From eeba295d0565a84036aa2312219a383b55bb970d Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Sat, 9 Nov 2024 19:49:15 +0000 Subject: [PATCH] chore: stop calling public kernel tail --- .github/ci-setup-action/action.yml | 9 +- .github/workflows/publish-aztec-packages.yml | 6 +- avm-transpiler/Cargo.lock | 20 +- barretenberg/.gitrepo | 4 +- barretenberg/cpp/CMakeLists.txt | 2 +- barretenberg/cpp/pil/avm/alu.pil | 13 +- barretenberg/cpp/pil/avm/gadgets/cmp.pil | 21 +- .../cpp/pil/avm/gadgets/range_check.pil | 3 + barretenberg/cpp/pil/avm/gas.pil | 1 - .../commitment_schemes/commitment_key.hpp | 6 +- .../sparse_commitment.test.cpp | 17 +- .../cpp/src/barretenberg/common/zip_view.hpp | 1 + .../cached_content_addressed_tree_store.hpp | 118 +- .../dsl/acir_format/acir_format.cpp | 13 +- .../acir_format/ivc_recursion_constraint.cpp | 165 + .../acir_format/ivc_recursion_constraint.hpp | 27 + .../ivc_recursion_constraint.test.cpp | 170 +- .../dsl/acir_format/proof_surgeon.hpp | 1 + .../barretenberg/dsl/acir_proofs/c_bind.cpp | 20 +- .../execution_trace/execution_trace.cpp | 8 +- .../execution_trace/execution_trace.hpp | 2 +- .../cpp/src/barretenberg/flavor/flavor.hpp | 6 +- .../honk/proof_system/permutation_library.hpp | 2 +- .../plonk/composer/composer_lib.hpp | 1 + .../execution_trace_usage_tracker.hpp | 2 +- .../arithmetization/mega_arithmetization.hpp | 12 +- .../arithmetization/ultra_arithmetization.hpp | 10 +- .../library/grand_product_library.hpp | 53 +- .../protogalaxy/protogalaxy.test.cpp | 5 +- .../honk_verifier/oink_recursive_verifier.cpp | 4 +- .../recursive_decider_verification_key.hpp | 2 +- .../grand_product_library.test.cpp | 9 +- .../stdlib_circuit_builders/mega_flavor.hpp | 23 +- .../ultra_circuit_builder.cpp | 1 + .../stdlib_circuit_builders/ultra_flavor.hpp | 22 +- .../ultra_honk/decider_proving_key.cpp | 6 +- .../ultra_honk/decider_proving_key.hpp | 39 +- .../ultra_honk/decider_verifier.cpp | 1 - .../barretenberg/ultra_honk/oink_prover.cpp | 9 +- .../barretenberg/ultra_honk/oink_verifier.cpp | 6 +- .../ultra_honk/relation_correctness.test.cpp | 10 +- .../barretenberg/ultra_honk/sumcheck.test.cpp | 3 +- .../vm/avm/generated/circuit_builder.cpp | 4 + .../barretenberg/vm/avm/generated/flavor.cpp | 1627 +- .../barretenberg/vm/avm/generated/flavor.hpp | 10 +- .../vm/avm/generated/full_row.cpp | 10 + .../vm/avm/generated/full_row.hpp | 7 +- .../vm/avm/generated/relations/alu.hpp | 134 +- .../vm/avm/generated/relations/cmp.hpp | 127 +- .../avm/generated/relations/perm_cmp_alu.hpp | 10 +- .../relations/perm_rng_non_ff_cmp.hpp | 53 + .../avm/generated/relations/range_check.hpp | 10 +- .../vm/avm/tests/arithmetic.test.cpp | 39 +- .../barretenberg/vm/avm/trace/alu_trace.cpp | 91 +- .../barretenberg/vm/avm/trace/alu_trace.hpp | 1 + .../vm/avm/trace/execution_hints.hpp | 150 +- .../barretenberg/vm/avm/trace/gadgets/cmp.cpp | 21 + .../barretenberg/vm/avm/trace/gadgets/cmp.hpp | 11 +- .../vm/avm/trace/gadgets/range_check.cpp | 3 + .../vm/avm/trace/gadgets/range_check.hpp | 4 +- .../src/barretenberg/vm/aztec_constants.hpp | 3 +- barretenberg/ts/src/barretenberg/backend.ts | 15 + barretenberg/ts/src/barretenberg_api/index.ts | 12 + .../developer_guides/getting_started.md | 6 +- .../developer_guides/js_apps/authwit.md | 6 +- .../how_to_compile_contract.md | 4 +- .../testing_contracts/testing.md | 12 +- .../writing_contracts/authwit.md | 8 +- .../common_patterns/index.md | 4 +- .../portals/communicate_with_portal.md | 2 +- docs/docs/migration_notes.md | 15 + .../sandbox_reference/cli_wallet_reference.md | 6 +- .../storage/private_state.md | 2 - .../codealong/aztecjs-getting-started.md | 2 +- .../codealong/cli_wallet/faceid_wallet.md | 4 +- .../token_bridge/1_depositing_to_aztec.md | 5 +- .../token_bridge/2_minting_on_aztec.md | 12 +- .../contract_tutorials/token_contract.md | 73 +- .../tutorials/examples/uniswap/l2_contract.md | 2 +- l1-contracts/foundry.toml | 1 + .../src/core/libraries/ConstantsGen.sol | 20 +- l1-contracts/src/core/libraries/Errors.sol | 4 + l1-contracts/src/core/libraries/FeeMath.sol | 80 + .../src/core/libraries/TxsDecoder.sol | 68 +- .../fee_portal/depositToAztecPublic.t.sol | 2 + .../test/fees/FeeModelTestPoints.t.sol | 65 + l1-contracts/test/fees/MinimalFeeModel.sol | 44 + l1-contracts/test/fees/MinimalFeeModel.t.sol | 69 + l1-contracts/test/fixtures/empty_block_1.json | 18 +- l1-contracts/test/fixtures/empty_block_2.json | 20 +- .../test/fixtures/fee_data_points.json | 26682 ++++++++++++++++ l1-contracts/test/fixtures/mixed_block_1.json | 20 +- l1-contracts/test/fixtures/mixed_block_2.json | 22 +- l1-contracts/test/portals/TokenPortal.sol | 8 +- l1-contracts/test/portals/TokenPortal.t.sol | 12 +- l1-contracts/test/portals/UniswapPortal.sol | 4 + l1-contracts/test/portals/UniswapPortal.t.sol | 6 + noir-projects/aztec-nr/.gitrepo | 4 +- .../aztec/src/context/private_context.nr | 13 +- .../aztec/src/encrypted_logs/payload.nr | 17 +- .../aztec-nr/aztec/src/macros/mod.nr | 10 + .../aztec-nr/aztec/src/macros/notes/mod.nr | 1 - .../aztec-nr/aztec/src/oracle/logs.nr | 28 +- .../aztec-nr/aztec/src/oracle/notes.nr | 44 +- .../aztec/src/state_vars/private_set.nr | 2 + .../app_subscription_contract/src/main.nr | 2 +- .../contracts/avm_test_contract/src/main.nr | 8 +- .../contracts/claim_contract/src/main.nr | 2 +- .../src/main.nr | 13 +- .../src/main.nr | 22 +- .../crowdfunding_contract/src/main.nr | 2 +- .../contracts/fee_juice_contract/src/lib.nr | 14 +- .../contracts/fpc_contract/src/main.nr | 4 +- .../contracts/lending_contract/src/main.nr | 8 +- .../contracts/nft_contract/src/main.nr | 18 +- .../src/test/transfer_to_private.nr | 6 +- .../contracts/test_contract/src/main.nr | 10 +- .../token_bridge_contract/src/main.nr | 11 +- .../contracts/token_contract/src/main.nr | 216 +- .../contracts/token_contract/src/test.nr | 17 +- .../contracts/token_contract/src/test/burn.nr | 188 - .../token_contract/src/test/burn_private.nr | 107 + .../token_contract/src/test/burn_public.nr | 89 + .../test/{minting.nr => mint_to_public.nr} | 30 +- .../token_contract/src/test/refunds.nr | 4 +- .../token_contract/src/test/shielding.nr | 179 - .../token_contract/src/test/transfer.nr | 64 + ...sfer_private.nr => transfer_in_private.nr} | 81 +- ...ansfer_public.nr => transfer_in_public.nr} | 54 +- .../src/test/transfer_to_private.nr | 21 +- .../src/test/transfer_to_public.nr | 14 +- .../token_contract/src/test/utils.nr | 10 +- .../contracts/token_contract/src/types.nr | 1 - .../src/types/transparent_note.nr | 63 - .../token_portal_content_hash_lib/src/lib.nr | 56 +- .../contracts/uniswap_contract/src/main.nr | 2 +- .../contracts/uniswap_contract/src/util.nr | 36 +- .../components/private_call_data_validator.nr | 17 +- ...private_kernel_circuit_output_validator.nr | 14 +- ...e_kernel_circuit_public_inputs_composer.nr | 16 +- .../src/components/reset_output_validator.nr | 4 +- .../src/components/tail_output_composer.nr | 6 +- .../tail_output_composer/meter_gas_used.nr | 4 +- .../src/components/tail_output_validator.nr | 15 +- .../tail_output_hints.nr | 22 +- .../meter_gas_used.nr | 8 +- .../split_to_public.nr | 16 +- .../tail_to_public_output_validator.nr | 12 +- .../tail_to_public_output_hints.nr | 18 +- .../src/private_kernel_tail.nr | 57 +- .../src/private_kernel_tail_to_public.nr | 5 +- .../validate_arrays.nr | 10 - .../validate_call.nr | 17 +- ...alidate_propagated_from_previous_kernel.nr | 15 +- .../validate_propagated_from_private_call.nr | 13 +- ..._from_previous_kernel_with_private_call.nr | 13 +- .../propagate_from_private_call.nr | 8 +- .../meter_gas_used.nr | 4 - .../validate_empty_values.nr | 9 + .../validate_propagated_sorted_values.nr | 32 +- .../meter_gas_used.nr | 4 +- .../split_to_public.nr | 11 +- .../tail_to_public_output_composer.nr | 24 +- .../combine_data.nr | 4 +- .../rollup-lib/src/base/public_base_rollup.nr | 15 +- .../crates/rollup-lib/src/components.nr | 46 +- .../combined_accumulated_data.nr | 24 +- .../private_accumulated_data.nr | 21 +- .../private_accumulated_data_builder.nr | 12 +- .../private_to_public_accumulated_data.nr | 20 +- ...vate_to_public_accumulated_data_builder.nr | 14 +- .../src/abis/avm_circuit_public_inputs.nr | 5 + .../private_kernel_circuit_public_inputs.nr | 8 +- .../src/abis/private_circuit_public_inputs.nr | 23 +- .../crates/types/src/constants.nr | 19 +- .../crates/types/src/hash.nr | 32 +- .../types/src/indexed_tagging_secret.nr | 9 +- .../crates/types/src/tests/fixture_builder.nr | 28 +- noir/noir-repo/.release-please-manifest.json | 4 +- noir/noir-repo/CHANGELOG.md | 28 + noir/noir-repo/Cargo.lock | 1438 +- noir/noir-repo/Cargo.toml | 17 +- noir/noir-repo/acvm-repo/CHANGELOG.md | 125 + noir/noir-repo/acvm-repo/acir/Cargo.toml | 2 +- .../noir-repo/acvm-repo/acir_field/Cargo.toml | 2 +- noir/noir-repo/acvm-repo/acvm/Cargo.toml | 2 +- .../compiler/optimizers/merge_expressions.rs | 192 +- noir/noir-repo/acvm-repo/acvm_js/Cargo.toml | 2 +- noir/noir-repo/acvm-repo/acvm_js/package.json | 2 +- .../acvm-repo/blackbox_solver/Cargo.toml | 2 +- .../bn254_blackbox_solver/Cargo.toml | 6 +- noir/noir-repo/acvm-repo/brillig/Cargo.toml | 2 +- .../noir-repo/acvm-repo/brillig_vm/Cargo.toml | 2 +- .../compiler/noirc_driver/src/abi_gen.rs | 20 +- .../compiler/noirc_driver/src/lib.rs | 5 +- .../compiler/noirc_evaluator/Cargo.toml | 4 +- .../src/brillig/brillig_gen/brillig_block.rs | 156 +- .../brillig/brillig_gen/brillig_directive.rs | 4 - .../noirc_evaluator/src/brillig/brillig_ir.rs | 82 + .../brillig_ir/codegen_control_flow.rs | 2 +- .../src/brillig/brillig_ir/procedures/mod.rs | 3 +- .../compiler/noirc_evaluator/src/lib.rs | 18 + .../compiler/noirc_evaluator/src/ssa.rs | 5 +- .../noirc_evaluator/src/ssa/acir_gen/mod.rs | 4 +- .../src/ssa/function_builder/data_bus.rs | 2 +- .../src/ssa/function_builder/mod.rs | 10 + .../noirc_evaluator/src/ssa/ir/dfg.rs | 5 +- .../src/ssa/ir/instruction/binary.rs | 10 +- .../noirc_evaluator/src/ssa/ir/printer.rs | 50 +- .../noirc_evaluator/src/ssa/ir/types.rs | 17 +- .../noirc_evaluator/src/ssa/opt/array_set.rs | 154 +- .../src/ssa/opt/as_slice_length.rs | 31 + .../src/ssa/opt/constant_folding.rs | 637 +- .../noirc_evaluator/src/ssa/opt/die.rs | 334 +- .../src/ssa/opt/flatten_cfg.rs | 388 +- .../noirc_evaluator/src/ssa/opt/mem2reg.rs | 132 +- .../src/ssa/opt/mem2reg/alias_set.rs | 7 + .../noirc_evaluator/src/ssa/opt/mod.rs | 27 + .../src/ssa/opt/remove_bit_shifts.rs | 33 +- .../noirc_evaluator/src/ssa/parser.rs | 902 + .../noirc_evaluator/src/ssa/parser/ast.rs | 139 + .../src/ssa/parser/into_ssa.rs | 317 + .../noirc_evaluator/src/ssa/parser/lexer.rs | 259 + .../noirc_evaluator/src/ssa/parser/tests.rs | 427 + .../noirc_evaluator/src/ssa/parser/token.rs | 269 + .../compiler/noirc_frontend/Cargo.toml | 2 + .../hir_def/types/arithmetic.txt | 7 + .../tests/arithmetic_generics.txt | 7 + .../noirc_frontend/src/ast/expression.rs | 4 +- .../noirc_frontend/src/ast/function.rs | 4 +- .../compiler/noirc_frontend/src/ast/mod.rs | 4 + .../noirc_frontend/src/ast/statement.rs | 10 +- .../noirc_frontend/src/ast/visitor.rs | 21 +- .../noirc_frontend/src/elaborator/comptime.rs | 62 +- .../noirc_frontend/src/elaborator/lints.rs | 8 +- .../noirc_frontend/src/elaborator/mod.rs | 28 +- .../src/elaborator/path_resolution.rs | 347 + .../noirc_frontend/src/elaborator/patterns.rs | 4 +- .../noirc_frontend/src/elaborator/scope.rs | 101 +- .../noirc_frontend/src/elaborator/traits.rs | 2 + .../noirc_frontend/src/elaborator/types.rs | 40 +- .../src/hir/comptime/display.rs | 3 +- .../noirc_frontend/src/hir/comptime/errors.rs | 20 +- .../src/hir/comptime/hir_to_display_ast.rs | 1 + .../src/hir/comptime/interpreter.rs | 46 +- .../src/hir/comptime/interpreter/builtin.rs | 147 +- .../src/hir/def_collector/dc_crate.rs | 103 +- .../src/hir/def_collector/dc_mod.rs | 3 +- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- .../src/hir/resolution/errors.rs | 13 +- .../src/hir/resolution/import.rs | 706 +- .../noirc_frontend/src/hir/resolution/mod.rs | 1 - .../src/hir/resolution/path_resolver.rs | 102 - .../src/hir/resolution/visibility.rs | 46 +- .../src/hir/type_check/errors.rs | 48 +- .../noirc_frontend/src/hir_def/function.rs | 5 +- .../noirc_frontend/src/hir_def/stmt.rs | 2 +- .../noirc_frontend/src/hir_def/types.rs | 238 +- .../src/hir_def/types/arithmetic.rs | 478 +- .../noirc_frontend/src/lexer/lexer.rs | 204 +- .../noirc_frontend/src/lexer/token.rs | 262 +- .../compiler/noirc_frontend/src/locations.rs | 59 +- .../src/monomorphization/ast.rs | 12 +- .../src/monomorphization/errors.rs | 18 +- .../src/monomorphization/mod.rs | 121 +- .../noirc_frontend/src/node_interner.rs | 1 + .../noirc_frontend/src/parser/errors.rs | 9 + .../noirc_frontend/src/parser/parser.rs | 24 + .../src/parser/parser/attributes.rs | 585 +- .../src/parser/parser/function.rs | 11 +- .../compiler/noirc_frontend/src/tests.rs | 125 +- .../src/tests/arithmetic_generics.rs | 155 + .../noirc_frontend/src/tests/imports.rs | 27 + .../noirc_frontend/src/tests/traits.rs | 18 +- .../noirc_frontend/src/tests/unused_items.rs | 20 + noir/noir-repo/compiler/wasm/package.json | 2 +- noir/noir-repo/compiler/wasm/src/compile.rs | 14 +- .../compiler/wasm/src/compile_new.rs | 14 +- noir/noir-repo/cspell.json | 6 +- noir/noir-repo/deny.toml | 18 +- .../docs/docs/how_to/how-to-oracles.md | 64 +- .../version-v0.32.0/how_to/how-to-oracles.md | 56 +- .../version-v0.33.0/how_to/how-to-oracles.md | 64 +- .../version-v0.34.0/how_to/how-to-oracles.md | 64 +- .../version-v0.35.0/how_to/how-to-oracles.md | 64 +- .../version-v0.36.0/how_to/how-to-oracles.md | 66 +- .../version-v0.37.0/how_to/how-to-oracles.md | 66 +- .../version-v0.38.0/explainers/cspell.json | 5 + .../explainers/explainer-oracle.md | 57 + .../explainers/explainer-recursion.md | 176 + .../explainers/explainer-writing-noir.md | 177 + .../getting_started/noir_installation.md | 106 + .../getting_started/project_breakdown.md | 159 + .../getting_started/quick_start.md | 126 + .../setting_up_shell_completions.md | 87 + .../version-v0.38.0/how_to/_category_.json | 5 + .../how_to/debugger/_category_.json | 6 + .../debugger/debugging_with_the_repl.md | 164 + .../how_to/debugger/debugging_with_vs_code.md | 68 + .../version-v0.38.0/how_to/how-to-oracles.md | 275 + .../how_to/how-to-recursion.md | 172 + .../how_to/how-to-solidity-verifier.md | 259 + .../version-v0.38.0/how_to/merkle-proof.mdx | 48 + .../how_to/using-devcontainers.mdx | 110 + .../versioned_docs/version-v0.38.0/index.mdx | 67 + .../version-v0.38.0/migration_notes.md | 105 + .../noir/concepts/_category_.json | 6 + .../version-v0.38.0/noir/concepts/assert.md | 78 + .../version-v0.38.0/noir/concepts/comments.md | 33 + .../version-v0.38.0/noir/concepts/comptime.md | 445 + .../noir/concepts/control_flow.md | 79 + .../noir/concepts/data_bus.mdx | 23 + .../noir/concepts/data_types/_category_.json | 5 + .../noir/concepts/data_types/arrays.md | 276 + .../noir/concepts/data_types/booleans.md | 28 + .../noir/concepts/data_types/fields.md | 246 + .../concepts/data_types/function_types.md | 26 + .../noir/concepts/data_types/index.md | 126 + .../noir/concepts/data_types/integers.md | 156 + .../noir/concepts/data_types/references.md | 23 + .../noir/concepts/data_types/slices.mdx | 358 + .../noir/concepts/data_types/strings.md | 79 + .../noir/concepts/data_types/structs.md | 96 + .../noir/concepts/data_types/tuples.md | 48 + .../noir/concepts/functions.md | 226 + .../version-v0.38.0/noir/concepts/generics.md | 251 + .../version-v0.38.0/noir/concepts/globals.md | 82 + .../version-v0.38.0/noir/concepts/lambdas.md | 81 + .../noir/concepts/mutability.md | 121 + .../version-v0.38.0/noir/concepts/ops.md | 98 + .../version-v0.38.0/noir/concepts/oracles.mdx | 29 + .../noir/concepts/shadowing.md | 44 + .../version-v0.38.0/noir/concepts/traits.md | 501 + .../noir/concepts/unconstrained.md | 104 + .../modules_packages_crates/_category_.json | 6 + .../crates_and_packages.md | 43 + .../modules_packages_crates/dependencies.md | 124 + .../noir/modules_packages_crates/modules.md | 221 + .../modules_packages_crates/workspaces.md | 42 + .../noir/standard_library/_category_.json | 6 + .../noir/standard_library/bigint.md | 127 + .../noir/standard_library/black_box_fns.md | 32 + .../noir/standard_library/bn254.md | 46 + .../standard_library/containers/boundedvec.md | 419 + .../standard_library/containers/hashmap.md | 587 + .../noir/standard_library/containers/index.md | 5 + .../noir/standard_library/containers/vec.mdx | 170 + .../cryptographic_primitives/_category_.json | 5 + .../cryptographic_primitives/ciphers.mdx | 32 + .../cryptographic_primitives/ec_primitives.md | 102 + .../ecdsa_sig_verification.mdx | 98 + .../cryptographic_primitives/eddsa.mdx | 37 + .../embedded_curve_ops.mdx | 95 + .../cryptographic_primitives/hashes.mdx | 227 + .../cryptographic_primitives/index.md | 14 + .../cryptographic_primitives/schnorr.mdx | 64 + .../noir/standard_library/fmtstr.md | 17 + .../noir/standard_library/is_unconstrained.md | 69 + .../noir/standard_library/logging.md | 78 + .../noir/standard_library/mem.md | 52 + .../noir/standard_library/merkle_trees.md | 58 + .../noir/standard_library/meta/ctstring.md | 100 + .../noir/standard_library/meta/expr.md | 380 + .../standard_library/meta/function_def.md | 166 + .../noir/standard_library/meta/index.md | 224 + .../noir/standard_library/meta/module.md | 82 + .../noir/standard_library/meta/op.md | 244 + .../noir/standard_library/meta/quoted.md | 141 + .../noir/standard_library/meta/struct_def.md | 177 + .../standard_library/meta/trait_constraint.md | 17 + .../noir/standard_library/meta/trait_def.md | 26 + .../noir/standard_library/meta/trait_impl.md | 60 + .../noir/standard_library/meta/typ.md | 264 + .../noir/standard_library/meta/typed_expr.md | 27 + .../standard_library/meta/unresolved_type.md | 57 + .../noir/standard_library/options.md | 101 + .../noir/standard_library/recursion.mdx | 85 + .../noir/standard_library/traits.md | 628 + .../reference/NoirJS/noir_js/.nojekyll | 1 + .../reference/NoirJS/noir_js/classes/Noir.md | 52 + .../reference/NoirJS/noir_js/functions/and.md | 22 + .../NoirJS/noir_js/functions/blake2s256.md | 21 + .../functions/ecdsa_secp256k1_verify.md | 28 + .../functions/ecdsa_secp256r1_verify.md | 28 + .../reference/NoirJS/noir_js/functions/xor.md | 22 + .../reference/NoirJS/noir_js/index.md | 47 + .../noir_js/type-aliases/ErrorWithPayload.md | 15 + .../type-aliases/ForeignCallHandler.md | 24 + .../noir_js/type-aliases/ForeignCallInput.md | 9 + .../noir_js/type-aliases/ForeignCallOutput.md | 9 + .../NoirJS/noir_js/type-aliases/WitnessMap.md | 9 + .../NoirJS/noir_js/typedoc-sidebar.cjs | 4 + .../reference/NoirJS/noir_wasm/.nojekyll | 1 + .../NoirJS/noir_wasm/functions/compile.md | 51 + .../noir_wasm/functions/compile_contract.md | 51 + .../noir_wasm/functions/createFileManager.md | 21 + .../functions/inflateDebugSymbols.md | 21 + .../reference/NoirJS/noir_wasm/index.md | 49 + .../NoirJS/noir_wasm/typedoc-sidebar.cjs | 4 + .../version-v0.38.0/reference/_category_.json | 5 + .../reference/debugger/_category_.json | 6 + .../debugger/debugger_known_limitations.md | 59 + .../reference/debugger/debugger_repl.md | 360 + .../reference/debugger/debugger_vscode.md | 82 + .../reference/nargo_commands.md | 474 + .../version-v0.38.0/reference/noir_codegen.md | 116 + .../version-v0.38.0/tooling/debugger.md | 26 + .../tooling/language_server.md | 43 + .../version-v0.38.0/tooling/testing.md | 79 + .../version-v0.38.0/tutorials/noirjs_app.md | 366 + .../version-v0.38.0-sidebars.json | 93 + .../codegen_verifier/codegen_verifier.sh | 13 +- .../examples/codegen_verifier/src/main.nr | 4 +- noir/noir-repo/noir_stdlib/src/ec/tecurve.nr | 2 +- .../attribute_args/src/main.nr | 8 +- .../bit_shifts_comptime/src/main.nr | 4 + .../bit_shifts_runtime/Prover.toml | 1 + .../bit_shifts_runtime/src/main.nr | 4 +- .../execution_success/eddsa/src/main.nr | 1 - .../execution_success/references/src/main.nr | 18 +- .../regression_6451/Nargo.toml | 5 + .../regression_6451/Prover.toml | 1 + .../regression_6451/src/main.nr | 23 + .../lsp/src/attribute_reference_finder.rs | 70 +- .../tooling/lsp/src/requests/completion.rs | 53 +- .../lsp/src/requests/completion/builtins.rs | 9 + .../lsp/src/requests/completion/tests.rs | 4 +- .../lsp/src/requests/goto_definition.rs | 1 - .../tooling/lsp/src/requests/hover.rs | 2 +- .../tooling/lsp/src/requests/inlay_hint.rs | 1 + .../src/trait_impl_method_stub_generator.rs | 1 + noir/noir-repo/tooling/lsp/src/visibility.rs | 27 +- noir/noir-repo/tooling/nargo_cli/Cargo.toml | 1 + noir/noir-repo/tooling/nargo_cli/build.rs | 14 +- .../tooling/nargo_cli/src/cli/compile_cmd.rs | 2 +- .../noir-repo/tooling/nargo_fmt/src/chunks.rs | 11 +- .../tooling/nargo_fmt/src/formatter.rs | 9 +- .../nargo_fmt/src/formatter/attribute.rs | 346 +- .../tooling/nargo_fmt/src/formatter/buffer.rs | 4 +- .../src/formatter/comments_and_whitespace.rs | 3 +- .../nargo_fmt/src/formatter/expression.rs | 22 +- .../nargo_fmt/src/formatter/function.rs | 64 +- .../tooling/nargo_fmt/src/formatter/item.rs | 2 +- .../tooling/nargo_fmt/src/formatter/module.rs | 8 +- .../nargo_fmt/src/formatter/statement.rs | 26 +- .../nargo_fmt/src/formatter/structs.rs | 4 +- .../tooling/nargo_fmt/src/formatter/traits.rs | 7 +- .../src/formatter/type_expression.rs | 6 +- .../tooling/nargo_fmt/src/formatter/types.rs | 6 +- .../nargo_fmt/src/formatter/visibility.rs | 3 +- .../nargo_fmt/tests/expected/parens.nr | 1 + .../tooling/noir_codegen/package.json | 2 +- noir/noir-repo/tooling/noir_js/package.json | 2 +- .../tooling/noir_js_types/package.json | 2 +- .../tooling/noirc_abi_wasm/package.json | 2 +- spartan/terraform/eks-cluster/main.tf | 72 +- spartan/terraform/gke-cluster/main.tf | 173 + spartan/terraform/gke-cluster/outputs.tf | 17 + spartan/terraform/gke-cluster/variables.tf | 11 + .../archiver/src/archiver/archiver.test.ts | 6 + .../archiver/src/archiver/archiver.ts | 48 +- .../archiver/src/archiver/archiver_store.ts | 11 +- .../src/archiver/archiver_store_test_suite.ts | 105 +- .../kv_archiver_store/kv_archiver_store.ts | 17 +- .../archiver/kv_archiver_store/log_store.ts | 93 +- .../memory_archiver_store.ts | 186 +- .../aztec-node/src/aztec-node/server.ts | 29 +- .../account_manager/deploy_account_sent_tx.ts | 2 - .../aztec.js/src/account_manager/index.ts | 4 +- .../aztec.js/src/contract/proven_tx.ts | 2 + .../aztec.js/src/contract/sent_tx.test.ts | 19 +- yarn-project/aztec.js/src/contract/sent_tx.ts | 42 +- .../src/fee/public_fee_payment_method.ts | 4 +- yarn-project/aztec.js/src/index.ts | 2 +- yarn-project/aztec.js/src/utils/account.ts | 33 - yarn-project/aztec.js/src/utils/index.ts | 1 - .../aztec.js/src/wallet/base_wallet.ts | 10 +- yarn-project/bb-prover/package.json | 2 + .../bb-prover/src/avm_proving.test.ts | 8 +- yarn-project/bb-prover/tsconfig.json | 10 +- yarn-project/bot/src/bot.ts | 6 +- yarn-project/bot/src/factory.ts | 2 +- yarn-project/bot/src/utils.ts | 2 +- yarn-project/circuit-types/src/body.ts | 13 +- .../src/interfaces/archiver.test.ts | 21 +- .../circuit-types/src/interfaces/archiver.ts | 5 +- .../src/interfaces/aztec-node.test.ts | 35 +- .../src/interfaces/aztec-node.ts | 33 +- .../circuit-types/src/interfaces/pxe.test.ts | 42 +- .../circuit-types/src/interfaces/pxe.ts | 28 +- .../src/interfaces/sync-status.ts | 3 - yarn-project/circuit-types/src/l2_block.ts | 8 + .../src/logs/get_logs_response.test.ts | 10 + .../src/logs/get_logs_response.ts | 42 +- .../l1_payload/encrypted_log_payload.test.ts | 8 +- .../src/logs/l2_block_l2_logs.test.ts | 28 +- .../src/logs/l2_block_l2_logs.ts | 98 +- .../circuit-types/src/logs/l2_logs_source.ts | 11 +- .../circuit-types/src/logs/tx_l2_logs.test.ts | 17 +- .../circuit-types/src/logs/tx_l2_logs.ts | 96 +- .../src/messaging/l1_to_l2_message.ts | 2 +- yarn-project/circuit-types/src/mocks.ts | 63 +- .../src/private_execution_result.ts | 32 +- .../circuit-types/src/stats/metrics.ts | 32 - yarn-project/circuit-types/src/stats/stats.ts | 50 +- .../circuit-types/src/test/factories.ts | 6 +- .../circuit-types/src/tx/processed_tx.ts | 5 + .../circuit-types/src/tx/simulated_tx.ts | 21 +- yarn-project/circuit-types/src/tx/tx.ts | 34 +- .../circuit-types/src/tx/tx_receipt.ts | 15 - .../circuit-types/src/tx_effect.test.ts | 2 +- yarn-project/circuit-types/src/tx_effect.ts | 18 +- yarn-project/circuits.js/src/constants.gen.ts | 21 +- .../contract_instance_deployed_event.ts | 9 +- ...strained_function_membership_proof.test.ts | 2 + .../circuits.js/src/structs/avm/avm.ts | 469 +- .../structs/avm/avm_circuit_public_inputs.ts | 6 + .../kernel/combined_accumulated_data.ts | 23 + .../kernel/private_accumulated_data.ts | 12 +- .../private_to_public_accumulated_data.ts | 16 +- ...vate_to_public_accumulated_data_builder.ts | 16 +- .../structs/private_circuit_public_inputs.ts | 16 +- .../circuits.js/src/structs/tagging_secret.ts | 28 +- .../circuits.js/src/tests/factories.ts | 84 +- .../circuits.js/src/tests/fixtures.ts | 4 +- yarn-project/cli-wallet/test/flows/basic.sh | 2 +- .../cli-wallet/test/flows/no_alias.sh | 2 +- .../test/flows/private_authwit_transfer.sh | 6 +- .../test/flows/public_authwit_transfer.sh | 6 +- .../test/flows/shield_and_transfer.sh | 2 +- .../create_main_and_mint_private.sh | 6 +- .../create_main_and_mint_public.sh | 2 +- yarn-project/cli/src/cmds/pxe/get_block.ts | 5 +- .../benchmarks/bench_process_history.test.ts | 13 +- .../src/benchmarks/bench_prover.test.ts | 4 +- .../benchmarks/bench_publish_rollup.test.ts | 6 +- .../src/benchmarks/bench_tx_size_fees.test.ts | 2 +- .../end-to-end/src/benchmarks/utils.ts | 25 +- .../src/composed/docs_examples.test.ts | 2 +- .../src/composed/e2e_persistence.test.ts | 5 - .../end-to-end/src/e2e_2_pxes.test.ts | 47 +- .../blacklist_token_contract_test.ts | 4 +- .../minting.test.ts | 13 +- .../shielding.test.ts | 14 +- .../end-to-end/src/e2e_block_building.test.ts | 2 +- .../end-to-end/src/e2e_cheat_codes.test.ts | 1 + .../token_bridge_failure_cases.test.ts | 2 +- .../token_bridge_private.test.ts | 2 +- .../token_bridge_public_to_private.test.ts | 59 - .../src/e2e_crowdfunding_and_claim.test.ts | 34 +- .../contract_class_registration.test.ts | 4 +- .../src/e2e_fees/account_init.test.ts | 8 +- .../src/e2e_fees/dapp_subscription.test.ts | 2 +- .../end-to-end/src/e2e_fees/failures.test.ts | 24 +- .../src/e2e_fees/fee_juice_payments.test.ts | 6 +- .../end-to-end/src/e2e_fees/fees_test.ts | 22 +- .../src/e2e_fees/gas_estimation.test.ts | 2 +- .../src/e2e_fees/private_payments.test.ts | 71 +- .../src/e2e_lending_contract.test.ts | 12 +- .../e2e_pending_note_hashes_contract.test.ts | 12 +- .../src/e2e_prover/e2e_prover_test.ts | 35 +- .../end-to-end/src/e2e_prover/full.test.ts | 4 +- .../end-to-end/src/e2e_synching.test.ts | 28 +- .../src/e2e_token_contract/burn.test.ts | 18 +- .../src/e2e_token_contract/minting.test.ts | 10 +- .../src/e2e_token_contract/shielding.test.ts | 131 - .../e2e_token_contract/token_contract_test.ts | 38 +- .../src/e2e_token_contract/transfer.test.ts | 85 + ...te.test.ts => transfer_in_private.test.ts} | 82 +- ...lic.test.ts => transfer_in_public.test.ts} | 30 +- .../transfer_to_private.test.ts | 59 + .../end-to-end/src/fixtures/token_utils.ts | 15 +- ...akey_e2e_inclusion_proofs_contract.test.ts | 10 +- .../src/guides/dapp_testing.test.ts | 17 +- .../writing_an_account_contract.test.ts | 2 +- .../end-to-end/src/sample-dapp/index.mjs | 2 +- .../src/shared/cross_chain_test_harness.ts | 26 +- .../end-to-end/src/shared/uniswap_l1_l2.ts | 8 +- .../src/simulators/lending_simulator.ts | 2 +- .../src/simulators/token_simulator.ts | 8 +- .../end-to-end/src/spartan/4epochs.test.ts | 2 +- .../src/spartan/setup_test_wallets.ts | 4 +- .../end-to-end/src/spartan/transfer.test.ts | 2 +- yarn-project/ivc-integration/package.json | 5 +- .../ivc-integration/package.local.json | 2 +- .../src/avm_integration.test.ts | 8 +- yarn-project/ivc-integration/tsconfig.json | 15 +- .../src/type_conversion.ts | 22 +- .../pxe/src/contract_data_oracle/index.ts | 5 + .../src/database/deferred_note_dao.test.ts | 24 - .../pxe/src/database/deferred_note_dao.ts | 47 - .../pxe/src/database/incoming_note_dao.ts | 2 +- .../pxe/src/database/kv_pxe_database.ts | 104 +- .../pxe/src/database/outgoing_note_dao.ts | 2 +- yarn-project/pxe/src/database/pxe_database.ts | 47 +- ...ild_private_kernel_reset_private_inputs.ts | 12 +- .../add_public_values_to_payload.ts | 2 +- .../brute_force_note_info.ts | 0 .../utils => note_decryption_utils}/index.ts | 0 .../produce_note_daos.ts | 22 +- .../produce_note_daos_for_key.ts | 21 +- yarn-project/pxe/src/note_processor/index.ts | 1 - .../src/note_processor/note_processor.test.ts | 391 - .../pxe/src/note_processor/note_processor.ts | 358 - .../pxe/src/pxe_service/pxe_service.ts | 51 +- .../pxe/src/simulator_oracle/index.ts | 273 +- .../simulator_oracle/simulator_oracle.test.ts | 255 +- .../pxe/src/synchronizer/synchronizer.test.ts | 67 +- .../pxe/src/synchronizer/synchronizer.ts | 256 +- .../scripts/src/benchmarks/aggregate.ts | 12 - .../src/tx_validator/gas_validator.ts | 4 +- .../src/tx_validator/phases_validator.ts | 4 +- .../simulator/src/acvm/oracle/oracle.ts | 20 +- .../simulator/src/acvm/oracle/typed_oracle.ts | 12 +- .../simulator/src/avm/avm_simulator.test.ts | 295 +- .../simulator/src/avm/avm_simulator.ts | 4 +- .../simulator/src/avm/fixtures/index.ts | 6 +- .../simulator/src/avm/journal/journal.test.ts | 35 +- .../simulator/src/avm/journal/journal.ts | 310 +- .../src/avm/opcodes/accrued_substate.test.ts | 10 +- .../src/avm/opcodes/accrued_substate.ts | 2 +- .../src/avm/opcodes/arithmetic.test.ts | 1 - .../simulator/src/avm/opcodes/arithmetic.ts | 23 +- .../src/avm/opcodes/external_calls.ts | 5 +- .../simulator/src/avm/opcodes/storage.ts | 2 +- .../src/client/client_execution_context.ts | 46 +- .../simulator/src/client/db_oracle.ts | 17 +- .../src/client/private_execution.test.ts | 27 +- .../simulator/src/client/private_execution.ts | 4 +- .../client/unconstrained_execution.test.ts | 2 + .../simulator/src/client/view_data_oracle.ts | 17 +- .../src/public/dual_side_effect_trace.ts | 147 +- .../enqueued_call_side_effect_trace.test.ts | 174 +- .../public/enqueued_call_side_effect_trace.ts | 275 +- .../src/public/enqueued_calls_processor.ts | 540 - yarn-project/simulator/src/public/index.ts | 3 +- .../simulator/src/public/public_db_sources.ts | 16 +- .../src/public/public_processor.test.ts | 14 +- .../simulator/src/public/public_processor.ts | 8 +- .../simulator/src/public/public_tx_context.ts | 269 + ...or.test.ts => public_tx_processor.test.ts} | 50 +- .../src/public/public_tx_processor.ts | 261 + .../src/public/side_effect_trace.test.ts | 143 +- .../simulator/src/public/side_effect_trace.ts | 127 +- .../src/public/side_effect_trace_interface.ts | 62 +- yarn-project/simulator/src/public/utils.ts | 182 + yarn-project/txe/package.json | 2 +- yarn-project/txe/src/oracle/txe_oracle.ts | 149 +- .../txe/src/txe_service/txe_service.ts | 8 +- yarn-project/yarn.lock | 21 +- 650 files changed, 56465 insertions(+), 10347 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.cpp create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp create mode 100644 l1-contracts/src/core/libraries/FeeMath.sol create mode 100644 l1-contracts/test/fees/FeeModelTestPoints.t.sol create mode 100644 l1-contracts/test/fees/MinimalFeeModel.sol create mode 100644 l1-contracts/test/fees/MinimalFeeModel.t.sol create mode 100644 l1-contracts/test/fixtures/fee_data_points.json delete mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr create mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/test/burn_private.nr create mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/test/burn_public.nr rename noir-projects/noir-contracts/contracts/token_contract/src/test/{minting.nr => mint_to_public.nr} (58%) delete mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr create mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr rename noir-projects/noir-contracts/contracts/token_contract/src/test/{transfer_private.nr => transfer_in_private.nr} (51%) rename noir-projects/noir-contracts/contracts/token_contract/src/test/{transfer_public.nr => transfer_in_public.nr} (70%) delete mode 100644 noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/ast.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/into_ssa.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/lexer.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/tests.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/token.rs create mode 100644 noir/noir-repo/compiler/noirc_frontend/proptest-regressions/hir_def/types/arithmetic.txt create mode 100644 noir/noir-repo/compiler/noirc_frontend/proptest-regressions/tests/arithmetic_generics.txt create mode 100644 noir/noir-repo/compiler/noirc_frontend/src/elaborator/path_resolution.rs delete mode 100644 noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/path_resolver.rs create mode 100644 noir/noir-repo/compiler/noirc_frontend/src/tests/arithmetic_generics.rs create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/cspell.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-oracle.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-recursion.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-writing-noir.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/noir_installation.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/project_breakdown.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/quick_start.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/setting_up_shell_completions.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_the_repl.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_vs_code.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-oracles.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-recursion.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-solidity-verifier.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/merkle-proof.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/using-devcontainers.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/index.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/migration_notes.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/assert.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comments.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comptime.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/control_flow.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_bus.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/arrays.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/booleans.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/fields.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/function_types.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/integers.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/references.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/slices.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/strings.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/structs.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/tuples.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/functions.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/generics.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/globals.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/lambdas.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/mutability.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/ops.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/oracles.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/shadowing.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/traits.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/unconstrained.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/crates_and_packages.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/dependencies.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/modules.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/workspaces.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bigint.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/black_box_fns.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bn254.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/boundedvec.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/hashmap.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/vec.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ciphers.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ec_primitives.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/eddsa.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/embedded_curve_ops.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/hashes.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/schnorr.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/fmtstr.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/is_unconstrained.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/logging.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/mem.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/merkle_trees.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/ctstring.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/expr.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/function_def.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/module.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/op.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/quoted.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/struct_def.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_constraint.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_def.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_impl.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typ.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typed_expr.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/unresolved_type.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/options.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/recursion.mdx create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/traits.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/.nojekyll create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/classes/Noir.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/and.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/blake2s256.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256k1_verify.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256r1_verify.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/xor.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ErrorWithPayload.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallInput.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/WitnessMap.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/typedoc-sidebar.cjs create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/.nojekyll create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile_contract.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/createFileManager.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/inflateDebugSymbols.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/index.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/typedoc-sidebar.cjs create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/_category_.json create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_known_limitations.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_repl.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_vscode.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/nargo_commands.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/noir_codegen.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/debugger.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/language_server.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/testing.md create mode 100644 noir/noir-repo/docs/versioned_docs/version-v0.38.0/tutorials/noirjs_app.md create mode 100644 noir/noir-repo/docs/versioned_sidebars/version-v0.38.0-sidebars.json create mode 100644 noir/noir-repo/test_programs/execution_success/regression_6451/Nargo.toml create mode 100644 noir/noir-repo/test_programs/execution_success/regression_6451/Prover.toml create mode 100644 noir/noir-repo/test_programs/execution_success/regression_6451/src/main.nr create mode 100644 spartan/terraform/gke-cluster/main.tf create mode 100644 spartan/terraform/gke-cluster/outputs.tf create mode 100644 spartan/terraform/gke-cluster/variables.tf delete mode 100644 yarn-project/aztec.js/src/utils/account.ts create mode 100644 yarn-project/circuit-types/src/logs/get_logs_response.test.ts delete mode 100644 yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts delete mode 100644 yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts create mode 100644 yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts rename yarn-project/end-to-end/src/e2e_token_contract/{transfer_private.test.ts => transfer_in_private.test.ts} (69%) rename yarn-project/end-to-end/src/e2e_token_contract/{transfer_public.test.ts => transfer_in_public.test.ts} (85%) create mode 100644 yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts delete mode 100644 yarn-project/pxe/src/database/deferred_note_dao.test.ts delete mode 100644 yarn-project/pxe/src/database/deferred_note_dao.ts rename yarn-project/pxe/src/{note_processor/utils => note_decryption_utils}/add_public_values_to_payload.ts (97%) rename yarn-project/pxe/src/{note_processor/utils => note_decryption_utils}/brute_force_note_info.ts (100%) rename yarn-project/pxe/src/{note_processor/utils => note_decryption_utils}/index.ts (100%) rename yarn-project/pxe/src/{note_processor/utils => note_decryption_utils}/produce_note_daos.ts (79%) rename yarn-project/pxe/src/{note_processor/utils => note_decryption_utils}/produce_note_daos_for_key.ts (62%) delete mode 100644 yarn-project/pxe/src/note_processor/index.ts delete mode 100644 yarn-project/pxe/src/note_processor/note_processor.test.ts delete mode 100644 yarn-project/pxe/src/note_processor/note_processor.ts delete mode 100644 yarn-project/simulator/src/public/enqueued_calls_processor.ts create mode 100644 yarn-project/simulator/src/public/public_tx_context.ts rename yarn-project/simulator/src/public/{enqueued_calls_processor.test.ts => public_tx_processor.test.ts} (92%) create mode 100644 yarn-project/simulator/src/public/public_tx_processor.ts create mode 100644 yarn-project/simulator/src/public/utils.ts diff --git a/.github/ci-setup-action/action.yml b/.github/ci-setup-action/action.yml index 93ad03f59413..8550966fe124 100644 --- a/.github/ci-setup-action/action.yml +++ b/.github/ci-setup-action/action.yml @@ -19,18 +19,11 @@ runs: echo HOME=$RUN_HOME >> $GITHUB_ENV mkdir -p $RUN_HOME - - name: Cache Submodules - id: cache-submodules - uses: actions/cache@v4 - with: - path: .git/modules - key: submodules-${{ hashFiles('.gitmodules') }}-spot-ebs - - name: Checkout Submodules shell: bash run: | git config --global --add safe.directory '*' - git submodule sync --recursive && git submodule update --init --recursive + git submodule update --init --recursive # TODO reconsider how jq gets into image - name: Setup jq diff --git a/.github/workflows/publish-aztec-packages.yml b/.github/workflows/publish-aztec-packages.yml index 7369207ab0d6..ad2d5b355d36 100644 --- a/.github/workflows/publish-aztec-packages.yml +++ b/.github/workflows/publish-aztec-packages.yml @@ -322,7 +322,11 @@ jobs: working-directory: ./aztec-up/terraform run: | terraform init - TAG=${{ env.DEPLOY_TAG }} + if [ "${{ github.ref_name }}" == "master" ]; then + TAG=master + else + TAG=${{ env.DEPLOY_TAG }} + fi export TF_VAR_VERSION=${TAG#aztec-packages-v} terraform apply -auto-approve diff --git a/avm-transpiler/Cargo.lock b/avm-transpiler/Cargo.lock index 0e6d94a39aa5..47110353d7ad 100644 --- a/avm-transpiler/Cargo.lock +++ b/avm-transpiler/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir_field", "base64 0.21.7", @@ -18,7 +18,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.53.0" +version = "0.54.0" dependencies = [ "ark-bn254", "ark-ff", @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "blake2", @@ -370,7 +370,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir_field", "serde", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -675,7 +675,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.37.0" +version = "0.38.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -830,7 +830,7 @@ checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "iter-extended" -version = "0.37.0" +version = "0.38.0" [[package]] name = "itertools" @@ -935,7 +935,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "base64 0.21.7", @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "iter-extended", diff --git a/barretenberg/.gitrepo b/barretenberg/.gitrepo index c05a1fd68a01..4572f4629de4 100644 --- a/barretenberg/.gitrepo +++ b/barretenberg/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/barretenberg branch = master - commit = c76755f0cba150633949c40506aa53dd4c7e9ec8 - parent = 32a546cbabee6570a3e84bbd15cf0ab3dd58f9a3 + commit = e13d72485ea6fc45715ce424b2e1a88f7d21376e + parent = 5997c823077d686107408caa8b4d148e115b62ac method = merge cmdver = 0.4.6 diff --git a/barretenberg/cpp/CMakeLists.txt b/barretenberg/cpp/CMakeLists.txt index ebbe45edd4d0..302e997f4340 100644 --- a/barretenberg/cpp/CMakeLists.txt +++ b/barretenberg/cpp/CMakeLists.txt @@ -31,7 +31,7 @@ option(DISABLE_AZTEC_VM "Don't build Aztec VM (acceptable if iterating on core p option(MULTITHREADING "Enable multi-threading" ON) option(OMP_MULTITHREADING "Enable OMP multi-threading" OFF) option(FUZZING "Build ONLY fuzzing harnesses" OFF) -option(ENABLE_PAR_ALGOS "Enable parallel algorithms" ON) +option(ENABLE_PAR_ALGOS "Enable parallel algorithms" OFF) option(COVERAGE "Enable collecting coverage from tests" OFF) option(ENABLE_ASAN "Address sanitizer for debugging tricky memory corruption" OFF) option(ENABLE_HEAVY_TESTS "Enable heavy tests when collecting coverage" OFF) diff --git a/barretenberg/cpp/pil/avm/alu.pil b/barretenberg/cpp/pil/avm/alu.pil index 4462161e9179..7014885fbd5c 100644 --- a/barretenberg/cpp/pil/avm/alu.pil +++ b/barretenberg/cpp/pil/avm/alu.pil @@ -84,17 +84,21 @@ namespace alu(256); pol commit cmp_gadget_input_b; pol commit cmp_gadget_result; pol commit cmp_gadget_gt; + pol commit cmp_gadget_non_ff_gt; // We use the comparison gadget to test GT for the following operations - cmp_gadget_gt = op_lt + op_lte + op_div + op_shr + op_shl; + pol CMP_GADGET_GT = op_lt + op_lte + op_div + op_shr + op_shl; + cmp_gadget_gt = CMP_GADGET_GT * ff_tag; + cmp_gadget_non_ff_gt = CMP_GADGET_GT * (1 - ff_tag); + // The cmp gadget is on when we are either testing GT or EQ - cmp_gadget_sel - (cmp_gadget_gt + op_eq) = 0; + cmp_gadget_sel - (cmp_gadget_gt + op_eq + cmp_gadget_non_ff_gt) = 0; // Permutation to the Comparison Gadget #[PERM_CMP_ALU] - cmp.sel_cmp {cmp.clk, cmp.input_a, cmp.input_b, cmp.result, cmp.op_eq, cmp.op_gt} + cmp.sel_cmp {cmp.clk, cmp.input_a, cmp.input_b, cmp.result, cmp.op_eq, cmp.op_gt, cmp.op_non_ff_gt} is - cmp_gadget_sel {clk, cmp_gadget_input_a, cmp_gadget_input_b, cmp_gadget_result, op_eq, cmp_gadget_gt }; + cmp_gadget_sel {clk, cmp_gadget_input_a, cmp_gadget_input_b, cmp_gadget_result, op_eq, cmp_gadget_gt, cmp_gadget_non_ff_gt }; // =============== HELPER POLYNOMIAL RELATIONS ================================================= @@ -143,6 +147,7 @@ namespace alu(256); // This holds the product over the integers // (u1 multiplication only cares about a_lo and b_lo) + // TODO(9937): The following is not well constrained as this expression overflows the field. pol PRODUCT = a_lo * b_lo + (1 - u1_tag) * (LIMB_BITS_POW * partial_prod_lo + MAX_BITS_POW * (partial_prod_hi + a_hi * b_hi)); // =============== ADDITION/SUBTRACTION Operation Constraints ================================================= diff --git a/barretenberg/cpp/pil/avm/gadgets/cmp.pil b/barretenberg/cpp/pil/avm/gadgets/cmp.pil index 2664880a55cf..bca804236890 100644 --- a/barretenberg/cpp/pil/avm/gadgets/cmp.pil +++ b/barretenberg/cpp/pil/avm/gadgets/cmp.pil @@ -16,6 +16,25 @@ namespace cmp(256); pol commit input_b; pol commit result; + // ========= NON FF GT Short-circuit computation =============================== + // If this is a non-ff check, we can short circuit (a > b) by checking + // 0 < a - b - 1 < 2**128 --> i.e. we just check we dont underlow which for "small" sized 128-bit number is just a + // single 128 bit range check + // This will be constrained by the calling function - maybe through instruction decomposition + pol commit op_non_ff_gt; + // Value of a - b + pol commit diff; + + pol A_GT_B = input_a - input_b - 1; + pol B_GTE_A = input_b - input_a; + op_non_ff_gt * (diff - (A_GT_B * result) - (B_GTE_A * (1 - result))) = 0; + + #[PERM_RNG_NON_FF_CMP] + range_check.cmp_non_ff_rng_chk {range_check.clk, range_check.value} + is + op_non_ff_gt {range_chk_clk, diff}; + + // ========= FF GT computation =============================== // We range check two columns per row of the cmp gadget, the lo and hi bit ranges resp. #[PERM_RNG_CMP_LO] range_check.cmp_lo_bits_rng_chk {range_check.clk, range_check.value} @@ -32,7 +51,7 @@ namespace cmp(256); pol commit op_eq; pol commit op_gt; - sel_cmp = op_eq + op_gt; + sel_cmp = op_eq + op_gt + op_non_ff_gt; // There are some standardised constraints on this gadget // The result is always a boolean diff --git a/barretenberg/cpp/pil/avm/gadgets/range_check.pil b/barretenberg/cpp/pil/avm/gadgets/range_check.pil index 872c12f0b8c6..d3d111682128 100644 --- a/barretenberg/cpp/pil/avm/gadgets/range_check.pil +++ b/barretenberg/cpp/pil/avm/gadgets/range_check.pil @@ -201,6 +201,9 @@ namespace range_check(256); // We range check 128 bits in the cmp trace cmp_lo_bits_rng_chk * (rng_chk_bits - 128) = 0; cmp_hi_bits_rng_chk * (rng_chk_bits - 128) = 0; + // For non FF + pol commit cmp_non_ff_rng_chk; + cmp_non_ff_rng_chk * (rng_chk_bits - 128) = 0; // ==== ALU TRACE RANGE CHECKS ==== pol commit alu_rng_chk; diff --git a/barretenberg/cpp/pil/avm/gas.pil b/barretenberg/cpp/pil/avm/gas.pil index 4eb833c2b0d2..32b1a858c866 100644 --- a/barretenberg/cpp/pil/avm/gas.pil +++ b/barretenberg/cpp/pil/avm/gas.pil @@ -96,7 +96,6 @@ namespace main(256); // We range check that the absolute value of the differences between each row of l2 and da gas are 32 bits. pol commit l2_gas_u16_r0; pol commit l2_gas_u16_r1; - // Do we need DA? main.abs_l2_rem_gas = l2_gas_u16_r0 + l2_gas_u16_r1 * 2**16; #[LOOKUP_L2_GAS_RNG_CHK_0] diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp index bdedf7f2c199..6440c016a627 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp @@ -269,15 +269,15 @@ template class CommitmentKey { // Percentage of constant coefficients below which we resort to the conventional commit method constexpr size_t CONSTANT_THRESHOLD = 50; - // Compute the active range complement over which the polynomial is assumed to be constant within each range + // Compute the active range complement over which the polynomial is assumed to be constant within each range. + // Note: the range from the end of the last active range to the end of the polynomial is excluded from the + // complement since the polynomial is assumed to be zero there. std::vector> active_ranges_complement; for (size_t i = 0; i < active_ranges.size() - 1; ++i) { const size_t start = active_ranges[i].second; const size_t end = active_ranges[i + 1].first; active_ranges_complement.emplace_back(start, end); } - // Final complement range goes from end of last active range to the end of the polynomial - active_ranges_complement.emplace_back(active_ranges.back().second, polynomial.end_index()); // Compute the total number of scalars in the constant regions size_t total_num_complement_scalars = 0; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/sparse_commitment.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/sparse_commitment.test.cpp index 7e5eb12f6f6f..4ec17f8807a7 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/sparse_commitment.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/sparse_commitment.test.cpp @@ -54,20 +54,19 @@ template class CommitmentKeyTest : public ::testing::Test { polynomial.at(idx) = Fr::random_element(); } start_idx += fixed_size; - if (non_zero_complement) { // fill complement with random constant value + } + + // If non_zero_complement, populate the space between active regions with a random constant value + if (non_zero_complement) { + for (size_t i = 0; i < active_range_endpoints.size() - 1; ++i) { + const size_t start = active_range_endpoints[i].second; + const size_t end = active_range_endpoints[i + 1].first; Fr const_val = Fr::random_element(); - for (size_t idx = end_idx; idx < start_idx; ++idx) { + for (size_t idx = start; idx < end; ++idx) { polynomial.at(idx) = const_val; } } } - // fill complement region between end of last fixed block and end of polynomial - if (non_zero_complement) { - Fr const_val = polynomial[active_range_endpoints.back().second]; - for (size_t i = active_range_endpoints.back().second; i < polynomial.end_index(); ++i) { - polynomial.at(i) = const_val; - } - } return { polynomial, active_range_endpoints }; } diff --git a/barretenberg/cpp/src/barretenberg/common/zip_view.hpp b/barretenberg/cpp/src/barretenberg/common/zip_view.hpp index 588e0703cd80..802227ad741f 100644 --- a/barretenberg/cpp/src/barretenberg/common/zip_view.hpp +++ b/barretenberg/cpp/src/barretenberg/common/zip_view.hpp @@ -76,6 +76,7 @@ static_assert(__cplusplus >= 201703L, " must be c++17 or greater"); // could be rewritten in c++11, but the features you must use will be buggy // in an older compiler anyways. #include "barretenberg/common/assert.hpp" +#include #include #include #include diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp index 9b113365e1a7..f91fd9bf775f 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp @@ -19,6 +19,7 @@ #include #include #include +#include template <> struct std::hash { std::size_t operator()(const uint256_t& k) const { return k.data[0]; } @@ -729,36 +730,48 @@ void ContentAddressedCachedTreeStore::persist_node(const std::opt uint32_t level, WriteTransaction& tx) { - // If the optional hash does not have a value then it means it's the zero tree value at this level - // If it has a value but that value is not in our stores then it means it is referencing a node - // created in a previous block, so that will need to have it's reference count increased - if (!optional_hash.has_value()) { - return; - } - fr hash = optional_hash.value(); + struct StackObject { + std::optional opHash; + uint32_t lvl; + }; + std::vector stack; + stack.push_back({ .opHash = optional_hash, .lvl = level }); + + while (!stack.empty()) { + StackObject so = stack.back(); + stack.pop_back(); + + // If the optional hash does not have a value then it means it's the zero tree value at this level + // If it has a value but that value is not in our stores then it means it is referencing a node + // created in a previous block, so that will need to have it's reference count increased + if (!so.opHash.has_value()) { + continue; + } + fr hash = so.opHash.value(); - if (level == depth_) { - // this is a leaf - persist_leaf_pre_image(hash, tx); - } + if (so.lvl == depth_) { + // this is a leaf + persist_leaf_pre_image(hash, tx); + } - // std::cout << "Persisting node hash " << hash << " at level " << level << std::endl; + // std::cout << "Persisting node hash " << hash << " at level " << so.lvl << std::endl; + auto nodePayloadIter = nodes_.find(hash); + if (nodePayloadIter == nodes_.end()) { + // need to increase the stored node's reference count here + dataStore_->increment_node_reference_count(hash, tx); + continue; + } - auto nodePayloadIter = nodes_.find(hash); - if (nodePayloadIter == nodes_.end()) { - // need to increase the stored node's reference count here - dataStore_->increment_node_reference_count(hash, tx); - return; - } - NodePayload nodeData = nodePayloadIter->second; - dataStore_->set_or_increment_node_reference_count(hash, nodeData, tx); - if (nodeData.ref != 1) { - // If the node now has a ref count greater then 1, we don't continue. - // It means that the entire sub-tree underneath already exists - return; + NodePayload nodeData = nodePayloadIter->second; + dataStore_->set_or_increment_node_reference_count(hash, nodeData, tx); + if (nodeData.ref != 1) { + // If the node now has a ref count greater then 1, we don't continue. + // It means that the entire sub-tree underneath already exists + continue; + } + stack.push_back({ .opHash = nodePayloadIter->second.left, .lvl = so.lvl + 1 }); + stack.push_back({ .opHash = nodePayloadIter->second.right, .lvl = so.lvl + 1 }); } - persist_node(nodePayloadIter->second.left, level + 1, tx); - persist_node(nodePayloadIter->second.right, level + 1, tx); } template @@ -1048,29 +1061,38 @@ void ContentAddressedCachedTreeStore::remove_node(const std::opti std::optional maxIndex, WriteTransaction& tx) { - if (!optional_hash.has_value()) { - return; - } - fr hash = optional_hash.value(); - - // we need to retrieve the node and decrement it's reference count - // std::cout << "Decrementing ref count for node " << hash << ", level " << level << std::endl; - NodePayload nodeData; - dataStore_->decrement_node_reference_count(hash, nodeData, tx); - - if (nodeData.ref != 0) { - // node was not deleted, we don't continue the search - return; - } - - // the node was deleted, if it was a leaf then we need to remove the pre-image - if (level == depth_) { - remove_leaf(hash, maxIndex, tx); + struct StackObject { + std::optional opHash; + uint32_t lvl; + }; + std::vector stack; + stack.push_back({ .opHash = optional_hash, .lvl = level }); + + while (!stack.empty()) { + StackObject so = stack.back(); + stack.pop_back(); + + if (!so.opHash.has_value()) { + continue; + } + fr hash = so.opHash.value(); + // we need to retrieve the node and decrement it's reference count + // std::cout << "Decrementing ref count for node " << hash << ", level " << so.lvl << std::endl; + NodePayload nodeData; + dataStore_->decrement_node_reference_count(hash, nodeData, tx); + + if (nodeData.ref != 0) { + // node was not deleted, we don't continue the search + continue; + } + // the node was deleted, if it was a leaf then we need to remove the pre-image + if (so.lvl == depth_) { + remove_leaf(hash, maxIndex, tx); + } + // push the child nodes to the stack + stack.push_back({ .opHash = std::optional(nodeData.left), .lvl = so.lvl + 1 }); + stack.push_back({ .opHash = std::optional(nodeData.right), .lvl = so.lvl + 1 }); } - - // now recursively remove the next level - remove_node(std::optional(nodeData.left), level + 1, maxIndex, tx); - remove_node(std::optional(nodeData.right), level + 1, maxIndex, tx); } template void ContentAddressedCachedTreeStore::initialise() diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index bd36912f2f18..d0eb9d767d6b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -1,6 +1,7 @@ #include "acir_format.hpp" #include "barretenberg/common/log.hpp" #include "barretenberg/common/throw_or_abort.hpp" +#include "barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp" #include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" #include "barretenberg/stdlib/primitives/field/field_conversion.hpp" #include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp" @@ -490,6 +491,17 @@ MegaCircuitBuilder create_kernel_circuit(AcirFormat& constraint_system, ASSERT(false); } + // If no witness is provided, populate the VK and public inputs in the recursion constraint with dummy values so + // that the present kernel circuit is constructed correctly. (Used for constructing VKs without witnesses). + if (witness.empty()) { + // Create stdlib representations of each {proof, vkey} pair to be recursively verified + for (auto [constraint, queue_entry] : + zip_view(constraint_system.ivc_recursion_constraints, ivc.verification_queue)) { + + populate_dummy_vk_in_constraint(circuit, queue_entry.honk_verification_key, constraint.key); + } + } + // Construct a stdlib verification key for each constraint based on the verification key witness indices therein std::vector> stdlib_verification_keys; stdlib_verification_keys.reserve(constraint_system.ivc_recursion_constraints.size()); @@ -497,7 +509,6 @@ MegaCircuitBuilder create_kernel_circuit(AcirFormat& constraint_system, stdlib_verification_keys.push_back(std::make_shared( StdlibVerificationKey::from_witness_indices(circuit, constraint.key))); } - // Create stdlib representations of each {proof, vkey} pair to be recursively verified ivc.instantiate_stdlib_verification_queue(circuit, stdlib_verification_keys); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.cpp new file mode 100644 index 000000000000..4100773a4868 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.cpp @@ -0,0 +1,165 @@ +#include "ivc_recursion_constraint.hpp" +#include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/plonk_honk_shared/types/aggregation_object_type.hpp" +#include "barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp" +#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" +#include "barretenberg/stdlib/primitives/curves/bn254.hpp" +#include "barretenberg/stdlib_circuit_builders/ultra_recursive_flavor.hpp" +#include "proof_surgeon.hpp" +#include "recursion_constraint.hpp" + +namespace acir_format { + +using namespace bb; +using field_ct = stdlib::field_t; + +ClientIVC create_mock_ivc_from_constraints(const std::vector& constraints) +{ + ClientIVC ivc; + ivc.trace_settings.structure = TraceStructure::SMALL_TEST; + + for (const auto& constraint : constraints) { + if (static_cast(PROOF_TYPE::OINK) == constraint.proof_type) { + mock_ivc_oink_accumulation(ivc, constraint.public_inputs.size()); + } else if (static_cast(PROOF_TYPE::PG) == constraint.proof_type) { + // perform equivalent mocking for PG accumulation + } + } + + return ivc; +} + +/** + * @brief Populate an IVC instance with data that mimics the state after accumulating the first app (which runs the oink + * prover) + *@details Mock state consists a mock verification queue entry of type OINK (proof, VK) and a mocked merge proof + * + * @param ivc + * @param num_public_inputs_app num pub inputs in accumulated app, excluding fixed components, e.g. pairing points + */ +void mock_ivc_oink_accumulation(ClientIVC& ivc, size_t num_public_inputs_app) +{ + ClientIVC::VerifierInputs oink_entry = + acir_format::create_dummy_vkey_and_proof_oink(ivc.trace_settings, num_public_inputs_app); + ivc.verification_queue.emplace_back(oink_entry); + ivc.merge_verification_queue.emplace_back(acir_format::create_dummy_merge_proof()); + ivc.initialized = true; +} + +/** + * @brief Create a mock oink proof and VK that have the correct structure but are not necessarily valid + * + */ +ClientIVC::VerifierInputs create_dummy_vkey_and_proof_oink(const TraceSettings& trace_settings, + const size_t num_public_inputs = 0) +{ + using Flavor = MegaFlavor; + using VerificationKey = ClientIVC::VerificationKey; + using FF = bb::fr; + + MegaArith::TraceBlocks blocks; + blocks.set_fixed_block_sizes(trace_settings); + blocks.compute_offsets(/*is_structured=*/true); + size_t structured_dyadic_size = blocks.get_structured_dyadic_size(); + size_t pub_inputs_offset = blocks.pub_inputs.trace_offset; + + ClientIVC::VerifierInputs verifier_inputs; + verifier_inputs.type = ClientIVC::QUEUE_TYPE::OINK; + + FF mock_val(5); + + auto mock_commitment = curve::BN254::AffineElement::one() * mock_val; + std::vector mock_commitment_frs = field_conversion::convert_to_bn254_frs(mock_commitment); + + // Set proof preamble (metadata plus public inputs) + size_t total_num_public_inputs = num_public_inputs + bb::PAIRING_POINT_ACCUMULATOR_SIZE; + verifier_inputs.proof.emplace_back(structured_dyadic_size); + verifier_inputs.proof.emplace_back(total_num_public_inputs); + verifier_inputs.proof.emplace_back(pub_inputs_offset); + for (size_t i = 0; i < total_num_public_inputs; ++i) { + verifier_inputs.proof.emplace_back(0); + } + + // Witness polynomial commitments + for (size_t i = 0; i < Flavor::NUM_WITNESS_ENTITIES; ++i) { + for (const FF& val : mock_commitment_frs) { + verifier_inputs.proof.emplace_back(val); + } + } + + // Set relevant VK metadata and commitments + verifier_inputs.honk_verification_key = std::make_shared(); + verifier_inputs.honk_verification_key->circuit_size = structured_dyadic_size; + verifier_inputs.honk_verification_key->num_public_inputs = total_num_public_inputs; + verifier_inputs.honk_verification_key->pub_inputs_offset = blocks.pub_inputs.trace_offset; // must be set correctly + verifier_inputs.honk_verification_key->contains_pairing_point_accumulator = true; + for (auto& commitment : verifier_inputs.honk_verification_key->get_all()) { + commitment = mock_commitment; + } + + return verifier_inputs; +} + +/** + * @brief Create a mock merge proof which has the correct structure but is not necessarily valid + * + * @return ClientIVC::MergeProof + */ +ClientIVC::MergeProof create_dummy_merge_proof() +{ + using FF = bb::fr; + + std::vector proof; + + FF mock_val(5); + auto mock_commitment = curve::BN254::AffineElement::one() * mock_val; + std::vector mock_commitment_frs = field_conversion::convert_to_bn254_frs(mock_commitment); + + // There are 12 entities in the merge protocol (4 columns x 3 components; aggregate transcript, previous aggregate + // transcript, current transcript contribution) + const size_t NUM_TRANSCRIPT_ENTITIES = 12; + + // Transcript poly commitments + for (size_t i = 0; i < NUM_TRANSCRIPT_ENTITIES; ++i) { + for (const FF& val : mock_commitment_frs) { + proof.emplace_back(val); + } + } + // Transcript poly evaluations + for (size_t i = 0; i < NUM_TRANSCRIPT_ENTITIES; ++i) { + proof.emplace_back(mock_val); + } + // Batched KZG quotient commitment + for (const FF& val : mock_commitment_frs) { + proof.emplace_back(val); + } + + return proof; +} + +/** + * @brief Populate VK witness fields from a recursion constraint from a provided VerificationKey + * + * @param builder + * @param mock_verification_key + * @param key_witness_indices + */ +void populate_dummy_vk_in_constraint(MegaCircuitBuilder& builder, + const std::shared_ptr& mock_verification_key, + std::vector& key_witness_indices) +{ + using Flavor = MegaFlavor; + using FF = Flavor::FF; + + // Convert the VerificationKey to fields + std::vector mock_vk_fields = mock_verification_key->to_field_elements(); + ASSERT(mock_vk_fields.size() == key_witness_indices.size()); + + // Add the fields to the witness and set the key witness indices accordingly + for (auto [witness_idx, value] : zip_view(key_witness_indices, mock_vk_fields)) { + witness_idx = builder.add_variable(value); + } +} + +} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp new file mode 100644 index 000000000000..5ab74ca80e6c --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp @@ -0,0 +1,27 @@ +#pragma once +#include "barretenberg/client_ivc/client_ivc.hpp" +#include "barretenberg/dsl/acir_format/recursion_constraint.hpp" +#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" +#include + +namespace acir_format { + +using namespace bb; + +// TODO(https://github.com/AztecProtocol/barretenberg/issues/1148): logic in this file is incomplete. See issue for +// details. + +ClientIVC create_mock_ivc_from_constraints(const std::vector& constraints); + +void mock_ivc_oink_accumulation(ClientIVC& ivc, size_t num_public_inputs_app = 0); + +ClientIVC::VerifierInputs create_dummy_vkey_and_proof_oink(const TraceSettings& trace_settings, + const size_t num_public_inputs); + +ClientIVC::MergeProof create_dummy_merge_proof(); + +void populate_dummy_vk_in_constraint(MegaCircuitBuilder& builder, + const std::shared_ptr& mock_verification_key, + std::vector& key_witness_indices); + +} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.test.cpp index 285106061beb..50da7e166b5d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ivc_recursion_constraint.test.cpp @@ -1,3 +1,4 @@ +#include "barretenberg/dsl/acir_format/ivc_recursion_constraint.hpp" #include "acir_format.hpp" #include "acir_format_mocks.hpp" #include "barretenberg/client_ivc/client_ivc.hpp" @@ -75,39 +76,11 @@ class IvcRecursionConstraintTest : public ::testing::Test { }; } - /** - * @brief Create an arithmetic constraint fixing the first public input witness to it's present value - * @details Meant to mimic the "business logic" of the aztec kernel. Used to facilitate failure testing since this - * will lead to failure of the kernel circuit to verify if a different proof witness is used in the business logic - * VS the recursive verification logic. - * - * @param public_inputs Witness indices of public inputs of some proof to be constrained - * @param witness - * @return ArithmeticConstraint - */ - static ArithmeticConstraint create_public_input_value_constraint(const std::vector& public_inputs, - const SlabVector& witness) - { - const uint32_t pub_input_idx = public_inputs[0]; - const FF pub_input_val = witness[pub_input_idx]; - return { - .a = pub_input_idx, - .b = 0, - .c = 0, - .q_m = 0, - .q_l = -1, - .q_r = 0, - .q_o = 0, - .q_c = pub_input_val, - }; - } - /** * @brief Generate an acir program {constraints, witness} for a mock kernel * @details The IVC contains and internal verification queue that contains proofs to be recursively verified. * Construct an AcirProgram with a RecursionConstraint for each entry in the ivc verification queue. (In practice - * these constraints would come directly from calls to verify_proof in noir). Also add mock "business logic" which - * simply enforces some constraint on the public inputs of the proof. + * these constraints would come directly from calls to verify_proof in noir). * @note This method needs the number of public inputs in each proof-to-be-verified so they can be extracted and * provided separately as is required in the acir constraint system. * @@ -130,14 +103,9 @@ class IvcRecursionConstraintTest : public ::testing::Test { verification_queue[idx], program.witness, inner_circuit_num_pub_inputs[idx])); } - // Add some mock kernel "business logic" which simply fixes one of the public inputs to a particular value - ArithmeticConstraint pub_input_constraint = - create_public_input_value_constraint(ivc_recursion_constraints[0].public_inputs, program.witness); - // Construct a constraint system containing the business logic and ivc recursion constraints program.constraints.varnum = static_cast(program.witness.size()); program.constraints.num_acir_opcodes = static_cast(ivc_recursion_constraints.size()); - program.constraints.poly_triple_constraints = { pub_input_constraint }; program.constraints.ivc_recursion_constraints = ivc_recursion_constraints; program.constraints.original_opcode_indices = create_empty_original_opcode_indices(); mock_opcode_indices(program.constraints); @@ -214,64 +182,110 @@ TEST_F(IvcRecursionConstraintTest, AccumulateFour) EXPECT_TRUE(ivc.prove_and_verify()); } -/** - * @brief Demonstrate failure of the IVC if the proof witness differs between those encoded in the constraint system - * (i.e. those used in the noir program) and those used in constructing the recursive verifiers internally - * @brief The idea is to construct two valid but unique verification queue entries of the form {proof, vkey}. One is - * used to construct the acir constraint system and the other is used to construct the recursive verification logic - * internally in the IVC. Since the proof/vkey witnesses in the constraint system are asserted equal to those used to - * construct the recursive verifiers, the use of different verification queue witnesses should result in failure as long - * as they were used in some nontrivial way in the main logic of the kernel. (Specifically, failure results from a - * failure of the "business logic" of the kernel which constrains one of the public inputs to a particular value). - */ -TEST_F(IvcRecursionConstraintTest, AccumulateTwoFailure) +// Test generation of "init" kernel VK via dummy IVC data +TEST_F(IvcRecursionConstraintTest, GenerateVK) { - // Accumulate a single app in order to construct a valid verification queue entry {proof, vkey} to be used later on. - // Demonstrate that it is indeed valid by completing the IVC with a kernel (which recursively verifies the entry) - // then proving and verifying the full IVC. - VerifierInputs alternative_verification_queue_entry; + const TraceSettings trace_settings{ TraceStructure::SMALL_TEST }; + + // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) + std::shared_ptr expected_kernel_vk; + size_t num_app_public_inputs = 0; { ClientIVC ivc; - ivc.trace_settings.structure = TraceStructure::SMALL_TEST; + ivc.trace_settings = trace_settings; - // construct and accumulate a mock app circuit with a single unique public input + // Construct and accumulate mock app_circuit Builder app_circuit = construct_mock_app_circuit(ivc); ivc.accumulate(app_circuit); + num_app_public_inputs = app_circuit.public_inputs.size(); - // Save the single entry in the verification queue at this point - alternative_verification_queue_entry = ivc.verification_queue[0]; + // Construct and accumulate kernel consisting only of the kernel completion logic + AcirProgram program = construct_mock_kernel_program(ivc.verification_queue, { num_app_public_inputs }); + Builder kernel = acir_format::create_kernel_circuit(program.constraints, ivc, program.witness); + ivc.accumulate(kernel); + expected_kernel_vk = ivc.verification_queue.back().honk_verification_key; + } + + // Now, construct the kernel VK by mocking the post app accumulation state of the IVC + std::shared_ptr kernel_vk; + { + ClientIVC ivc; + ivc.trace_settings = trace_settings; + + acir_format::mock_ivc_oink_accumulation(ivc, num_app_public_inputs - bb::PAIRING_POINT_ACCUMULATOR_SIZE); - // Construct and accumulate kernel_0 - size_t num_pub_inputs_app = app_circuit.public_inputs.size(); - AcirProgram program_0 = construct_mock_kernel_program(ivc.verification_queue, { num_pub_inputs_app }); - Builder kernel_0 = acir_format::create_kernel_circuit(program_0.constraints, ivc, program_0.witness); - ivc.accumulate(kernel_0); + // Construct kernel consisting only of the kernel completion logic + AcirProgram program = construct_mock_kernel_program(ivc.verification_queue, { num_app_public_inputs }); + Builder kernel = acir_format::create_kernel_circuit(program.constraints, ivc); + // WORKTODO: this would normally happen in accumulate() + kernel.add_pairing_point_accumulator(stdlib::recursion::init_default_agg_obj_indices(kernel)); - EXPECT_TRUE(ivc.prove_and_verify()); + auto proving_key = std::make_shared>(kernel, trace_settings); + MegaProver prover(proving_key); + kernel_vk = std::make_shared(prover.proving_key->proving_key); } - // Repeat a similar IVC but use the alternative queue entry just created to provide different (but independently - // valid) witnesses during constraint system construction VS recursive verifier construction. + // PCS verification keys will not match so set to null before comparing + kernel_vk->pcs_verification_key = nullptr; + expected_kernel_vk->pcs_verification_key = nullptr; - ClientIVC ivc; - ivc.trace_settings.structure = TraceStructure::SMALL_TEST; + EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); +} - // construct and accumulate a mock app circuit with a single unique public input - Builder app_circuit = construct_mock_app_circuit(ivc); - ivc.accumulate(app_circuit); +// Test generation of "init" kernel VK via dummy IVC data +TEST_F(IvcRecursionConstraintTest, GenerateVKFromConstraints) +{ + const TraceSettings trace_settings{ TraceStructure::SMALL_TEST }; - // Construct kernel_0 - AcirProgram program_0 = construct_mock_kernel_program(ivc.verification_queue, { app_circuit.public_inputs.size() }); + // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) + std::shared_ptr expected_kernel_vk; + size_t num_app_public_inputs = 0; + { + ClientIVC ivc; + ivc.trace_settings = trace_settings; - // Replace the existing verification queue entry that was used to construct the acir constraint system for the - // kernel with a different (but valid, as shown above) set of inputs - ivc.verification_queue[0] = alternative_verification_queue_entry; - Builder kernel_0 = acir_format::create_kernel_circuit(program_0.constraints, ivc, program_0.witness); + // Construct and accumulate mock app_circuit + Builder app_circuit = construct_mock_app_circuit(ivc); + ivc.accumulate(app_circuit); + num_app_public_inputs = app_circuit.public_inputs.size(); - // The witness should fail to check due to the business logic of the kernel failing - EXPECT_FALSE(CircuitChecker::check(kernel_0)); - ivc.accumulate(kernel_0); + // Construct and accumulate kernel consisting only of the kernel completion logic + AcirProgram program = construct_mock_kernel_program(ivc.verification_queue, { num_app_public_inputs }); + Builder kernel = acir_format::create_kernel_circuit(program.constraints, ivc, program.witness); - // The full IVC should of course also fail to verify since we've accumulated an invalid witness for the kernel - EXPECT_FALSE(ivc.prove_and_verify()); -} + ivc.accumulate(kernel); + expected_kernel_vk = ivc.verification_queue.back().honk_verification_key; + } + + // Now, construct the kernel VK by mocking the post app accumulation state of the IVC + std::shared_ptr kernel_vk; + { + ClientIVC ivc; + ivc.trace_settings = trace_settings; + + // Construct kernel consisting only of the kernel completion logic + acir_format::mock_ivc_oink_accumulation(ivc, num_app_public_inputs - bb::PAIRING_POINT_ACCUMULATOR_SIZE); + AcirProgram program = construct_mock_kernel_program(ivc.verification_queue, { num_app_public_inputs }); + program.witness = {}; // erase witness to mimic VK construction context + + // Create a mock IVC instance from the IVC recursion constraints in the kernel program + ClientIVC mock_ivc = create_mock_ivc_from_constraints(program.constraints.ivc_recursion_constraints); + + // Create a kernel circuit from the kernel program and the mocked IVC + Builder kernel = acir_format::create_kernel_circuit(program.constraints, mock_ivc); + // Note: adding pairing point normally happens in accumulate() + kernel.add_pairing_point_accumulator(stdlib::recursion::init_default_agg_obj_indices(kernel)); + + // Manually construct the VK for the kernel circuit + auto proving_key = std::make_shared>(kernel, ivc.trace_settings); + MegaProver prover(proving_key); + kernel_vk = std::make_shared(prover.proving_key->proving_key); + } + + // PCS verification keys will not match so set to null before comparing + kernel_vk->pcs_verification_key = nullptr; + expected_kernel_vk->pcs_verification_key = nullptr; + + // Compare the VK constructed via running the IVc with the one constructed via mocking + EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/proof_surgeon.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/proof_surgeon.hpp index 224d344ae8a8..0b2d1768bcaf 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/proof_surgeon.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/proof_surgeon.hpp @@ -149,6 +149,7 @@ class ProofSurgeon { const size_t num_public_inputs) { // Extract all public inputs except for those corresponding to the aggregation object + ASSERT(num_public_inputs >= bb::PAIRING_POINT_ACCUMULATOR_SIZE); const size_t num_public_inputs_to_extract = num_public_inputs - bb::PAIRING_POINT_ACCUMULATOR_SIZE; std::vector public_input_witnesses = cut_public_inputs_from_proof(proof_witnesses, num_public_inputs_to_extract); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 2af498e35857..5fbd1af77c94 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -11,6 +11,7 @@ #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/serialize/msgpack.hpp" #include "barretenberg/srs/global_crs.hpp" +#include "honk_contract.hpp" #include #include @@ -320,6 +321,23 @@ WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* r *out = to_heap_buffer(to_buffer(vk)); } +WASM_EXPORT void get_honk_solidity_verifier_vk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out) +{ + using DeciderProvingKey = DeciderProvingKey_; + using VerificationKey = UltraFlavor::VerificationKey; + + auto constraint_system = + acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), /*honk_recursion=*/true); + auto builder = + acir_format::create_circuit(constraint_system, *recursive, 0, {}, /*honk_recursion=*/true); + + DeciderProvingKey proving_key(builder); + VerificationKey vk(proving_key.proving_key); + + auto str = get_honk_solidity_verifier(&vk); + *out = to_heap_buffer(str); +} + WASM_EXPORT void acir_proof_as_fields_ultra_honk(uint8_t const* proof_buf, fr::vec_out_buf out) { auto proof = from_buffer>(from_buffer>(proof_buf)); @@ -342,4 +360,4 @@ WASM_EXPORT void acir_vk_as_fields_mega_honk(uint8_t const* vk_buf, fr::vec_out_ auto verification_key = std::make_shared(from_buffer(vk_buf)); std::vector vkey_as_fields = verification_key->to_field_elements(); *out_vkey = to_heap_buffer(vkey_as_fields); -} \ No newline at end of file +} diff --git a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp index 38b20b9891b3..77b311656706 100644 --- a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.cpp @@ -45,7 +45,7 @@ void ExecutionTrace_::populate(Builder& builder, typename Flavor::Provin add_memory_records_to_proving_key(trace_data, builder, proving_key); } - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { PROFILE_THIS_NAME("add_ecc_op_wires_to_proving_key"); @@ -100,7 +100,9 @@ typename ExecutionTrace_::TraceData ExecutionTrace_::construct_t // Save ranges over which the blocks are "active" for use in structured commitments if constexpr (IsHonkFlavor) { - proving_key.active_block_ranges.emplace_back(offset, offset + block.size()); + if (block.size() > 0) { + proving_key.active_block_ranges.emplace_back(offset, offset + block.size()); + } } // Update wire polynomials and copy cycles @@ -151,7 +153,7 @@ typename ExecutionTrace_::TraceData ExecutionTrace_::construct_t template void ExecutionTrace_::add_ecc_op_wires_to_proving_key(Builder& builder, typename Flavor::ProvingKey& proving_key) - requires IsGoblinFlavor + requires IsMegaFlavor { auto& ecc_op_selector = proving_key.polynomials.lagrange_ecc_op; const size_t op_wire_offset = Flavor::has_zero_row ? 1 : 0; diff --git a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.hpp b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.hpp index 2f107a3444d7..6092e0f5cc7d 100644 --- a/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/execution_trace/execution_trace.hpp @@ -125,7 +125,7 @@ template class ExecutionTrace_ { * @param proving_key */ static void add_ecc_op_wires_to_proving_key(Builder& builder, typename Flavor::ProvingKey& proving_key) - requires IsGoblinFlavor; + requires IsMegaFlavor; }; } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index b59338873cbe..a354e03235f0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -123,7 +123,7 @@ template class ProvingKey_ { // folded element by element. std::vector public_inputs; - // Ranges over which the execution trace is "active" + // Ranges of the form [start, end) over which the execution trace is "active" std::vector> active_block_ranges; ProvingKey_() = default; @@ -369,7 +369,7 @@ template concept IsUltraFlavor = IsAnyOf; template -concept IsGoblinFlavor = IsAnyOf, MegaRecursiveFlavor_, MegaRecursiveFlavor_, @@ -377,7 +377,7 @@ MegaZKRecursiveFlavor_, MegaZKRecursiveFlavor_>; template -concept HasDataBus = IsGoblinFlavor; +concept HasDataBus = IsMegaFlavor; template concept IsRecursiveFlavor = IsAnyOf, diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index 5cc245ee9859..bbe394315ad7 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -180,7 +180,7 @@ void compute_translator_range_constraint_ordered_polynomials(typename Flavor::Pr #ifdef NO_PAR_ALGOS std::sort(extra_denominator_uint.begin(), extra_denominator_uint.end()); #else - std::sort(std::execution::par_unseq, extra_denominator_uint.begin(), extra_denominator.end()); + std::sort(std::execution::par_unseq, extra_denominator_uint.begin(), extra_denominator_uint.end()); #endif // Copy the values into the actual polynomial diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp index 90fb89c785dc..e535e58acda8 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.hpp @@ -2,6 +2,7 @@ #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" +#include namespace bb::plonk { struct SelectorProperties { diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/execution_trace_usage_tracker.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/execution_trace_usage_tracker.hpp index 53db481ff599..f1798fa3c76d 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/execution_trace_usage_tracker.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/execution_trace_usage_tracker.hpp @@ -67,7 +67,7 @@ struct ExecutionTraceUsageTracker { // The active ranges for the databus and lookup relations (both based on log-deriv lookup argument) must // incorporate both the lookup/read gate blocks as well as the rows containing the data that is being read. // Update the corresponding ranges accordingly. (Note: tables are constructed at the 'bottom' of the trace). - size_t dyadic_circuit_size = circuit.get_circuit_subgroup_size(fixed_sizes.get_total_structured_size()); + size_t dyadic_circuit_size = fixed_sizes.get_structured_dyadic_size(); active_ranges.busread.first = 0; // databus data is stored at the top of the trace active_ranges.busread.second = std::max(max_databus_size, active_ranges.busread.second); active_ranges.lookup.first = std::min(dyadic_circuit_size - max_tables_size, active_ranges.lookup.first); diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/mega_arithmetization.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/mega_arithmetization.hpp index 7cb03ae310ab..8a19c73cc438 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/mega_arithmetization.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/mega_arithmetization.hpp @@ -3,6 +3,7 @@ #include "barretenberg/common/ref_vector.hpp" #include "barretenberg/common/zip_view.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp" #include "barretenberg/plonk_honk_shared/types/circuit_type.hpp" @@ -309,13 +310,18 @@ template class MegaArith { info(""); } - size_t get_total_structured_size() + size_t get_structured_dyadic_size() { - size_t total_size = 0; + size_t total_size = 1; // start at 1 because the 0th row is unused for selectors for Honk for (auto block : this->get()) { total_size += block.get_fixed_size(); } - return total_size; + + auto log2_n = static_cast(numeric::get_msb(total_size)); + if ((1UL << log2_n) != (total_size)) { + ++log2_n; + } + return 1UL << log2_n; } bool operator==(const TraceBlocks& other) const = default; diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/ultra_arithmetization.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/ultra_arithmetization.hpp index a188d2faef59..d4443a11dbd1 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/ultra_arithmetization.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/ultra_arithmetization.hpp @@ -1,6 +1,7 @@ #pragma once #include "barretenberg/common/ref_vector.hpp" +#include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp" namespace bb { @@ -167,13 +168,18 @@ template class UltraArith { info("overflow :\t", this->overflow.size()); } - size_t get_total_structured_size() + size_t get_structured_dyadic_size() { size_t total_size = 1; // start at 1 because the 0th row is unused for selectors for Honk for (auto block : this->get()) { total_size += block.get_fixed_size(); } - return total_size; + + auto log2_n = static_cast(numeric::get_msb(total_size)); + if ((1UL << log2_n) != (total_size)) { + ++log2_n; + } + return 1UL << log2_n; } bool operator==(const TraceBlocks& other) const = default; diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp index bf2859365d05..58b1d35630a5 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp @@ -13,7 +13,7 @@ namespace bb { // product. Update comments accordingly. /** * @brief Compute a permutation grand product polynomial Z_perm(X) - * * + * * @details * Z_perm may be defined in terms of its values on X_i = 0,1,...,n-1 as Z_perm[0] = 1 and for i = 1:n-1 * relation::numerator(j) @@ -46,31 +46,52 @@ namespace bb { * Step 3) Compute Z_perm[i + 1] = numerator[i] / denominator[i] (recall: Z_perm[0] = 1) * * Note: Step (3) utilizes Montgomery batch inversion to replace n-many inversions with + * + * @tparam Flavor + * @tparam GrandProdRelation + * @param full_polynomials + * @param relation_parameters + * @param size_override optional size of the domain; otherwise based on dyadic polynomial domain */ template void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, - bb::RelationParameters& relation_parameters) + bb::RelationParameters& relation_parameters, + size_t size_override = 0) { using FF = typename Flavor::FF; using Polynomial = typename Flavor::Polynomial; using Accumulator = std::tuple_element_t<0, typename GrandProdRelation::SumcheckArrayOfValuesOverSubrelations>; + // Set the domain over which the grand product must be computed. This may be less than the dyadic circuit size, e.g + // the permutation grand product does not need to be computed beyond the index of the last active wire + size_t domain_size = size_override == 0 ? full_polynomials.get_polynomial_size() : size_override; + + const size_t num_threads = domain_size >= get_num_cpus_pow2() ? get_num_cpus_pow2() : 1; + const size_t block_size = domain_size / num_threads; + const size_t final_idx = domain_size - 1; + + // Cumpute the index bounds for each thread for reuse in the computations below + std::vector> idx_bounds; + idx_bounds.reserve(num_threads); + for (size_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) { + const size_t start = thread_idx * block_size; + const size_t end = (thread_idx == num_threads - 1) ? final_idx : (thread_idx + 1) * block_size; + idx_bounds.push_back(std::make_pair(start, end)); + } + // Allocate numerator/denominator polynomials that will serve as scratch space // TODO(zac) we can re-use the permutation polynomial as the numerator polynomial. Reduces readability - size_t circuit_size = full_polynomials.get_polynomial_size(); - Polynomial numerator{ circuit_size, circuit_size }; - Polynomial denominator{ circuit_size, circuit_size }; + Polynomial numerator{ domain_size, domain_size }; + Polynomial denominator{ domain_size, domain_size }; // Step (1) // Populate `numerator` and `denominator` with the algebra described by Relation - const size_t num_threads = circuit_size >= get_num_cpus_pow2() ? get_num_cpus_pow2() : 1; - const size_t block_size = circuit_size / num_threads; parallel_for(num_threads, [&](size_t thread_idx) { - const size_t start = thread_idx * block_size; - const size_t end = (thread_idx + 1) * block_size; typename Flavor::AllValues evaluations; // TODO(https://github.com/AztecProtocol/barretenberg/issues/940): construction of evaluations is equivalent to // calling get_row which creates full copies. avoid? + const size_t start = idx_bounds[thread_idx].first; + const size_t end = idx_bounds[thread_idx].second; for (size_t i = start; i < end; ++i) { for (auto [eval, full_poly] : zip_view(evaluations.get_all(), full_polynomials.get_all())) { eval = full_poly.size() > i ? full_poly[i] : 0; @@ -101,8 +122,8 @@ void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, std::vector partial_denominators(num_threads); parallel_for(num_threads, [&](size_t thread_idx) { - const size_t start = thread_idx * block_size; - const size_t end = (thread_idx + 1) * block_size; + const size_t start = idx_bounds[thread_idx].first; + const size_t end = idx_bounds[thread_idx].second; for (size_t i = start; i < end - 1; ++i) { numerator.at(i + 1) *= numerator[i]; denominator.at(i + 1) *= denominator[i]; @@ -115,8 +136,8 @@ void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, DEBUG_LOG_ALL(partial_denominators); parallel_for(num_threads, [&](size_t thread_idx) { - const size_t start = thread_idx * block_size; - const size_t end = (thread_idx + 1) * block_size; + const size_t start = idx_bounds[thread_idx].first; + const size_t end = idx_bounds[thread_idx].second; if (thread_idx > 0) { FF numerator_scaling = 1; FF denominator_scaling = 1; @@ -132,7 +153,7 @@ void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, } // Final step: invert denominator - FF::batch_invert(std::span{ &denominator.data()[start], block_size }); + FF::batch_invert(std::span{ &denominator.data()[start], end - start }); }); DEBUG_LOG_ALL(numerator.coeffs()); @@ -143,8 +164,8 @@ void compute_grand_product(typename Flavor::ProverPolynomials& full_polynomials, // We have a 'virtual' 0 at the start (as this is a to-be-shifted polynomial) ASSERT(grand_product_polynomial.start_index() == 1); parallel_for(num_threads, [&](size_t thread_idx) { - const size_t start = thread_idx * block_size; - const size_t end = (thread_idx == num_threads - 1) ? circuit_size - 1 : (thread_idx + 1) * block_size; + const size_t start = idx_bounds[thread_idx].first; + const size_t end = idx_bounds[thread_idx].second; for (size_t i = start; i < end; ++i) { grand_product_polynomial.at(i + 1) = numerator[i] * denominator[i]; } diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp index 4db7309a7da3..a765b439daf7 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp @@ -48,7 +48,7 @@ template class ProtogalaxyTests : public testing::Test { static void construct_circuit(Builder& builder) { MockCircuits::add_arithmetic_gates(builder); - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { GoblinMockCircuits::add_some_ecc_op_gates(builder); } } @@ -143,7 +143,8 @@ template class ProtogalaxyTests : public testing::Test { decider_pk->relation_parameters.eta_two, decider_pk->relation_parameters.eta_three); decider_pk->proving_key.compute_logderivative_inverses(decider_pk->relation_parameters); - decider_pk->proving_key.compute_grand_product_polynomials(decider_pk->relation_parameters); + decider_pk->proving_key.compute_grand_product_polynomial(decider_pk->relation_parameters, + decider_pk->final_active_wire_idx + 1); for (auto& alpha : decider_pk->alphas) { alpha = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/oink_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/oink_recursive_verifier.cpp index 8c79fa753f05..6e09db90b524 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/oink_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/oink_recursive_verifier.cpp @@ -68,7 +68,7 @@ template void OinkRecursiveVerifier_::verify() commitments.w_o = transcript->template receive_from_prover(domain_separator + labels.w_o); // If Goblin, get commitments to ECC op wire polynomials and DataBus columns - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { // Receive ECC op wire commitments for (auto [commitment, label] : zip_view(commitments.get_ecc_op_wires(), labels.get_ecc_op_wires())) { commitment = transcript->template receive_from_prover(domain_separator + label); @@ -98,7 +98,7 @@ template void OinkRecursiveVerifier_::verify() transcript->template receive_from_prover(domain_separator + labels.lookup_inverses); // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomials - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { for (auto [commitment, label] : zip_view(commitments.get_databus_inverses(), labels.get_databus_inverses())) { commitment = transcript->template receive_from_prover(domain_separator + label); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/recursive_decider_verification_key.hpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/recursive_decider_verification_key.hpp index 95833c465d14..e11674a2c827 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/recursive_decider_verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/recursive_decider_verification_key.hpp @@ -109,7 +109,7 @@ template class RecursiveDeciderVerificationKey_ { native_honk_vk->contains_pairing_point_accumulator = verification_key->contains_pairing_point_accumulator; native_honk_vk->pairing_point_accumulator_public_input_indices = verification_key->pairing_point_accumulator_public_input_indices; - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { native_honk_vk->databus_propagation_data = verification_key->databus_propagation_data; } diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/grand_product_library.test.cpp index 791242f61f41..f03d59be6647 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/grand_product_library.test.cpp @@ -60,14 +60,7 @@ template class GrandProductTests : public testing::Test { .lookup_grand_product_delta = 1, }; - // Method 1: Compute z_perm using 'compute_grand_product_polynomial' as the prover would in practice - constexpr size_t PERMUTATION_RELATION_INDEX = 0; - using LHS = - typename std::tuple_element::type; - ASSERT(Flavor::NUM_WIRES == 4); - using RHS = typename bb::UltraPermutationRelation; - static_assert(std::same_as); - compute_grand_product(prover_polynomials, params); + compute_grand_product>(prover_polynomials, params); // Method 2: Compute z_perm locally using the simplest non-optimized syntax possible. The comment below, // which describes the computation in 4 steps, is adapted from a similar comment in diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp index 13f6e3cbe85f..095840dc85d1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_flavor.hpp @@ -51,8 +51,6 @@ class MegaFlavor { // Total number of folded polynomials, which is just all polynomials except the shifts static constexpr size_t NUM_FOLDED_ENTITIES = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; - using GrandProductRelations = std::tuple>; - // define the tuple of Relations that comprise the Sumcheck relation // Note: made generic for use in MegaRecursive. template @@ -497,18 +495,19 @@ class MegaFlavor { * @brief Computes public_input_delta and the permutation grand product polynomial * * @param relation_parameters + * @param size_override override the size of the domain over which to compute the grand product */ - void compute_grand_product_polynomials(RelationParameters& relation_parameters) + void compute_grand_product_polynomial(RelationParameters& relation_parameters, size_t size_override = 0) { - auto public_input_delta = compute_public_input_delta(this->public_inputs, - relation_parameters.beta, - relation_parameters.gamma, - this->circuit_size, - this->pub_inputs_offset); - relation_parameters.public_input_delta = public_input_delta; - - // Compute permutation and lookup grand product polynomials - compute_grand_products(this->polynomials, relation_parameters); + relation_parameters.public_input_delta = compute_public_input_delta(this->public_inputs, + relation_parameters.beta, + relation_parameters.gamma, + this->circuit_size, + this->pub_inputs_offset); + + // Compute permutation grand product polynomial + compute_grand_product>( + this->polynomials, relation_parameters, size_override); } }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.cpp index 0e00ba6adc25..0f9063b65749 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_circuit_builder.cpp @@ -8,6 +8,7 @@ #include "ultra_circuit_builder.hpp" #include "barretenberg/crypto/poseidon2/poseidon2_params.hpp" #include +#include #include #include diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp index 76b8e1ed56a8..4df8941fd538 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/ultra_flavor.hpp @@ -52,7 +52,6 @@ class UltraFlavor { // Total number of folded polynomials, which is just all polynomials except the shifts static constexpr size_t NUM_FOLDED_ENTITIES = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; - using GrandProductRelations = std::tuple>; // define the tuple of Relations that comprise the Sumcheck relation // Note: made generic for use in MegaRecursive. template @@ -401,18 +400,19 @@ class UltraFlavor { * @brief Computes public_input_delta and the permutation grand product polynomial * * @param relation_parameters + * @param size_override override the size of the domain over which to compute the grand product */ - void compute_grand_product_polynomials(RelationParameters& relation_parameters) + void compute_grand_product_polynomial(RelationParameters& relation_parameters, size_t size_override = 0) { - auto public_input_delta = compute_public_input_delta(this->public_inputs, - relation_parameters.beta, - relation_parameters.gamma, - this->circuit_size, - this->pub_inputs_offset); - relation_parameters.public_input_delta = public_input_delta; - - // Compute permutation and lookup grand product polynomials - compute_grand_products(this->polynomials, relation_parameters); + relation_parameters.public_input_delta = compute_public_input_delta(this->public_inputs, + relation_parameters.beta, + relation_parameters.gamma, + this->circuit_size, + this->pub_inputs_offset); + + // Compute permutation grand product polynomial + compute_grand_product>( + this->polynomials, relation_parameters, size_override); } }; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp index e89d27d23db2..b28affc45cb5 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp @@ -18,7 +18,7 @@ template size_t DeciderProvingKey_::compute_dyadic // minimum size of execution trace due to everything else size_t min_size_of_execution_trace = circuit.public_inputs.size() + circuit.num_gates; - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { min_size_of_execution_trace += circuit.blocks.ecc_op.size(); } @@ -39,7 +39,7 @@ template size_t DeciderProvingKey_::compute_dyadic */ template void DeciderProvingKey_::construct_databus_polynomials(Circuit& circuit) - requires IsGoblinFlavor + requires IsMegaFlavor { auto& calldata_poly = proving_key.polynomials.calldata; auto& calldata_read_counts = proving_key.polynomials.calldata_read_counts; @@ -114,7 +114,7 @@ void DeciderProvingKey_::move_structured_trace_overflow_to_overflow_bloc if (block_size > fixed_block_size && block != overflow_block) { // Disallow overflow in blocks that are not expected to be used by App circuits ASSERT(!block.is_pub_inputs); - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { ASSERT(block != blocks.ecc_op); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp index dd8c8593b845..14f399503f84 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.hpp @@ -45,6 +45,8 @@ template class DeciderProvingKey_ { // The target sum, which is typically nonzero for a ProtogalaxyProver's accmumulator FF target_sum; + size_t final_active_wire_idx{ 0 }; // idx of last non-trivial wire value in the trace + DeciderProvingKey_(Circuit& circuit, TraceSettings trace_settings = TraceSettings{}, std::shared_ptr commitment_key = nullptr) @@ -75,10 +77,17 @@ template class DeciderProvingKey_ { Trace::populate_public_inputs_block(circuit); circuit.blocks.compute_offsets(is_structured); + // Find index of last non-trivial wire value in the trace + for (auto& block : circuit.blocks.get()) { + if (block.size() > 0) { + final_active_wire_idx = block.trace_offset + block.size() - 1; + } + } + // TODO(https://github.com/AztecProtocol/barretenberg/issues/905): This is adding ops to the op queue but NOT to // the circuit, meaning the ECCVM/Translator will use different ops than the main circuit. This will lead to // failure once https://github.com/AztecProtocol/barretenberg/issues/746 is resolved. - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { circuit.op_queue->append_nonzero_ops(); } { @@ -88,7 +97,7 @@ template class DeciderProvingKey_ { proving_key = ProvingKey(dyadic_circuit_size, circuit.public_inputs.size(), commitment_key); // If not using structured trace OR if using structured trace but overflow has occurred (overflow block in // use), allocate full size polys - if ((IsGoblinFlavor && !is_structured) || (is_structured && circuit.blocks.has_overflow)) { + if ((IsMegaFlavor && !is_structured) || (is_structured && circuit.blocks.has_overflow)) { // Allocate full size polynomials proving_key.polynomials = typename Flavor::ProverPolynomials(dyadic_circuit_size); } else { // Allocate only a correct amount of memory for each polynomial @@ -129,7 +138,7 @@ template class DeciderProvingKey_ { selector = Polynomial(proving_key.circuit_size); } } - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { PROFILE_THIS_NAME("allocating ecc op wires and selector"); // Allocate the ecc op wires and selector @@ -238,8 +247,14 @@ template class DeciderProvingKey_ { PROFILE_THIS_NAME("allocating lagrange polynomials"); // First and last lagrange polynomials (in the full circuit size) - proving_key.polynomials.lagrange_first = Polynomial(1, dyadic_circuit_size, 0); - proving_key.polynomials.lagrange_last = Polynomial(1, dyadic_circuit_size, dyadic_circuit_size - 1); + proving_key.polynomials.lagrange_first = Polynomial( + /* size=*/1, /*virtual size=*/dyadic_circuit_size, /*start_idx=*/0); + + // Even though lagrange_last has a singe non-zero element, we cannot set its size to 0 as different + // keys being folded might have lagrange_last set at different indexes and folding does not work + // correctly unless the polynomial is allocated in the correct range to accomodate this + proving_key.polynomials.lagrange_last = Polynomial( + /* size=*/dyadic_circuit_size, /*virtual size=*/dyadic_circuit_size, /*start_idx=*/0); } } // We can finally set the shifted polynomials now that all of the to_be_shifted polynomials are @@ -256,7 +271,7 @@ template class DeciderProvingKey_ { PROFILE_THIS_NAME("constructing prover instance after trace populate"); // If Goblin, construct the databus polynomials - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { PROFILE_THIS_NAME("constructing databus polynomials"); construct_databus_polynomials(circuit); @@ -264,7 +279,7 @@ template class DeciderProvingKey_ { } // Set the lagrange polynomials proving_key.polynomials.lagrange_first.at(0) = 1; - proving_key.polynomials.lagrange_last.at(dyadic_circuit_size - 1) = 1; + proving_key.polynomials.lagrange_last.at(final_active_wire_idx) = 1; { PROFILE_THIS_NAME("constructing lookup table polynomials"); @@ -293,7 +308,7 @@ template class DeciderProvingKey_ { circuit.pairing_point_accumulator_public_input_indices; proving_key.contains_pairing_point_accumulator = circuit.contains_pairing_point_accumulator; - if constexpr (IsGoblinFlavor) { // Set databus commitment propagation data + if constexpr (IsMegaFlavor) { // Set databus commitment propagation data proving_key.databus_propagation_data = circuit.databus_propagation_data; } auto end = std::chrono::steady_clock::now(); @@ -317,14 +332,10 @@ template class DeciderProvingKey_ { * @brief Compute dyadic size based on a structured trace with fixed block size * */ - size_t compute_structured_dyadic_size(Circuit& circuit) - { - size_t minimum_size = circuit.blocks.get_total_structured_size(); - return circuit.get_circuit_subgroup_size(minimum_size); - } + size_t compute_structured_dyadic_size(Circuit& circuit) { return circuit.blocks.get_structured_dyadic_size(); } void construct_databus_polynomials(Circuit&) - requires IsGoblinFlavor; + requires IsMegaFlavor; static void move_structured_trace_overflow_to_overflow_block(Circuit& circuit); }; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp index 6f7b1d8e9196..540a74e6f13e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_verifier.cpp @@ -83,7 +83,6 @@ template bool DeciderVerifier_::verify() libra_evaluations); const auto pairing_points = PCS::reduce_verify_batch_opening_claim(opening_claim, transcript); bool verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - return sumcheck_output.verified.value() && verified; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 594ba28d05c0..cbea1470ab5e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -119,7 +119,7 @@ template void OinkProver::execute_wire_commitment transcript->send_to_verifier(domain_separator + wire_labels[idx], wire_comms[idx]); } - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { // Commit to Goblin ECC op wires for (auto [commitment, polynomial, label] : zip_view(witness_commitments.get_ecc_op_wires(), @@ -211,7 +211,7 @@ template void OinkProver::execute_log_derivative_ witness_commitments.lookup_inverses); // If Mega, commit to the databus inverse polynomials and send - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { for (auto [commitment, polynomial, label] : zip_view(witness_commitments.get_databus_inverses(), proving_key->proving_key.polynomials.get_databus_inverses(), @@ -232,8 +232,9 @@ template void OinkProver::execute_log_derivative_ template void OinkProver::execute_grand_product_computation_round() { PROFILE_THIS_NAME("OinkProver::execute_grand_product_computation_round"); - // Compute the permutation and lookup grand product polynomials - proving_key->proving_key.compute_grand_product_polynomials(proving_key->relation_parameters); + // Compute the permutation grand product polynomial + proving_key->proving_key.compute_grand_product_polynomial(proving_key->relation_parameters, + proving_key->final_active_wire_idx + 1); { PROFILE_THIS_NAME("COMMIT::z_perm"); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_verifier.cpp index 96ca8161f1d3..bd7aa34fb88f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_verifier.cpp @@ -70,7 +70,7 @@ template void OinkVerifier::execute_wire_commitme witness_comms.w_o = transcript->template receive_from_prover(domain_separator + comm_labels.w_o); // If Goblin, get commitments to ECC op wire polynomials and DataBus columns - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { // Receive ECC op wire commitments for (auto [commitment, label] : zip_view(witness_comms.get_ecc_op_wires(), comm_labels.get_ecc_op_wires())) { commitment = transcript->template receive_from_prover(domain_separator + label); @@ -106,7 +106,7 @@ template void OinkVerifier::execute_sorted_list_a } /** - * @brief Get log derivative inverse polynomial and its commitment, if GoblinFlavor + * @brief Get log derivative inverse polynomial and its commitment, if MegaFlavor * */ template void OinkVerifier::execute_log_derivative_inverse_round() @@ -120,7 +120,7 @@ template void OinkVerifier::execute_log_derivativ transcript->template receive_from_prover(domain_separator + comm_labels.lookup_inverses); // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomials - if constexpr (IsGoblinFlavor) { + if constexpr (IsMegaFlavor) { for (auto [commitment, label] : zip_view(witness_comms.get_databus_inverses(), comm_labels.get_databus_inverses())) { commitment = transcript->template receive_from_prover(domain_separator + label); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 1958860a83ad..334a7d6e5f02 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -219,7 +219,7 @@ template void create_some_ecc_op_queue_gates(auto& circuit_bui { using G1 = typename Flavor::Curve::Group; using FF = typename Flavor::FF; - static_assert(IsGoblinFlavor); + static_assert(IsMegaFlavor); const size_t num_ecc_operations = 10; // arbitrary for (size_t i = 0; i < num_ecc_operations; ++i) { auto point = G1::affine_one * FF::random_element(); @@ -249,7 +249,7 @@ TEST_F(UltraRelationCorrectnessTests, Ultra) using Flavor = UltraFlavor; using FF = typename Flavor::FF; - // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented + // Create a builder and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. auto builder = UltraCircuitBuilder(); @@ -276,7 +276,8 @@ TEST_F(UltraRelationCorrectnessTests, Ultra) decider_pk->relation_parameters.eta_two, decider_pk->relation_parameters.eta_three); decider_pk->proving_key.compute_logderivative_inverses(decider_pk->relation_parameters); - decider_pk->proving_key.compute_grand_product_polynomials(decider_pk->relation_parameters); + decider_pk->proving_key.compute_grand_product_polynomial(decider_pk->relation_parameters, + decider_pk->final_active_wire_idx + 1); // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution ensure_non_zero(proving_key.polynomials.q_arith); @@ -329,7 +330,8 @@ TEST_F(UltraRelationCorrectnessTests, Mega) decider_pk->relation_parameters.eta_two, decider_pk->relation_parameters.eta_three); decider_pk->proving_key.compute_logderivative_inverses(decider_pk->relation_parameters); - decider_pk->proving_key.compute_grand_product_polynomials(decider_pk->relation_parameters); + decider_pk->proving_key.compute_grand_product_polynomial(decider_pk->relation_parameters, + decider_pk->final_active_wire_idx + 1); // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution ensure_non_zero(proving_key.polynomials.q_arith); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index 45f5a78c4d35..2a7c3d5646b5 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -160,7 +160,8 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) decider_pk->relation_parameters.eta_two, decider_pk->relation_parameters.eta_three); decider_pk->proving_key.compute_logderivative_inverses(decider_pk->relation_parameters); - decider_pk->proving_key.compute_grand_product_polynomials(decider_pk->relation_parameters); + decider_pk->proving_key.compute_grand_product_polynomial(decider_pk->relation_parameters, + decider_pk->final_active_wire_idx + 1); auto prover_transcript = Transcript::prover_init_empty(); auto circuit_size = decider_pk->proving_key.circuit_size; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp index 149a31348056..6a3d9ae9f170 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp @@ -139,6 +139,7 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.alu_cmp_gadget_gt.set_if_valid_index(i, rows[i].alu_cmp_gadget_gt); polys.alu_cmp_gadget_input_a.set_if_valid_index(i, rows[i].alu_cmp_gadget_input_a); polys.alu_cmp_gadget_input_b.set_if_valid_index(i, rows[i].alu_cmp_gadget_input_b); + polys.alu_cmp_gadget_non_ff_gt.set_if_valid_index(i, rows[i].alu_cmp_gadget_non_ff_gt); polys.alu_cmp_gadget_result.set_if_valid_index(i, rows[i].alu_cmp_gadget_result); polys.alu_cmp_gadget_sel.set_if_valid_index(i, rows[i].alu_cmp_gadget_sel); polys.alu_ff_tag.set_if_valid_index(i, rows[i].alu_ff_tag); @@ -218,11 +219,13 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.cmp_borrow.set_if_valid_index(i, rows[i].cmp_borrow); polys.cmp_clk.set_if_valid_index(i, rows[i].cmp_clk); polys.cmp_cmp_rng_ctr.set_if_valid_index(i, rows[i].cmp_cmp_rng_ctr); + polys.cmp_diff.set_if_valid_index(i, rows[i].cmp_diff); polys.cmp_input_a.set_if_valid_index(i, rows[i].cmp_input_a); polys.cmp_input_b.set_if_valid_index(i, rows[i].cmp_input_b); polys.cmp_op_eq.set_if_valid_index(i, rows[i].cmp_op_eq); polys.cmp_op_eq_diff_inv.set_if_valid_index(i, rows[i].cmp_op_eq_diff_inv); polys.cmp_op_gt.set_if_valid_index(i, rows[i].cmp_op_gt); + polys.cmp_op_non_ff_gt.set_if_valid_index(i, rows[i].cmp_op_non_ff_gt); polys.cmp_p_a_borrow.set_if_valid_index(i, rows[i].cmp_p_a_borrow); polys.cmp_p_b_borrow.set_if_valid_index(i, rows[i].cmp_p_b_borrow); polys.cmp_p_sub_a_hi.set_if_valid_index(i, rows[i].cmp_p_sub_a_hi); @@ -760,6 +763,7 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.range_check_clk.set_if_valid_index(i, rows[i].range_check_clk); polys.range_check_cmp_hi_bits_rng_chk.set_if_valid_index(i, rows[i].range_check_cmp_hi_bits_rng_chk); polys.range_check_cmp_lo_bits_rng_chk.set_if_valid_index(i, rows[i].range_check_cmp_lo_bits_rng_chk); + polys.range_check_cmp_non_ff_rng_chk.set_if_valid_index(i, rows[i].range_check_cmp_non_ff_rng_chk); polys.range_check_dyn_diff.set_if_valid_index(i, rows[i].range_check_dyn_diff); polys.range_check_dyn_rng_chk_bits.set_if_valid_index(i, rows[i].range_check_dyn_rng_chk_bits); polys.range_check_dyn_rng_chk_pow_2.set_if_valid_index(i, rows[i].range_check_dyn_rng_chk_pow_2); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index 8c8a393e69f3..5d5c812deb0d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -44,812 +44,817 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , alu_cmp_gadget_gt(il[36]) , alu_cmp_gadget_input_a(il[37]) , alu_cmp_gadget_input_b(il[38]) - , alu_cmp_gadget_result(il[39]) - , alu_cmp_gadget_sel(il[40]) - , alu_ff_tag(il[41]) - , alu_ia(il[42]) - , alu_ib(il[43]) - , alu_ic(il[44]) - , alu_in_tag(il[45]) - , alu_max_bits_sub_b_bits(il[46]) - , alu_max_bits_sub_b_pow(il[47]) - , alu_op_add(il[48]) - , alu_op_cast(il[49]) - , alu_op_div(il[50]) - , alu_op_eq(il[51]) - , alu_op_lt(il[52]) - , alu_op_lte(il[53]) - , alu_op_mul(il[54]) - , alu_op_not(il[55]) - , alu_op_shl(il[56]) - , alu_op_shr(il[57]) - , alu_op_sub(il[58]) - , alu_partial_prod_hi(il[59]) - , alu_partial_prod_lo(il[60]) - , alu_range_check_input_value(il[61]) - , alu_range_check_num_bits(il[62]) - , alu_range_check_sel(il[63]) - , alu_remainder(il[64]) - , alu_sel_alu(il[65]) - , alu_sel_cmp(il[66]) - , alu_sel_shift_which(il[67]) - , alu_u128_tag(il[68]) - , alu_u16_tag(il[69]) - , alu_u1_tag(il[70]) - , alu_u32_tag(il[71]) - , alu_u64_tag(il[72]) - , alu_u8_tag(il[73]) - , alu_zero_shift(il[74]) - , binary_acc_ia(il[75]) - , binary_acc_ib(il[76]) - , binary_acc_ic(il[77]) - , binary_clk(il[78]) - , binary_ia_bytes(il[79]) - , binary_ib_bytes(il[80]) - , binary_ic_bytes(il[81]) - , binary_in_tag(il[82]) - , binary_mem_tag_ctr(il[83]) - , binary_mem_tag_ctr_inv(il[84]) - , binary_op_id(il[85]) - , binary_sel_bin(il[86]) - , binary_start(il[87]) - , bytecode_arifact_hash(il[88]) - , bytecode_as_fields(il[89]) - , bytecode_bytes(il[90]) - , bytecode_bytes_pc(il[91]) - , bytecode_class_id(il[92]) - , bytecode_contract_address(il[93]) - , bytecode_decomposed(il[94]) - , bytecode_deployer_addr(il[95]) - , bytecode_end_latch(il[96]) - , bytecode_incoming_viewing_key_x(il[97]) - , bytecode_incoming_viewing_key_y(il[98]) - , bytecode_initialization_hash(il[99]) - , bytecode_length_remaining(il[100]) - , bytecode_nullifier_key_x(il[101]) - , bytecode_nullifier_key_y(il[102]) - , bytecode_outgoing_viewing_key_x(il[103]) - , bytecode_outgoing_viewing_key_y(il[104]) - , bytecode_private_fn_root(il[105]) - , bytecode_public_key_hash(il[106]) - , bytecode_running_hash(il[107]) - , bytecode_salt(il[108]) - , bytecode_tagging_key_x(il[109]) - , bytecode_tagging_key_y(il[110]) - , cmp_a_hi(il[111]) - , cmp_a_lo(il[112]) - , cmp_b_hi(il[113]) - , cmp_b_lo(il[114]) - , cmp_borrow(il[115]) - , cmp_clk(il[116]) - , cmp_cmp_rng_ctr(il[117]) - , cmp_input_a(il[118]) - , cmp_input_b(il[119]) - , cmp_op_eq(il[120]) - , cmp_op_eq_diff_inv(il[121]) - , cmp_op_gt(il[122]) - , cmp_p_a_borrow(il[123]) - , cmp_p_b_borrow(il[124]) - , cmp_p_sub_a_hi(il[125]) - , cmp_p_sub_a_lo(il[126]) - , cmp_p_sub_b_hi(il[127]) - , cmp_p_sub_b_lo(il[128]) - , cmp_range_chk_clk(il[129]) - , cmp_res_hi(il[130]) - , cmp_res_lo(il[131]) - , cmp_result(il[132]) - , cmp_sel_cmp(il[133]) - , cmp_sel_rng_chk(il[134]) - , cmp_shift_sel(il[135]) - , conversion_clk(il[136]) - , conversion_input(il[137]) - , conversion_num_limbs(il[138]) - , conversion_output_bits(il[139]) - , conversion_radix(il[140]) - , conversion_sel_to_radix_be(il[141]) - , keccakf1600_clk(il[142]) - , keccakf1600_input(il[143]) - , keccakf1600_output(il[144]) - , keccakf1600_sel_keccakf1600(il[145]) - , main_abs_da_rem_gas(il[146]) - , main_abs_l2_rem_gas(il[147]) - , main_alu_in_tag(il[148]) - , main_base_da_gas_op_cost(il[149]) - , main_base_l2_gas_op_cost(il[150]) - , main_bin_op_id(il[151]) - , main_call_ptr(il[152]) - , main_da_gas_remaining(il[153]) - , main_da_gas_u16_r0(il[154]) - , main_da_gas_u16_r1(il[155]) - , main_da_out_of_gas(il[156]) - , main_dyn_da_gas_op_cost(il[157]) - , main_dyn_gas_multiplier(il[158]) - , main_dyn_l2_gas_op_cost(il[159]) - , main_emit_l2_to_l1_msg_write_offset(il[160]) - , main_emit_note_hash_write_offset(il[161]) - , main_emit_nullifier_write_offset(il[162]) - , main_emit_unencrypted_log_write_offset(il[163]) - , main_ia(il[164]) - , main_ib(il[165]) - , main_ic(il[166]) - , main_id(il[167]) - , main_id_zero(il[168]) - , main_ind_addr_a(il[169]) - , main_ind_addr_b(il[170]) - , main_ind_addr_c(il[171]) - , main_ind_addr_d(il[172]) - , main_internal_return_ptr(il[173]) - , main_inv(il[174]) - , main_is_fake_row(il[175]) - , main_is_gas_accounted(il[176]) - , main_kernel_in_offset(il[177]) - , main_kernel_out_offset(il[178]) - , main_l1_to_l2_msg_exists_write_offset(il[179]) - , main_l2_gas_remaining(il[180]) - , main_l2_gas_u16_r0(il[181]) - , main_l2_gas_u16_r1(il[182]) - , main_l2_out_of_gas(il[183]) - , main_mem_addr_a(il[184]) - , main_mem_addr_b(il[185]) - , main_mem_addr_c(il[186]) - , main_mem_addr_d(il[187]) - , main_note_hash_exist_write_offset(il[188]) - , main_nullifier_exists_write_offset(il[189]) - , main_nullifier_non_exists_write_offset(il[190]) - , main_op_err(il[191]) - , main_opcode_val(il[192]) - , main_pc(il[193]) - , main_r_in_tag(il[194]) - , main_rwa(il[195]) - , main_rwb(il[196]) - , main_rwc(il[197]) - , main_rwd(il[198]) - , main_sel_alu(il[199]) - , main_sel_bin(il[200]) - , main_sel_calldata(il[201]) - , main_sel_execution_end(il[202]) - , main_sel_execution_row(il[203]) - , main_sel_kernel_inputs(il[204]) - , main_sel_kernel_out(il[205]) - , main_sel_mem_op_a(il[206]) - , main_sel_mem_op_b(il[207]) - , main_sel_mem_op_c(il[208]) - , main_sel_mem_op_d(il[209]) - , main_sel_mov_ia_to_ic(il[210]) - , main_sel_mov_ib_to_ic(il[211]) - , main_sel_op_add(il[212]) - , main_sel_op_address(il[213]) - , main_sel_op_and(il[214]) - , main_sel_op_block_number(il[215]) - , main_sel_op_calldata_copy(il[216]) - , main_sel_op_cast(il[217]) - , main_sel_op_chain_id(il[218]) - , main_sel_op_dagasleft(il[219]) - , main_sel_op_debug_log(il[220]) - , main_sel_op_div(il[221]) - , main_sel_op_ecadd(il[222]) - , main_sel_op_emit_l2_to_l1_msg(il[223]) - , main_sel_op_emit_note_hash(il[224]) - , main_sel_op_emit_nullifier(il[225]) - , main_sel_op_emit_unencrypted_log(il[226]) - , main_sel_op_eq(il[227]) - , main_sel_op_external_call(il[228]) - , main_sel_op_external_return(il[229]) - , main_sel_op_external_revert(il[230]) - , main_sel_op_fdiv(il[231]) - , main_sel_op_fee_per_da_gas(il[232]) - , main_sel_op_fee_per_l2_gas(il[233]) - , main_sel_op_function_selector(il[234]) - , main_sel_op_get_contract_instance(il[235]) - , main_sel_op_internal_call(il[236]) - , main_sel_op_internal_return(il[237]) - , main_sel_op_is_static_call(il[238]) - , main_sel_op_jump(il[239]) - , main_sel_op_jumpi(il[240]) - , main_sel_op_keccak(il[241]) - , main_sel_op_l1_to_l2_msg_exists(il[242]) - , main_sel_op_l2gasleft(il[243]) - , main_sel_op_lt(il[244]) - , main_sel_op_lte(il[245]) - , main_sel_op_mov(il[246]) - , main_sel_op_msm(il[247]) - , main_sel_op_mul(il[248]) - , main_sel_op_not(il[249]) - , main_sel_op_note_hash_exists(il[250]) - , main_sel_op_nullifier_exists(il[251]) - , main_sel_op_or(il[252]) - , main_sel_op_poseidon2(il[253]) - , main_sel_op_radix_be(il[254]) - , main_sel_op_returndata_copy(il[255]) - , main_sel_op_returndata_size(il[256]) - , main_sel_op_sender(il[257]) - , main_sel_op_set(il[258]) - , main_sel_op_sha256(il[259]) - , main_sel_op_shl(il[260]) - , main_sel_op_shr(il[261]) - , main_sel_op_sload(il[262]) - , main_sel_op_sstore(il[263]) - , main_sel_op_static_call(il[264]) - , main_sel_op_sub(il[265]) - , main_sel_op_timestamp(il[266]) - , main_sel_op_transaction_fee(il[267]) - , main_sel_op_version(il[268]) - , main_sel_op_xor(il[269]) - , main_sel_q_kernel_lookup(il[270]) - , main_sel_q_kernel_output_lookup(il[271]) - , main_sel_resolve_ind_addr_a(il[272]) - , main_sel_resolve_ind_addr_b(il[273]) - , main_sel_resolve_ind_addr_c(il[274]) - , main_sel_resolve_ind_addr_d(il[275]) - , main_sel_returndata(il[276]) - , main_sel_rng_16(il[277]) - , main_sel_rng_8(il[278]) - , main_sel_slice_gadget(il[279]) - , main_side_effect_counter(il[280]) - , main_sload_write_offset(il[281]) - , main_space_id(il[282]) - , main_sstore_write_offset(il[283]) - , main_tag_err(il[284]) - , main_w_in_tag(il[285]) - , mem_addr(il[286]) - , mem_clk(il[287]) - , mem_diff(il[288]) - , mem_glob_addr(il[289]) - , mem_last(il[290]) - , mem_lastAccess(il[291]) - , mem_one_min_inv(il[292]) - , mem_r_in_tag(il[293]) - , mem_rw(il[294]) - , mem_sel_mem(il[295]) - , mem_sel_mov_ia_to_ic(il[296]) - , mem_sel_mov_ib_to_ic(il[297]) - , mem_sel_op_a(il[298]) - , mem_sel_op_b(il[299]) - , mem_sel_op_c(il[300]) - , mem_sel_op_d(il[301]) - , mem_sel_op_poseidon_read_a(il[302]) - , mem_sel_op_poseidon_read_b(il[303]) - , mem_sel_op_poseidon_read_c(il[304]) - , mem_sel_op_poseidon_read_d(il[305]) - , mem_sel_op_poseidon_write_a(il[306]) - , mem_sel_op_poseidon_write_b(il[307]) - , mem_sel_op_poseidon_write_c(il[308]) - , mem_sel_op_poseidon_write_d(il[309]) - , mem_sel_op_slice(il[310]) - , mem_sel_resolve_ind_addr_a(il[311]) - , mem_sel_resolve_ind_addr_b(il[312]) - , mem_sel_resolve_ind_addr_c(il[313]) - , mem_sel_resolve_ind_addr_d(il[314]) - , mem_sel_rng_chk(il[315]) - , mem_skip_check_tag(il[316]) - , mem_space_id(il[317]) - , mem_tag(il[318]) - , mem_tag_err(il[319]) - , mem_tsp(il[320]) - , mem_u16_r0(il[321]) - , mem_u16_r1(il[322]) - , mem_u8_r0(il[323]) - , mem_val(il[324]) - , mem_w_in_tag(il[325]) - , merkle_tree_clk(il[326]) - , merkle_tree_expected_tree_root(il[327]) - , merkle_tree_latch(il[328]) - , merkle_tree_leaf_index(il[329]) - , merkle_tree_leaf_index_is_even(il[330]) - , merkle_tree_leaf_value(il[331]) - , merkle_tree_left_hash(il[332]) - , merkle_tree_output_hash(il[333]) - , merkle_tree_path_len(il[334]) - , merkle_tree_path_len_inv(il[335]) - , merkle_tree_right_hash(il[336]) - , merkle_tree_sel_merkle_tree(il[337]) - , merkle_tree_sibling_value(il[338]) - , poseidon2_B_10_0(il[339]) - , poseidon2_B_10_1(il[340]) - , poseidon2_B_10_2(il[341]) - , poseidon2_B_10_3(il[342]) - , poseidon2_B_11_0(il[343]) - , poseidon2_B_11_1(il[344]) - , poseidon2_B_11_2(il[345]) - , poseidon2_B_11_3(il[346]) - , poseidon2_B_12_0(il[347]) - , poseidon2_B_12_1(il[348]) - , poseidon2_B_12_2(il[349]) - , poseidon2_B_12_3(il[350]) - , poseidon2_B_13_0(il[351]) - , poseidon2_B_13_1(il[352]) - , poseidon2_B_13_2(il[353]) - , poseidon2_B_13_3(il[354]) - , poseidon2_B_14_0(il[355]) - , poseidon2_B_14_1(il[356]) - , poseidon2_B_14_2(il[357]) - , poseidon2_B_14_3(il[358]) - , poseidon2_B_15_0(il[359]) - , poseidon2_B_15_1(il[360]) - , poseidon2_B_15_2(il[361]) - , poseidon2_B_15_3(il[362]) - , poseidon2_B_16_0(il[363]) - , poseidon2_B_16_1(il[364]) - , poseidon2_B_16_2(il[365]) - , poseidon2_B_16_3(il[366]) - , poseidon2_B_17_0(il[367]) - , poseidon2_B_17_1(il[368]) - , poseidon2_B_17_2(il[369]) - , poseidon2_B_17_3(il[370]) - , poseidon2_B_18_0(il[371]) - , poseidon2_B_18_1(il[372]) - , poseidon2_B_18_2(il[373]) - , poseidon2_B_18_3(il[374]) - , poseidon2_B_19_0(il[375]) - , poseidon2_B_19_1(il[376]) - , poseidon2_B_19_2(il[377]) - , poseidon2_B_19_3(il[378]) - , poseidon2_B_20_0(il[379]) - , poseidon2_B_20_1(il[380]) - , poseidon2_B_20_2(il[381]) - , poseidon2_B_20_3(il[382]) - , poseidon2_B_21_0(il[383]) - , poseidon2_B_21_1(il[384]) - , poseidon2_B_21_2(il[385]) - , poseidon2_B_21_3(il[386]) - , poseidon2_B_22_0(il[387]) - , poseidon2_B_22_1(il[388]) - , poseidon2_B_22_2(il[389]) - , poseidon2_B_22_3(il[390]) - , poseidon2_B_23_0(il[391]) - , poseidon2_B_23_1(il[392]) - , poseidon2_B_23_2(il[393]) - , poseidon2_B_23_3(il[394]) - , poseidon2_B_24_0(il[395]) - , poseidon2_B_24_1(il[396]) - , poseidon2_B_24_2(il[397]) - , poseidon2_B_24_3(il[398]) - , poseidon2_B_25_0(il[399]) - , poseidon2_B_25_1(il[400]) - , poseidon2_B_25_2(il[401]) - , poseidon2_B_25_3(il[402]) - , poseidon2_B_26_0(il[403]) - , poseidon2_B_26_1(il[404]) - , poseidon2_B_26_2(il[405]) - , poseidon2_B_26_3(il[406]) - , poseidon2_B_27_0(il[407]) - , poseidon2_B_27_1(il[408]) - , poseidon2_B_27_2(il[409]) - , poseidon2_B_27_3(il[410]) - , poseidon2_B_28_0(il[411]) - , poseidon2_B_28_1(il[412]) - , poseidon2_B_28_2(il[413]) - , poseidon2_B_28_3(il[414]) - , poseidon2_B_29_0(il[415]) - , poseidon2_B_29_1(il[416]) - , poseidon2_B_29_2(il[417]) - , poseidon2_B_29_3(il[418]) - , poseidon2_B_30_0(il[419]) - , poseidon2_B_30_1(il[420]) - , poseidon2_B_30_2(il[421]) - , poseidon2_B_30_3(il[422]) - , poseidon2_B_31_0(il[423]) - , poseidon2_B_31_1(il[424]) - , poseidon2_B_31_2(il[425]) - , poseidon2_B_31_3(il[426]) - , poseidon2_B_32_0(il[427]) - , poseidon2_B_32_1(il[428]) - , poseidon2_B_32_2(il[429]) - , poseidon2_B_32_3(il[430]) - , poseidon2_B_33_0(il[431]) - , poseidon2_B_33_1(il[432]) - , poseidon2_B_33_2(il[433]) - , poseidon2_B_33_3(il[434]) - , poseidon2_B_34_0(il[435]) - , poseidon2_B_34_1(il[436]) - , poseidon2_B_34_2(il[437]) - , poseidon2_B_34_3(il[438]) - , poseidon2_B_35_0(il[439]) - , poseidon2_B_35_1(il[440]) - , poseidon2_B_35_2(il[441]) - , poseidon2_B_35_3(il[442]) - , poseidon2_B_36_0(il[443]) - , poseidon2_B_36_1(il[444]) - , poseidon2_B_36_2(il[445]) - , poseidon2_B_36_3(il[446]) - , poseidon2_B_37_0(il[447]) - , poseidon2_B_37_1(il[448]) - , poseidon2_B_37_2(il[449]) - , poseidon2_B_37_3(il[450]) - , poseidon2_B_38_0(il[451]) - , poseidon2_B_38_1(il[452]) - , poseidon2_B_38_2(il[453]) - , poseidon2_B_38_3(il[454]) - , poseidon2_B_39_0(il[455]) - , poseidon2_B_39_1(il[456]) - , poseidon2_B_39_2(il[457]) - , poseidon2_B_39_3(il[458]) - , poseidon2_B_40_0(il[459]) - , poseidon2_B_40_1(il[460]) - , poseidon2_B_40_2(il[461]) - , poseidon2_B_40_3(il[462]) - , poseidon2_B_41_0(il[463]) - , poseidon2_B_41_1(il[464]) - , poseidon2_B_41_2(il[465]) - , poseidon2_B_41_3(il[466]) - , poseidon2_B_42_0(il[467]) - , poseidon2_B_42_1(il[468]) - , poseidon2_B_42_2(il[469]) - , poseidon2_B_42_3(il[470]) - , poseidon2_B_43_0(il[471]) - , poseidon2_B_43_1(il[472]) - , poseidon2_B_43_2(il[473]) - , poseidon2_B_43_3(il[474]) - , poseidon2_B_44_0(il[475]) - , poseidon2_B_44_1(il[476]) - , poseidon2_B_44_2(il[477]) - , poseidon2_B_44_3(il[478]) - , poseidon2_B_45_0(il[479]) - , poseidon2_B_45_1(il[480]) - , poseidon2_B_45_2(il[481]) - , poseidon2_B_45_3(il[482]) - , poseidon2_B_46_0(il[483]) - , poseidon2_B_46_1(il[484]) - , poseidon2_B_46_2(il[485]) - , poseidon2_B_46_3(il[486]) - , poseidon2_B_47_0(il[487]) - , poseidon2_B_47_1(il[488]) - , poseidon2_B_47_2(il[489]) - , poseidon2_B_47_3(il[490]) - , poseidon2_B_48_0(il[491]) - , poseidon2_B_48_1(il[492]) - , poseidon2_B_48_2(il[493]) - , poseidon2_B_48_3(il[494]) - , poseidon2_B_49_0(il[495]) - , poseidon2_B_49_1(il[496]) - , poseidon2_B_49_2(il[497]) - , poseidon2_B_49_3(il[498]) - , poseidon2_B_4_0(il[499]) - , poseidon2_B_4_1(il[500]) - , poseidon2_B_4_2(il[501]) - , poseidon2_B_4_3(il[502]) - , poseidon2_B_50_0(il[503]) - , poseidon2_B_50_1(il[504]) - , poseidon2_B_50_2(il[505]) - , poseidon2_B_50_3(il[506]) - , poseidon2_B_51_0(il[507]) - , poseidon2_B_51_1(il[508]) - , poseidon2_B_51_2(il[509]) - , poseidon2_B_51_3(il[510]) - , poseidon2_B_52_0(il[511]) - , poseidon2_B_52_1(il[512]) - , poseidon2_B_52_2(il[513]) - , poseidon2_B_52_3(il[514]) - , poseidon2_B_53_0(il[515]) - , poseidon2_B_53_1(il[516]) - , poseidon2_B_53_2(il[517]) - , poseidon2_B_53_3(il[518]) - , poseidon2_B_54_0(il[519]) - , poseidon2_B_54_1(il[520]) - , poseidon2_B_54_2(il[521]) - , poseidon2_B_54_3(il[522]) - , poseidon2_B_55_0(il[523]) - , poseidon2_B_55_1(il[524]) - , poseidon2_B_55_2(il[525]) - , poseidon2_B_55_3(il[526]) - , poseidon2_B_56_0(il[527]) - , poseidon2_B_56_1(il[528]) - , poseidon2_B_56_2(il[529]) - , poseidon2_B_56_3(il[530]) - , poseidon2_B_57_0(il[531]) - , poseidon2_B_57_1(il[532]) - , poseidon2_B_57_2(il[533]) - , poseidon2_B_57_3(il[534]) - , poseidon2_B_58_0(il[535]) - , poseidon2_B_58_1(il[536]) - , poseidon2_B_58_2(il[537]) - , poseidon2_B_58_3(il[538]) - , poseidon2_B_59_0(il[539]) - , poseidon2_B_59_1(il[540]) - , poseidon2_B_59_2(il[541]) - , poseidon2_B_59_3(il[542]) - , poseidon2_B_5_0(il[543]) - , poseidon2_B_5_1(il[544]) - , poseidon2_B_5_2(il[545]) - , poseidon2_B_5_3(il[546]) - , poseidon2_B_6_0(il[547]) - , poseidon2_B_6_1(il[548]) - , poseidon2_B_6_2(il[549]) - , poseidon2_B_6_3(il[550]) - , poseidon2_B_7_0(il[551]) - , poseidon2_B_7_1(il[552]) - , poseidon2_B_7_2(il[553]) - , poseidon2_B_7_3(il[554]) - , poseidon2_B_8_0(il[555]) - , poseidon2_B_8_1(il[556]) - , poseidon2_B_8_2(il[557]) - , poseidon2_B_8_3(il[558]) - , poseidon2_B_9_0(il[559]) - , poseidon2_B_9_1(il[560]) - , poseidon2_B_9_2(il[561]) - , poseidon2_B_9_3(il[562]) - , poseidon2_EXT_LAYER_4(il[563]) - , poseidon2_EXT_LAYER_5(il[564]) - , poseidon2_EXT_LAYER_6(il[565]) - , poseidon2_EXT_LAYER_7(il[566]) - , poseidon2_T_0_4(il[567]) - , poseidon2_T_0_5(il[568]) - , poseidon2_T_0_6(il[569]) - , poseidon2_T_0_7(il[570]) - , poseidon2_T_1_4(il[571]) - , poseidon2_T_1_5(il[572]) - , poseidon2_T_1_6(il[573]) - , poseidon2_T_1_7(il[574]) - , poseidon2_T_2_4(il[575]) - , poseidon2_T_2_5(il[576]) - , poseidon2_T_2_6(il[577]) - , poseidon2_T_2_7(il[578]) - , poseidon2_T_3_4(il[579]) - , poseidon2_T_3_5(il[580]) - , poseidon2_T_3_6(il[581]) - , poseidon2_T_3_7(il[582]) - , poseidon2_T_60_4(il[583]) - , poseidon2_T_60_5(il[584]) - , poseidon2_T_60_6(il[585]) - , poseidon2_T_60_7(il[586]) - , poseidon2_T_61_4(il[587]) - , poseidon2_T_61_5(il[588]) - , poseidon2_T_61_6(il[589]) - , poseidon2_T_61_7(il[590]) - , poseidon2_T_62_4(il[591]) - , poseidon2_T_62_5(il[592]) - , poseidon2_T_62_6(il[593]) - , poseidon2_T_62_7(il[594]) - , poseidon2_T_63_4(il[595]) - , poseidon2_T_63_5(il[596]) - , poseidon2_T_63_6(il[597]) - , poseidon2_T_63_7(il[598]) - , poseidon2_a_0(il[599]) - , poseidon2_a_1(il[600]) - , poseidon2_a_2(il[601]) - , poseidon2_a_3(il[602]) - , poseidon2_b_0(il[603]) - , poseidon2_b_1(il[604]) - , poseidon2_b_2(il[605]) - , poseidon2_b_3(il[606]) - , poseidon2_clk(il[607]) - , poseidon2_full_a_0(il[608]) - , poseidon2_full_a_1(il[609]) - , poseidon2_full_a_2(il[610]) - , poseidon2_full_a_3(il[611]) - , poseidon2_full_b_0(il[612]) - , poseidon2_full_b_1(il[613]) - , poseidon2_full_b_2(il[614]) - , poseidon2_full_b_3(il[615]) - , poseidon2_full_clk(il[616]) - , poseidon2_full_end_poseidon(il[617]) - , poseidon2_full_execute_poseidon_perm(il[618]) - , poseidon2_full_input_0(il[619]) - , poseidon2_full_input_1(il[620]) - , poseidon2_full_input_2(il[621]) - , poseidon2_full_input_len(il[622]) - , poseidon2_full_num_perm_rounds_rem(il[623]) - , poseidon2_full_num_perm_rounds_rem_inv(il[624]) - , poseidon2_full_output(il[625]) - , poseidon2_full_padding(il[626]) - , poseidon2_full_sel_merkle_tree(il[627]) - , poseidon2_full_sel_poseidon(il[628]) - , poseidon2_full_start_poseidon(il[629]) - , poseidon2_input_addr(il[630]) - , poseidon2_mem_addr_read_a(il[631]) - , poseidon2_mem_addr_read_b(il[632]) - , poseidon2_mem_addr_read_c(il[633]) - , poseidon2_mem_addr_read_d(il[634]) - , poseidon2_mem_addr_write_a(il[635]) - , poseidon2_mem_addr_write_b(il[636]) - , poseidon2_mem_addr_write_c(il[637]) - , poseidon2_mem_addr_write_d(il[638]) - , poseidon2_output_addr(il[639]) - , poseidon2_sel_poseidon_perm(il[640]) - , poseidon2_sel_poseidon_perm_immediate(il[641]) - , poseidon2_sel_poseidon_perm_mem_op(il[642]) - , poseidon2_space_id(il[643]) - , range_check_alu_rng_chk(il[644]) - , range_check_clk(il[645]) - , range_check_cmp_hi_bits_rng_chk(il[646]) - , range_check_cmp_lo_bits_rng_chk(il[647]) - , range_check_dyn_diff(il[648]) - , range_check_dyn_rng_chk_bits(il[649]) - , range_check_dyn_rng_chk_pow_2(il[650]) - , range_check_gas_da_rng_chk(il[651]) - , range_check_gas_l2_rng_chk(il[652]) - , range_check_is_lte_u112(il[653]) - , range_check_is_lte_u128(il[654]) - , range_check_is_lte_u16(il[655]) - , range_check_is_lte_u32(il[656]) - , range_check_is_lte_u48(il[657]) - , range_check_is_lte_u64(il[658]) - , range_check_is_lte_u80(il[659]) - , range_check_is_lte_u96(il[660]) - , range_check_rng_chk_bits(il[661]) - , range_check_sel_lookup_0(il[662]) - , range_check_sel_lookup_1(il[663]) - , range_check_sel_lookup_2(il[664]) - , range_check_sel_lookup_3(il[665]) - , range_check_sel_lookup_4(il[666]) - , range_check_sel_lookup_5(il[667]) - , range_check_sel_lookup_6(il[668]) - , range_check_sel_rng_chk(il[669]) - , range_check_u16_r0(il[670]) - , range_check_u16_r1(il[671]) - , range_check_u16_r2(il[672]) - , range_check_u16_r3(il[673]) - , range_check_u16_r4(il[674]) - , range_check_u16_r5(il[675]) - , range_check_u16_r6(il[676]) - , range_check_u16_r7(il[677]) - , range_check_value(il[678]) - , sha256_clk(il[679]) - , sha256_input(il[680]) - , sha256_output(il[681]) - , sha256_sel_sha256_compression(il[682]) - , sha256_state(il[683]) - , slice_addr(il[684]) - , slice_clk(il[685]) - , slice_cnt(il[686]) - , slice_col_offset(il[687]) - , slice_one_min_inv(il[688]) - , slice_sel_cd_cpy(il[689]) - , slice_sel_mem_active(il[690]) - , slice_sel_return(il[691]) - , slice_sel_start(il[692]) - , slice_space_id(il[693]) - , slice_val(il[694]) - , lookup_rng_chk_pow_2_counts(il[695]) - , lookup_rng_chk_diff_counts(il[696]) - , lookup_rng_chk_0_counts(il[697]) - , lookup_rng_chk_1_counts(il[698]) - , lookup_rng_chk_2_counts(il[699]) - , lookup_rng_chk_3_counts(il[700]) - , lookup_rng_chk_4_counts(il[701]) - , lookup_rng_chk_5_counts(il[702]) - , lookup_rng_chk_6_counts(il[703]) - , lookup_rng_chk_7_counts(il[704]) - , lookup_mem_rng_chk_0_counts(il[705]) - , lookup_mem_rng_chk_1_counts(il[706]) - , lookup_mem_rng_chk_2_counts(il[707]) - , lookup_pow_2_0_counts(il[708]) - , lookup_pow_2_1_counts(il[709]) - , lookup_byte_lengths_counts(il[710]) - , lookup_byte_operations_counts(il[711]) - , lookup_opcode_gas_counts(il[712]) - , lookup_l2_gas_rng_chk_0_counts(il[713]) - , lookup_l2_gas_rng_chk_1_counts(il[714]) - , lookup_da_gas_rng_chk_0_counts(il[715]) - , lookup_da_gas_rng_chk_1_counts(il[716]) - , kernel_output_lookup_counts(il[717]) - , lookup_into_kernel_counts(il[718]) - , lookup_cd_value_counts(il[719]) - , lookup_ret_value_counts(il[720]) - , incl_main_tag_err_counts(il[721]) - , incl_mem_tag_err_counts(il[722]) - , perm_rng_cmp_lo_inv(il[723]) - , perm_rng_cmp_hi_inv(il[724]) - , perm_rng_alu_inv(il[725]) - , perm_cmp_alu_inv(il[726]) - , perm_l2_start_gas_inv(il[727]) - , perm_da_start_gas_inv(il[728]) - , perm_l2_end_gas_inv(il[729]) - , perm_da_end_gas_inv(il[730]) - , perm_pos_mem_read_a_inv(il[731]) - , perm_pos_mem_read_b_inv(il[732]) - , perm_pos_mem_read_c_inv(il[733]) - , perm_pos_mem_read_d_inv(il[734]) - , perm_pos_mem_write_a_inv(il[735]) - , perm_pos_mem_write_b_inv(il[736]) - , perm_pos_mem_write_c_inv(il[737]) - , perm_pos_mem_write_d_inv(il[738]) - , perm_pos2_fixed_pos2_perm_inv(il[739]) - , perm_slice_mem_inv(il[740]) - , perm_merkle_poseidon2_inv(il[741]) - , perm_main_alu_inv(il[742]) - , perm_main_bin_inv(il[743]) - , perm_main_conv_inv(il[744]) - , perm_main_sha256_inv(il[745]) - , perm_main_pos2_perm_inv(il[746]) - , perm_main_slice_inv(il[747]) - , perm_main_mem_a_inv(il[748]) - , perm_main_mem_b_inv(il[749]) - , perm_main_mem_c_inv(il[750]) - , perm_main_mem_d_inv(il[751]) - , perm_main_mem_ind_addr_a_inv(il[752]) - , perm_main_mem_ind_addr_b_inv(il[753]) - , perm_main_mem_ind_addr_c_inv(il[754]) - , perm_main_mem_ind_addr_d_inv(il[755]) - , lookup_rng_chk_pow_2_inv(il[756]) - , lookup_rng_chk_diff_inv(il[757]) - , lookup_rng_chk_0_inv(il[758]) - , lookup_rng_chk_1_inv(il[759]) - , lookup_rng_chk_2_inv(il[760]) - , lookup_rng_chk_3_inv(il[761]) - , lookup_rng_chk_4_inv(il[762]) - , lookup_rng_chk_5_inv(il[763]) - , lookup_rng_chk_6_inv(il[764]) - , lookup_rng_chk_7_inv(il[765]) - , lookup_mem_rng_chk_0_inv(il[766]) - , lookup_mem_rng_chk_1_inv(il[767]) - , lookup_mem_rng_chk_2_inv(il[768]) - , lookup_pow_2_0_inv(il[769]) - , lookup_pow_2_1_inv(il[770]) - , lookup_byte_lengths_inv(il[771]) - , lookup_byte_operations_inv(il[772]) - , lookup_opcode_gas_inv(il[773]) - , lookup_l2_gas_rng_chk_0_inv(il[774]) - , lookup_l2_gas_rng_chk_1_inv(il[775]) - , lookup_da_gas_rng_chk_0_inv(il[776]) - , lookup_da_gas_rng_chk_1_inv(il[777]) - , kernel_output_lookup_inv(il[778]) - , lookup_into_kernel_inv(il[779]) - , lookup_cd_value_inv(il[780]) - , lookup_ret_value_inv(il[781]) - , incl_main_tag_err_inv(il[782]) - , incl_mem_tag_err_inv(il[783]) - , binary_acc_ia_shift(il[784]) - , binary_acc_ib_shift(il[785]) - , binary_acc_ic_shift(il[786]) - , binary_mem_tag_ctr_shift(il[787]) - , binary_op_id_shift(il[788]) - , cmp_a_hi_shift(il[789]) - , cmp_a_lo_shift(il[790]) - , cmp_b_hi_shift(il[791]) - , cmp_b_lo_shift(il[792]) - , cmp_cmp_rng_ctr_shift(il[793]) - , cmp_op_gt_shift(il[794]) - , cmp_p_sub_a_hi_shift(il[795]) - , cmp_p_sub_a_lo_shift(il[796]) - , cmp_p_sub_b_hi_shift(il[797]) - , cmp_p_sub_b_lo_shift(il[798]) - , cmp_sel_rng_chk_shift(il[799]) - , main_da_gas_remaining_shift(il[800]) - , main_emit_l2_to_l1_msg_write_offset_shift(il[801]) - , main_emit_note_hash_write_offset_shift(il[802]) - , main_emit_nullifier_write_offset_shift(il[803]) - , main_emit_unencrypted_log_write_offset_shift(il[804]) - , main_internal_return_ptr_shift(il[805]) - , main_l1_to_l2_msg_exists_write_offset_shift(il[806]) - , main_l2_gas_remaining_shift(il[807]) - , main_note_hash_exist_write_offset_shift(il[808]) - , main_nullifier_exists_write_offset_shift(il[809]) - , main_nullifier_non_exists_write_offset_shift(il[810]) - , main_pc_shift(il[811]) - , main_sel_execution_end_shift(il[812]) - , main_sel_execution_row_shift(il[813]) - , main_sload_write_offset_shift(il[814]) - , main_sstore_write_offset_shift(il[815]) - , mem_glob_addr_shift(il[816]) - , mem_rw_shift(il[817]) - , mem_sel_mem_shift(il[818]) - , mem_tag_shift(il[819]) - , mem_tsp_shift(il[820]) - , mem_val_shift(il[821]) - , merkle_tree_leaf_index_shift(il[822]) - , merkle_tree_leaf_value_shift(il[823]) - , merkle_tree_path_len_shift(il[824]) - , poseidon2_full_a_0_shift(il[825]) - , poseidon2_full_a_1_shift(il[826]) - , poseidon2_full_a_2_shift(il[827]) - , poseidon2_full_a_3_shift(il[828]) - , poseidon2_full_execute_poseidon_perm_shift(il[829]) - , poseidon2_full_input_0_shift(il[830]) - , poseidon2_full_input_1_shift(il[831]) - , poseidon2_full_input_2_shift(il[832]) - , poseidon2_full_num_perm_rounds_rem_shift(il[833]) - , poseidon2_full_sel_poseidon_shift(il[834]) - , poseidon2_full_start_poseidon_shift(il[835]) - , slice_addr_shift(il[836]) - , slice_clk_shift(il[837]) - , slice_cnt_shift(il[838]) - , slice_col_offset_shift(il[839]) - , slice_sel_cd_cpy_shift(il[840]) - , slice_sel_mem_active_shift(il[841]) - , slice_sel_return_shift(il[842]) - , slice_sel_start_shift(il[843]) - , slice_space_id_shift(il[844]) + , alu_cmp_gadget_non_ff_gt(il[39]) + , alu_cmp_gadget_result(il[40]) + , alu_cmp_gadget_sel(il[41]) + , alu_ff_tag(il[42]) + , alu_ia(il[43]) + , alu_ib(il[44]) + , alu_ic(il[45]) + , alu_in_tag(il[46]) + , alu_max_bits_sub_b_bits(il[47]) + , alu_max_bits_sub_b_pow(il[48]) + , alu_op_add(il[49]) + , alu_op_cast(il[50]) + , alu_op_div(il[51]) + , alu_op_eq(il[52]) + , alu_op_lt(il[53]) + , alu_op_lte(il[54]) + , alu_op_mul(il[55]) + , alu_op_not(il[56]) + , alu_op_shl(il[57]) + , alu_op_shr(il[58]) + , alu_op_sub(il[59]) + , alu_partial_prod_hi(il[60]) + , alu_partial_prod_lo(il[61]) + , alu_range_check_input_value(il[62]) + , alu_range_check_num_bits(il[63]) + , alu_range_check_sel(il[64]) + , alu_remainder(il[65]) + , alu_sel_alu(il[66]) + , alu_sel_cmp(il[67]) + , alu_sel_shift_which(il[68]) + , alu_u128_tag(il[69]) + , alu_u16_tag(il[70]) + , alu_u1_tag(il[71]) + , alu_u32_tag(il[72]) + , alu_u64_tag(il[73]) + , alu_u8_tag(il[74]) + , alu_zero_shift(il[75]) + , binary_acc_ia(il[76]) + , binary_acc_ib(il[77]) + , binary_acc_ic(il[78]) + , binary_clk(il[79]) + , binary_ia_bytes(il[80]) + , binary_ib_bytes(il[81]) + , binary_ic_bytes(il[82]) + , binary_in_tag(il[83]) + , binary_mem_tag_ctr(il[84]) + , binary_mem_tag_ctr_inv(il[85]) + , binary_op_id(il[86]) + , binary_sel_bin(il[87]) + , binary_start(il[88]) + , bytecode_arifact_hash(il[89]) + , bytecode_as_fields(il[90]) + , bytecode_bytes(il[91]) + , bytecode_bytes_pc(il[92]) + , bytecode_class_id(il[93]) + , bytecode_contract_address(il[94]) + , bytecode_decomposed(il[95]) + , bytecode_deployer_addr(il[96]) + , bytecode_end_latch(il[97]) + , bytecode_incoming_viewing_key_x(il[98]) + , bytecode_incoming_viewing_key_y(il[99]) + , bytecode_initialization_hash(il[100]) + , bytecode_length_remaining(il[101]) + , bytecode_nullifier_key_x(il[102]) + , bytecode_nullifier_key_y(il[103]) + , bytecode_outgoing_viewing_key_x(il[104]) + , bytecode_outgoing_viewing_key_y(il[105]) + , bytecode_private_fn_root(il[106]) + , bytecode_public_key_hash(il[107]) + , bytecode_running_hash(il[108]) + , bytecode_salt(il[109]) + , bytecode_tagging_key_x(il[110]) + , bytecode_tagging_key_y(il[111]) + , cmp_a_hi(il[112]) + , cmp_a_lo(il[113]) + , cmp_b_hi(il[114]) + , cmp_b_lo(il[115]) + , cmp_borrow(il[116]) + , cmp_clk(il[117]) + , cmp_cmp_rng_ctr(il[118]) + , cmp_diff(il[119]) + , cmp_input_a(il[120]) + , cmp_input_b(il[121]) + , cmp_op_eq(il[122]) + , cmp_op_eq_diff_inv(il[123]) + , cmp_op_gt(il[124]) + , cmp_op_non_ff_gt(il[125]) + , cmp_p_a_borrow(il[126]) + , cmp_p_b_borrow(il[127]) + , cmp_p_sub_a_hi(il[128]) + , cmp_p_sub_a_lo(il[129]) + , cmp_p_sub_b_hi(il[130]) + , cmp_p_sub_b_lo(il[131]) + , cmp_range_chk_clk(il[132]) + , cmp_res_hi(il[133]) + , cmp_res_lo(il[134]) + , cmp_result(il[135]) + , cmp_sel_cmp(il[136]) + , cmp_sel_rng_chk(il[137]) + , cmp_shift_sel(il[138]) + , conversion_clk(il[139]) + , conversion_input(il[140]) + , conversion_num_limbs(il[141]) + , conversion_output_bits(il[142]) + , conversion_radix(il[143]) + , conversion_sel_to_radix_be(il[144]) + , keccakf1600_clk(il[145]) + , keccakf1600_input(il[146]) + , keccakf1600_output(il[147]) + , keccakf1600_sel_keccakf1600(il[148]) + , main_abs_da_rem_gas(il[149]) + , main_abs_l2_rem_gas(il[150]) + , main_alu_in_tag(il[151]) + , main_base_da_gas_op_cost(il[152]) + , main_base_l2_gas_op_cost(il[153]) + , main_bin_op_id(il[154]) + , main_call_ptr(il[155]) + , main_da_gas_remaining(il[156]) + , main_da_gas_u16_r0(il[157]) + , main_da_gas_u16_r1(il[158]) + , main_da_out_of_gas(il[159]) + , main_dyn_da_gas_op_cost(il[160]) + , main_dyn_gas_multiplier(il[161]) + , main_dyn_l2_gas_op_cost(il[162]) + , main_emit_l2_to_l1_msg_write_offset(il[163]) + , main_emit_note_hash_write_offset(il[164]) + , main_emit_nullifier_write_offset(il[165]) + , main_emit_unencrypted_log_write_offset(il[166]) + , main_ia(il[167]) + , main_ib(il[168]) + , main_ic(il[169]) + , main_id(il[170]) + , main_id_zero(il[171]) + , main_ind_addr_a(il[172]) + , main_ind_addr_b(il[173]) + , main_ind_addr_c(il[174]) + , main_ind_addr_d(il[175]) + , main_internal_return_ptr(il[176]) + , main_inv(il[177]) + , main_is_fake_row(il[178]) + , main_is_gas_accounted(il[179]) + , main_kernel_in_offset(il[180]) + , main_kernel_out_offset(il[181]) + , main_l1_to_l2_msg_exists_write_offset(il[182]) + , main_l2_gas_remaining(il[183]) + , main_l2_gas_u16_r0(il[184]) + , main_l2_gas_u16_r1(il[185]) + , main_l2_out_of_gas(il[186]) + , main_mem_addr_a(il[187]) + , main_mem_addr_b(il[188]) + , main_mem_addr_c(il[189]) + , main_mem_addr_d(il[190]) + , main_note_hash_exist_write_offset(il[191]) + , main_nullifier_exists_write_offset(il[192]) + , main_nullifier_non_exists_write_offset(il[193]) + , main_op_err(il[194]) + , main_opcode_val(il[195]) + , main_pc(il[196]) + , main_r_in_tag(il[197]) + , main_rwa(il[198]) + , main_rwb(il[199]) + , main_rwc(il[200]) + , main_rwd(il[201]) + , main_sel_alu(il[202]) + , main_sel_bin(il[203]) + , main_sel_calldata(il[204]) + , main_sel_execution_end(il[205]) + , main_sel_execution_row(il[206]) + , main_sel_kernel_inputs(il[207]) + , main_sel_kernel_out(il[208]) + , main_sel_mem_op_a(il[209]) + , main_sel_mem_op_b(il[210]) + , main_sel_mem_op_c(il[211]) + , main_sel_mem_op_d(il[212]) + , main_sel_mov_ia_to_ic(il[213]) + , main_sel_mov_ib_to_ic(il[214]) + , main_sel_op_add(il[215]) + , main_sel_op_address(il[216]) + , main_sel_op_and(il[217]) + , main_sel_op_block_number(il[218]) + , main_sel_op_calldata_copy(il[219]) + , main_sel_op_cast(il[220]) + , main_sel_op_chain_id(il[221]) + , main_sel_op_dagasleft(il[222]) + , main_sel_op_debug_log(il[223]) + , main_sel_op_div(il[224]) + , main_sel_op_ecadd(il[225]) + , main_sel_op_emit_l2_to_l1_msg(il[226]) + , main_sel_op_emit_note_hash(il[227]) + , main_sel_op_emit_nullifier(il[228]) + , main_sel_op_emit_unencrypted_log(il[229]) + , main_sel_op_eq(il[230]) + , main_sel_op_external_call(il[231]) + , main_sel_op_external_return(il[232]) + , main_sel_op_external_revert(il[233]) + , main_sel_op_fdiv(il[234]) + , main_sel_op_fee_per_da_gas(il[235]) + , main_sel_op_fee_per_l2_gas(il[236]) + , main_sel_op_function_selector(il[237]) + , main_sel_op_get_contract_instance(il[238]) + , main_sel_op_internal_call(il[239]) + , main_sel_op_internal_return(il[240]) + , main_sel_op_is_static_call(il[241]) + , main_sel_op_jump(il[242]) + , main_sel_op_jumpi(il[243]) + , main_sel_op_keccak(il[244]) + , main_sel_op_l1_to_l2_msg_exists(il[245]) + , main_sel_op_l2gasleft(il[246]) + , main_sel_op_lt(il[247]) + , main_sel_op_lte(il[248]) + , main_sel_op_mov(il[249]) + , main_sel_op_msm(il[250]) + , main_sel_op_mul(il[251]) + , main_sel_op_not(il[252]) + , main_sel_op_note_hash_exists(il[253]) + , main_sel_op_nullifier_exists(il[254]) + , main_sel_op_or(il[255]) + , main_sel_op_poseidon2(il[256]) + , main_sel_op_radix_be(il[257]) + , main_sel_op_returndata_copy(il[258]) + , main_sel_op_returndata_size(il[259]) + , main_sel_op_sender(il[260]) + , main_sel_op_set(il[261]) + , main_sel_op_sha256(il[262]) + , main_sel_op_shl(il[263]) + , main_sel_op_shr(il[264]) + , main_sel_op_sload(il[265]) + , main_sel_op_sstore(il[266]) + , main_sel_op_static_call(il[267]) + , main_sel_op_sub(il[268]) + , main_sel_op_timestamp(il[269]) + , main_sel_op_transaction_fee(il[270]) + , main_sel_op_version(il[271]) + , main_sel_op_xor(il[272]) + , main_sel_q_kernel_lookup(il[273]) + , main_sel_q_kernel_output_lookup(il[274]) + , main_sel_resolve_ind_addr_a(il[275]) + , main_sel_resolve_ind_addr_b(il[276]) + , main_sel_resolve_ind_addr_c(il[277]) + , main_sel_resolve_ind_addr_d(il[278]) + , main_sel_returndata(il[279]) + , main_sel_rng_16(il[280]) + , main_sel_rng_8(il[281]) + , main_sel_slice_gadget(il[282]) + , main_side_effect_counter(il[283]) + , main_sload_write_offset(il[284]) + , main_space_id(il[285]) + , main_sstore_write_offset(il[286]) + , main_tag_err(il[287]) + , main_w_in_tag(il[288]) + , mem_addr(il[289]) + , mem_clk(il[290]) + , mem_diff(il[291]) + , mem_glob_addr(il[292]) + , mem_last(il[293]) + , mem_lastAccess(il[294]) + , mem_one_min_inv(il[295]) + , mem_r_in_tag(il[296]) + , mem_rw(il[297]) + , mem_sel_mem(il[298]) + , mem_sel_mov_ia_to_ic(il[299]) + , mem_sel_mov_ib_to_ic(il[300]) + , mem_sel_op_a(il[301]) + , mem_sel_op_b(il[302]) + , mem_sel_op_c(il[303]) + , mem_sel_op_d(il[304]) + , mem_sel_op_poseidon_read_a(il[305]) + , mem_sel_op_poseidon_read_b(il[306]) + , mem_sel_op_poseidon_read_c(il[307]) + , mem_sel_op_poseidon_read_d(il[308]) + , mem_sel_op_poseidon_write_a(il[309]) + , mem_sel_op_poseidon_write_b(il[310]) + , mem_sel_op_poseidon_write_c(il[311]) + , mem_sel_op_poseidon_write_d(il[312]) + , mem_sel_op_slice(il[313]) + , mem_sel_resolve_ind_addr_a(il[314]) + , mem_sel_resolve_ind_addr_b(il[315]) + , mem_sel_resolve_ind_addr_c(il[316]) + , mem_sel_resolve_ind_addr_d(il[317]) + , mem_sel_rng_chk(il[318]) + , mem_skip_check_tag(il[319]) + , mem_space_id(il[320]) + , mem_tag(il[321]) + , mem_tag_err(il[322]) + , mem_tsp(il[323]) + , mem_u16_r0(il[324]) + , mem_u16_r1(il[325]) + , mem_u8_r0(il[326]) + , mem_val(il[327]) + , mem_w_in_tag(il[328]) + , merkle_tree_clk(il[329]) + , merkle_tree_expected_tree_root(il[330]) + , merkle_tree_latch(il[331]) + , merkle_tree_leaf_index(il[332]) + , merkle_tree_leaf_index_is_even(il[333]) + , merkle_tree_leaf_value(il[334]) + , merkle_tree_left_hash(il[335]) + , merkle_tree_output_hash(il[336]) + , merkle_tree_path_len(il[337]) + , merkle_tree_path_len_inv(il[338]) + , merkle_tree_right_hash(il[339]) + , merkle_tree_sel_merkle_tree(il[340]) + , merkle_tree_sibling_value(il[341]) + , poseidon2_B_10_0(il[342]) + , poseidon2_B_10_1(il[343]) + , poseidon2_B_10_2(il[344]) + , poseidon2_B_10_3(il[345]) + , poseidon2_B_11_0(il[346]) + , poseidon2_B_11_1(il[347]) + , poseidon2_B_11_2(il[348]) + , poseidon2_B_11_3(il[349]) + , poseidon2_B_12_0(il[350]) + , poseidon2_B_12_1(il[351]) + , poseidon2_B_12_2(il[352]) + , poseidon2_B_12_3(il[353]) + , poseidon2_B_13_0(il[354]) + , poseidon2_B_13_1(il[355]) + , poseidon2_B_13_2(il[356]) + , poseidon2_B_13_3(il[357]) + , poseidon2_B_14_0(il[358]) + , poseidon2_B_14_1(il[359]) + , poseidon2_B_14_2(il[360]) + , poseidon2_B_14_3(il[361]) + , poseidon2_B_15_0(il[362]) + , poseidon2_B_15_1(il[363]) + , poseidon2_B_15_2(il[364]) + , poseidon2_B_15_3(il[365]) + , poseidon2_B_16_0(il[366]) + , poseidon2_B_16_1(il[367]) + , poseidon2_B_16_2(il[368]) + , poseidon2_B_16_3(il[369]) + , poseidon2_B_17_0(il[370]) + , poseidon2_B_17_1(il[371]) + , poseidon2_B_17_2(il[372]) + , poseidon2_B_17_3(il[373]) + , poseidon2_B_18_0(il[374]) + , poseidon2_B_18_1(il[375]) + , poseidon2_B_18_2(il[376]) + , poseidon2_B_18_3(il[377]) + , poseidon2_B_19_0(il[378]) + , poseidon2_B_19_1(il[379]) + , poseidon2_B_19_2(il[380]) + , poseidon2_B_19_3(il[381]) + , poseidon2_B_20_0(il[382]) + , poseidon2_B_20_1(il[383]) + , poseidon2_B_20_2(il[384]) + , poseidon2_B_20_3(il[385]) + , poseidon2_B_21_0(il[386]) + , poseidon2_B_21_1(il[387]) + , poseidon2_B_21_2(il[388]) + , poseidon2_B_21_3(il[389]) + , poseidon2_B_22_0(il[390]) + , poseidon2_B_22_1(il[391]) + , poseidon2_B_22_2(il[392]) + , poseidon2_B_22_3(il[393]) + , poseidon2_B_23_0(il[394]) + , poseidon2_B_23_1(il[395]) + , poseidon2_B_23_2(il[396]) + , poseidon2_B_23_3(il[397]) + , poseidon2_B_24_0(il[398]) + , poseidon2_B_24_1(il[399]) + , poseidon2_B_24_2(il[400]) + , poseidon2_B_24_3(il[401]) + , poseidon2_B_25_0(il[402]) + , poseidon2_B_25_1(il[403]) + , poseidon2_B_25_2(il[404]) + , poseidon2_B_25_3(il[405]) + , poseidon2_B_26_0(il[406]) + , poseidon2_B_26_1(il[407]) + , poseidon2_B_26_2(il[408]) + , poseidon2_B_26_3(il[409]) + , poseidon2_B_27_0(il[410]) + , poseidon2_B_27_1(il[411]) + , poseidon2_B_27_2(il[412]) + , poseidon2_B_27_3(il[413]) + , poseidon2_B_28_0(il[414]) + , poseidon2_B_28_1(il[415]) + , poseidon2_B_28_2(il[416]) + , poseidon2_B_28_3(il[417]) + , poseidon2_B_29_0(il[418]) + , poseidon2_B_29_1(il[419]) + , poseidon2_B_29_2(il[420]) + , poseidon2_B_29_3(il[421]) + , poseidon2_B_30_0(il[422]) + , poseidon2_B_30_1(il[423]) + , poseidon2_B_30_2(il[424]) + , poseidon2_B_30_3(il[425]) + , poseidon2_B_31_0(il[426]) + , poseidon2_B_31_1(il[427]) + , poseidon2_B_31_2(il[428]) + , poseidon2_B_31_3(il[429]) + , poseidon2_B_32_0(il[430]) + , poseidon2_B_32_1(il[431]) + , poseidon2_B_32_2(il[432]) + , poseidon2_B_32_3(il[433]) + , poseidon2_B_33_0(il[434]) + , poseidon2_B_33_1(il[435]) + , poseidon2_B_33_2(il[436]) + , poseidon2_B_33_3(il[437]) + , poseidon2_B_34_0(il[438]) + , poseidon2_B_34_1(il[439]) + , poseidon2_B_34_2(il[440]) + , poseidon2_B_34_3(il[441]) + , poseidon2_B_35_0(il[442]) + , poseidon2_B_35_1(il[443]) + , poseidon2_B_35_2(il[444]) + , poseidon2_B_35_3(il[445]) + , poseidon2_B_36_0(il[446]) + , poseidon2_B_36_1(il[447]) + , poseidon2_B_36_2(il[448]) + , poseidon2_B_36_3(il[449]) + , poseidon2_B_37_0(il[450]) + , poseidon2_B_37_1(il[451]) + , poseidon2_B_37_2(il[452]) + , poseidon2_B_37_3(il[453]) + , poseidon2_B_38_0(il[454]) + , poseidon2_B_38_1(il[455]) + , poseidon2_B_38_2(il[456]) + , poseidon2_B_38_3(il[457]) + , poseidon2_B_39_0(il[458]) + , poseidon2_B_39_1(il[459]) + , poseidon2_B_39_2(il[460]) + , poseidon2_B_39_3(il[461]) + , poseidon2_B_40_0(il[462]) + , poseidon2_B_40_1(il[463]) + , poseidon2_B_40_2(il[464]) + , poseidon2_B_40_3(il[465]) + , poseidon2_B_41_0(il[466]) + , poseidon2_B_41_1(il[467]) + , poseidon2_B_41_2(il[468]) + , poseidon2_B_41_3(il[469]) + , poseidon2_B_42_0(il[470]) + , poseidon2_B_42_1(il[471]) + , poseidon2_B_42_2(il[472]) + , poseidon2_B_42_3(il[473]) + , poseidon2_B_43_0(il[474]) + , poseidon2_B_43_1(il[475]) + , poseidon2_B_43_2(il[476]) + , poseidon2_B_43_3(il[477]) + , poseidon2_B_44_0(il[478]) + , poseidon2_B_44_1(il[479]) + , poseidon2_B_44_2(il[480]) + , poseidon2_B_44_3(il[481]) + , poseidon2_B_45_0(il[482]) + , poseidon2_B_45_1(il[483]) + , poseidon2_B_45_2(il[484]) + , poseidon2_B_45_3(il[485]) + , poseidon2_B_46_0(il[486]) + , poseidon2_B_46_1(il[487]) + , poseidon2_B_46_2(il[488]) + , poseidon2_B_46_3(il[489]) + , poseidon2_B_47_0(il[490]) + , poseidon2_B_47_1(il[491]) + , poseidon2_B_47_2(il[492]) + , poseidon2_B_47_3(il[493]) + , poseidon2_B_48_0(il[494]) + , poseidon2_B_48_1(il[495]) + , poseidon2_B_48_2(il[496]) + , poseidon2_B_48_3(il[497]) + , poseidon2_B_49_0(il[498]) + , poseidon2_B_49_1(il[499]) + , poseidon2_B_49_2(il[500]) + , poseidon2_B_49_3(il[501]) + , poseidon2_B_4_0(il[502]) + , poseidon2_B_4_1(il[503]) + , poseidon2_B_4_2(il[504]) + , poseidon2_B_4_3(il[505]) + , poseidon2_B_50_0(il[506]) + , poseidon2_B_50_1(il[507]) + , poseidon2_B_50_2(il[508]) + , poseidon2_B_50_3(il[509]) + , poseidon2_B_51_0(il[510]) + , poseidon2_B_51_1(il[511]) + , poseidon2_B_51_2(il[512]) + , poseidon2_B_51_3(il[513]) + , poseidon2_B_52_0(il[514]) + , poseidon2_B_52_1(il[515]) + , poseidon2_B_52_2(il[516]) + , poseidon2_B_52_3(il[517]) + , poseidon2_B_53_0(il[518]) + , poseidon2_B_53_1(il[519]) + , poseidon2_B_53_2(il[520]) + , poseidon2_B_53_3(il[521]) + , poseidon2_B_54_0(il[522]) + , poseidon2_B_54_1(il[523]) + , poseidon2_B_54_2(il[524]) + , poseidon2_B_54_3(il[525]) + , poseidon2_B_55_0(il[526]) + , poseidon2_B_55_1(il[527]) + , poseidon2_B_55_2(il[528]) + , poseidon2_B_55_3(il[529]) + , poseidon2_B_56_0(il[530]) + , poseidon2_B_56_1(il[531]) + , poseidon2_B_56_2(il[532]) + , poseidon2_B_56_3(il[533]) + , poseidon2_B_57_0(il[534]) + , poseidon2_B_57_1(il[535]) + , poseidon2_B_57_2(il[536]) + , poseidon2_B_57_3(il[537]) + , poseidon2_B_58_0(il[538]) + , poseidon2_B_58_1(il[539]) + , poseidon2_B_58_2(il[540]) + , poseidon2_B_58_3(il[541]) + , poseidon2_B_59_0(il[542]) + , poseidon2_B_59_1(il[543]) + , poseidon2_B_59_2(il[544]) + , poseidon2_B_59_3(il[545]) + , poseidon2_B_5_0(il[546]) + , poseidon2_B_5_1(il[547]) + , poseidon2_B_5_2(il[548]) + , poseidon2_B_5_3(il[549]) + , poseidon2_B_6_0(il[550]) + , poseidon2_B_6_1(il[551]) + , poseidon2_B_6_2(il[552]) + , poseidon2_B_6_3(il[553]) + , poseidon2_B_7_0(il[554]) + , poseidon2_B_7_1(il[555]) + , poseidon2_B_7_2(il[556]) + , poseidon2_B_7_3(il[557]) + , poseidon2_B_8_0(il[558]) + , poseidon2_B_8_1(il[559]) + , poseidon2_B_8_2(il[560]) + , poseidon2_B_8_3(il[561]) + , poseidon2_B_9_0(il[562]) + , poseidon2_B_9_1(il[563]) + , poseidon2_B_9_2(il[564]) + , poseidon2_B_9_3(il[565]) + , poseidon2_EXT_LAYER_4(il[566]) + , poseidon2_EXT_LAYER_5(il[567]) + , poseidon2_EXT_LAYER_6(il[568]) + , poseidon2_EXT_LAYER_7(il[569]) + , poseidon2_T_0_4(il[570]) + , poseidon2_T_0_5(il[571]) + , poseidon2_T_0_6(il[572]) + , poseidon2_T_0_7(il[573]) + , poseidon2_T_1_4(il[574]) + , poseidon2_T_1_5(il[575]) + , poseidon2_T_1_6(il[576]) + , poseidon2_T_1_7(il[577]) + , poseidon2_T_2_4(il[578]) + , poseidon2_T_2_5(il[579]) + , poseidon2_T_2_6(il[580]) + , poseidon2_T_2_7(il[581]) + , poseidon2_T_3_4(il[582]) + , poseidon2_T_3_5(il[583]) + , poseidon2_T_3_6(il[584]) + , poseidon2_T_3_7(il[585]) + , poseidon2_T_60_4(il[586]) + , poseidon2_T_60_5(il[587]) + , poseidon2_T_60_6(il[588]) + , poseidon2_T_60_7(il[589]) + , poseidon2_T_61_4(il[590]) + , poseidon2_T_61_5(il[591]) + , poseidon2_T_61_6(il[592]) + , poseidon2_T_61_7(il[593]) + , poseidon2_T_62_4(il[594]) + , poseidon2_T_62_5(il[595]) + , poseidon2_T_62_6(il[596]) + , poseidon2_T_62_7(il[597]) + , poseidon2_T_63_4(il[598]) + , poseidon2_T_63_5(il[599]) + , poseidon2_T_63_6(il[600]) + , poseidon2_T_63_7(il[601]) + , poseidon2_a_0(il[602]) + , poseidon2_a_1(il[603]) + , poseidon2_a_2(il[604]) + , poseidon2_a_3(il[605]) + , poseidon2_b_0(il[606]) + , poseidon2_b_1(il[607]) + , poseidon2_b_2(il[608]) + , poseidon2_b_3(il[609]) + , poseidon2_clk(il[610]) + , poseidon2_full_a_0(il[611]) + , poseidon2_full_a_1(il[612]) + , poseidon2_full_a_2(il[613]) + , poseidon2_full_a_3(il[614]) + , poseidon2_full_b_0(il[615]) + , poseidon2_full_b_1(il[616]) + , poseidon2_full_b_2(il[617]) + , poseidon2_full_b_3(il[618]) + , poseidon2_full_clk(il[619]) + , poseidon2_full_end_poseidon(il[620]) + , poseidon2_full_execute_poseidon_perm(il[621]) + , poseidon2_full_input_0(il[622]) + , poseidon2_full_input_1(il[623]) + , poseidon2_full_input_2(il[624]) + , poseidon2_full_input_len(il[625]) + , poseidon2_full_num_perm_rounds_rem(il[626]) + , poseidon2_full_num_perm_rounds_rem_inv(il[627]) + , poseidon2_full_output(il[628]) + , poseidon2_full_padding(il[629]) + , poseidon2_full_sel_merkle_tree(il[630]) + , poseidon2_full_sel_poseidon(il[631]) + , poseidon2_full_start_poseidon(il[632]) + , poseidon2_input_addr(il[633]) + , poseidon2_mem_addr_read_a(il[634]) + , poseidon2_mem_addr_read_b(il[635]) + , poseidon2_mem_addr_read_c(il[636]) + , poseidon2_mem_addr_read_d(il[637]) + , poseidon2_mem_addr_write_a(il[638]) + , poseidon2_mem_addr_write_b(il[639]) + , poseidon2_mem_addr_write_c(il[640]) + , poseidon2_mem_addr_write_d(il[641]) + , poseidon2_output_addr(il[642]) + , poseidon2_sel_poseidon_perm(il[643]) + , poseidon2_sel_poseidon_perm_immediate(il[644]) + , poseidon2_sel_poseidon_perm_mem_op(il[645]) + , poseidon2_space_id(il[646]) + , range_check_alu_rng_chk(il[647]) + , range_check_clk(il[648]) + , range_check_cmp_hi_bits_rng_chk(il[649]) + , range_check_cmp_lo_bits_rng_chk(il[650]) + , range_check_cmp_non_ff_rng_chk(il[651]) + , range_check_dyn_diff(il[652]) + , range_check_dyn_rng_chk_bits(il[653]) + , range_check_dyn_rng_chk_pow_2(il[654]) + , range_check_gas_da_rng_chk(il[655]) + , range_check_gas_l2_rng_chk(il[656]) + , range_check_is_lte_u112(il[657]) + , range_check_is_lte_u128(il[658]) + , range_check_is_lte_u16(il[659]) + , range_check_is_lte_u32(il[660]) + , range_check_is_lte_u48(il[661]) + , range_check_is_lte_u64(il[662]) + , range_check_is_lte_u80(il[663]) + , range_check_is_lte_u96(il[664]) + , range_check_rng_chk_bits(il[665]) + , range_check_sel_lookup_0(il[666]) + , range_check_sel_lookup_1(il[667]) + , range_check_sel_lookup_2(il[668]) + , range_check_sel_lookup_3(il[669]) + , range_check_sel_lookup_4(il[670]) + , range_check_sel_lookup_5(il[671]) + , range_check_sel_lookup_6(il[672]) + , range_check_sel_rng_chk(il[673]) + , range_check_u16_r0(il[674]) + , range_check_u16_r1(il[675]) + , range_check_u16_r2(il[676]) + , range_check_u16_r3(il[677]) + , range_check_u16_r4(il[678]) + , range_check_u16_r5(il[679]) + , range_check_u16_r6(il[680]) + , range_check_u16_r7(il[681]) + , range_check_value(il[682]) + , sha256_clk(il[683]) + , sha256_input(il[684]) + , sha256_output(il[685]) + , sha256_sel_sha256_compression(il[686]) + , sha256_state(il[687]) + , slice_addr(il[688]) + , slice_clk(il[689]) + , slice_cnt(il[690]) + , slice_col_offset(il[691]) + , slice_one_min_inv(il[692]) + , slice_sel_cd_cpy(il[693]) + , slice_sel_mem_active(il[694]) + , slice_sel_return(il[695]) + , slice_sel_start(il[696]) + , slice_space_id(il[697]) + , slice_val(il[698]) + , lookup_rng_chk_pow_2_counts(il[699]) + , lookup_rng_chk_diff_counts(il[700]) + , lookup_rng_chk_0_counts(il[701]) + , lookup_rng_chk_1_counts(il[702]) + , lookup_rng_chk_2_counts(il[703]) + , lookup_rng_chk_3_counts(il[704]) + , lookup_rng_chk_4_counts(il[705]) + , lookup_rng_chk_5_counts(il[706]) + , lookup_rng_chk_6_counts(il[707]) + , lookup_rng_chk_7_counts(il[708]) + , lookup_mem_rng_chk_0_counts(il[709]) + , lookup_mem_rng_chk_1_counts(il[710]) + , lookup_mem_rng_chk_2_counts(il[711]) + , lookup_pow_2_0_counts(il[712]) + , lookup_pow_2_1_counts(il[713]) + , lookup_byte_lengths_counts(il[714]) + , lookup_byte_operations_counts(il[715]) + , lookup_opcode_gas_counts(il[716]) + , lookup_l2_gas_rng_chk_0_counts(il[717]) + , lookup_l2_gas_rng_chk_1_counts(il[718]) + , lookup_da_gas_rng_chk_0_counts(il[719]) + , lookup_da_gas_rng_chk_1_counts(il[720]) + , kernel_output_lookup_counts(il[721]) + , lookup_into_kernel_counts(il[722]) + , lookup_cd_value_counts(il[723]) + , lookup_ret_value_counts(il[724]) + , incl_main_tag_err_counts(il[725]) + , incl_mem_tag_err_counts(il[726]) + , perm_rng_non_ff_cmp_inv(il[727]) + , perm_rng_cmp_lo_inv(il[728]) + , perm_rng_cmp_hi_inv(il[729]) + , perm_rng_alu_inv(il[730]) + , perm_cmp_alu_inv(il[731]) + , perm_l2_start_gas_inv(il[732]) + , perm_da_start_gas_inv(il[733]) + , perm_l2_end_gas_inv(il[734]) + , perm_da_end_gas_inv(il[735]) + , perm_pos_mem_read_a_inv(il[736]) + , perm_pos_mem_read_b_inv(il[737]) + , perm_pos_mem_read_c_inv(il[738]) + , perm_pos_mem_read_d_inv(il[739]) + , perm_pos_mem_write_a_inv(il[740]) + , perm_pos_mem_write_b_inv(il[741]) + , perm_pos_mem_write_c_inv(il[742]) + , perm_pos_mem_write_d_inv(il[743]) + , perm_pos2_fixed_pos2_perm_inv(il[744]) + , perm_slice_mem_inv(il[745]) + , perm_merkle_poseidon2_inv(il[746]) + , perm_main_alu_inv(il[747]) + , perm_main_bin_inv(il[748]) + , perm_main_conv_inv(il[749]) + , perm_main_sha256_inv(il[750]) + , perm_main_pos2_perm_inv(il[751]) + , perm_main_slice_inv(il[752]) + , perm_main_mem_a_inv(il[753]) + , perm_main_mem_b_inv(il[754]) + , perm_main_mem_c_inv(il[755]) + , perm_main_mem_d_inv(il[756]) + , perm_main_mem_ind_addr_a_inv(il[757]) + , perm_main_mem_ind_addr_b_inv(il[758]) + , perm_main_mem_ind_addr_c_inv(il[759]) + , perm_main_mem_ind_addr_d_inv(il[760]) + , lookup_rng_chk_pow_2_inv(il[761]) + , lookup_rng_chk_diff_inv(il[762]) + , lookup_rng_chk_0_inv(il[763]) + , lookup_rng_chk_1_inv(il[764]) + , lookup_rng_chk_2_inv(il[765]) + , lookup_rng_chk_3_inv(il[766]) + , lookup_rng_chk_4_inv(il[767]) + , lookup_rng_chk_5_inv(il[768]) + , lookup_rng_chk_6_inv(il[769]) + , lookup_rng_chk_7_inv(il[770]) + , lookup_mem_rng_chk_0_inv(il[771]) + , lookup_mem_rng_chk_1_inv(il[772]) + , lookup_mem_rng_chk_2_inv(il[773]) + , lookup_pow_2_0_inv(il[774]) + , lookup_pow_2_1_inv(il[775]) + , lookup_byte_lengths_inv(il[776]) + , lookup_byte_operations_inv(il[777]) + , lookup_opcode_gas_inv(il[778]) + , lookup_l2_gas_rng_chk_0_inv(il[779]) + , lookup_l2_gas_rng_chk_1_inv(il[780]) + , lookup_da_gas_rng_chk_0_inv(il[781]) + , lookup_da_gas_rng_chk_1_inv(il[782]) + , kernel_output_lookup_inv(il[783]) + , lookup_into_kernel_inv(il[784]) + , lookup_cd_value_inv(il[785]) + , lookup_ret_value_inv(il[786]) + , incl_main_tag_err_inv(il[787]) + , incl_mem_tag_err_inv(il[788]) + , binary_acc_ia_shift(il[789]) + , binary_acc_ib_shift(il[790]) + , binary_acc_ic_shift(il[791]) + , binary_mem_tag_ctr_shift(il[792]) + , binary_op_id_shift(il[793]) + , cmp_a_hi_shift(il[794]) + , cmp_a_lo_shift(il[795]) + , cmp_b_hi_shift(il[796]) + , cmp_b_lo_shift(il[797]) + , cmp_cmp_rng_ctr_shift(il[798]) + , cmp_op_gt_shift(il[799]) + , cmp_p_sub_a_hi_shift(il[800]) + , cmp_p_sub_a_lo_shift(il[801]) + , cmp_p_sub_b_hi_shift(il[802]) + , cmp_p_sub_b_lo_shift(il[803]) + , cmp_sel_rng_chk_shift(il[804]) + , main_da_gas_remaining_shift(il[805]) + , main_emit_l2_to_l1_msg_write_offset_shift(il[806]) + , main_emit_note_hash_write_offset_shift(il[807]) + , main_emit_nullifier_write_offset_shift(il[808]) + , main_emit_unencrypted_log_write_offset_shift(il[809]) + , main_internal_return_ptr_shift(il[810]) + , main_l1_to_l2_msg_exists_write_offset_shift(il[811]) + , main_l2_gas_remaining_shift(il[812]) + , main_note_hash_exist_write_offset_shift(il[813]) + , main_nullifier_exists_write_offset_shift(il[814]) + , main_nullifier_non_exists_write_offset_shift(il[815]) + , main_pc_shift(il[816]) + , main_sel_execution_end_shift(il[817]) + , main_sel_execution_row_shift(il[818]) + , main_sload_write_offset_shift(il[819]) + , main_sstore_write_offset_shift(il[820]) + , mem_glob_addr_shift(il[821]) + , mem_rw_shift(il[822]) + , mem_sel_mem_shift(il[823]) + , mem_tag_shift(il[824]) + , mem_tsp_shift(il[825]) + , mem_val_shift(il[826]) + , merkle_tree_leaf_index_shift(il[827]) + , merkle_tree_leaf_value_shift(il[828]) + , merkle_tree_path_len_shift(il[829]) + , poseidon2_full_a_0_shift(il[830]) + , poseidon2_full_a_1_shift(il[831]) + , poseidon2_full_a_2_shift(il[832]) + , poseidon2_full_a_3_shift(il[833]) + , poseidon2_full_execute_poseidon_perm_shift(il[834]) + , poseidon2_full_input_0_shift(il[835]) + , poseidon2_full_input_1_shift(il[836]) + , poseidon2_full_input_2_shift(il[837]) + , poseidon2_full_num_perm_rounds_rem_shift(il[838]) + , poseidon2_full_sel_poseidon_shift(il[839]) + , poseidon2_full_start_poseidon_shift(il[840]) + , slice_addr_shift(il[841]) + , slice_clk_shift(il[842]) + , slice_cnt_shift(il[843]) + , slice_col_offset_shift(il[844]) + , slice_sel_cd_cpy_shift(il[845]) + , slice_sel_mem_active_shift(il[846]) + , slice_sel_return_shift(il[847]) + , slice_sel_start_shift(il[848]) + , slice_space_id_shift(il[849]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) @@ -905,6 +910,7 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id alu_cmp_gadget_gt[row_idx], alu_cmp_gadget_input_a[row_idx], alu_cmp_gadget_input_b[row_idx], + alu_cmp_gadget_non_ff_gt[row_idx], alu_cmp_gadget_result[row_idx], alu_cmp_gadget_sel[row_idx], alu_ff_tag[row_idx], @@ -984,11 +990,13 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id cmp_borrow[row_idx], cmp_clk[row_idx], cmp_cmp_rng_ctr[row_idx], + cmp_diff[row_idx], cmp_input_a[row_idx], cmp_input_b[row_idx], cmp_op_eq[row_idx], cmp_op_eq_diff_inv[row_idx], cmp_op_gt[row_idx], + cmp_op_non_ff_gt[row_idx], cmp_p_a_borrow[row_idx], cmp_p_b_borrow[row_idx], cmp_p_sub_a_hi[row_idx], @@ -1514,6 +1522,7 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id range_check_clk[row_idx], range_check_cmp_hi_bits_rng_chk[row_idx], range_check_cmp_lo_bits_rng_chk[row_idx], + range_check_cmp_non_ff_rng_chk[row_idx], range_check_dyn_diff[row_idx], range_check_dyn_rng_chk_bits[row_idx], range_check_dyn_rng_chk_pow_2[row_idx], @@ -1589,6 +1598,7 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id lookup_ret_value_counts[row_idx], incl_main_tag_err_counts[row_idx], incl_mem_tag_err_counts[row_idx], + perm_rng_non_ff_cmp_inv[row_idx], perm_rng_cmp_lo_inv[row_idx], perm_rng_cmp_hi_inv[row_idx], perm_rng_alu_inv[row_idx], @@ -1754,6 +1764,7 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::alu_cmp_gadget_gt = "ALU_CMP_GADGET_GT"; Base::alu_cmp_gadget_input_a = "ALU_CMP_GADGET_INPUT_A"; Base::alu_cmp_gadget_input_b = "ALU_CMP_GADGET_INPUT_B"; + Base::alu_cmp_gadget_non_ff_gt = "ALU_CMP_GADGET_NON_FF_GT"; Base::alu_cmp_gadget_result = "ALU_CMP_GADGET_RESULT"; Base::alu_cmp_gadget_sel = "ALU_CMP_GADGET_SEL"; Base::alu_ff_tag = "ALU_FF_TAG"; @@ -1833,11 +1844,13 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::cmp_borrow = "CMP_BORROW"; Base::cmp_clk = "CMP_CLK"; Base::cmp_cmp_rng_ctr = "CMP_CMP_RNG_CTR"; + Base::cmp_diff = "CMP_DIFF"; Base::cmp_input_a = "CMP_INPUT_A"; Base::cmp_input_b = "CMP_INPUT_B"; Base::cmp_op_eq = "CMP_OP_EQ"; Base::cmp_op_eq_diff_inv = "CMP_OP_EQ_DIFF_INV"; Base::cmp_op_gt = "CMP_OP_GT"; + Base::cmp_op_non_ff_gt = "CMP_OP_NON_FF_GT"; Base::cmp_p_a_borrow = "CMP_P_A_BORROW"; Base::cmp_p_b_borrow = "CMP_P_B_BORROW"; Base::cmp_p_sub_a_hi = "CMP_P_SUB_A_HI"; @@ -2363,6 +2376,7 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::range_check_clk = "RANGE_CHECK_CLK"; Base::range_check_cmp_hi_bits_rng_chk = "RANGE_CHECK_CMP_HI_BITS_RNG_CHK"; Base::range_check_cmp_lo_bits_rng_chk = "RANGE_CHECK_CMP_LO_BITS_RNG_CHK"; + Base::range_check_cmp_non_ff_rng_chk = "RANGE_CHECK_CMP_NON_FF_RNG_CHK"; Base::range_check_dyn_diff = "RANGE_CHECK_DYN_DIFF"; Base::range_check_dyn_rng_chk_bits = "RANGE_CHECK_DYN_RNG_CHK_BITS"; Base::range_check_dyn_rng_chk_pow_2 = "RANGE_CHECK_DYN_RNG_CHK_POW_2"; @@ -2410,6 +2424,7 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::slice_sel_start = "SLICE_SEL_START"; Base::slice_space_id = "SLICE_SPACE_ID"; Base::slice_val = "SLICE_VAL"; + Base::perm_rng_non_ff_cmp_inv = "PERM_RNG_NON_FF_CMP_INV"; Base::perm_rng_cmp_lo_inv = "PERM_RNG_CMP_LO_INV"; Base::perm_rng_cmp_hi_inv = "PERM_RNG_CMP_HI_INV"; Base::perm_rng_alu_inv = "PERM_RNG_ALU_INV"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index 11a849f85c44..103f23375d9b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -94,6 +94,7 @@ #include "barretenberg/vm/avm/generated/relations/perm_rng_alu.hpp" #include "barretenberg/vm/avm/generated/relations/perm_rng_cmp_hi.hpp" #include "barretenberg/vm/avm/generated/relations/perm_rng_cmp_lo.hpp" +#include "barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp" #include "barretenberg/vm/avm/generated/relations/perm_slice_mem.hpp" // Metaprogramming to concatenate tuple types. @@ -102,8 +103,8 @@ template using tuple_cat_t = decltype(std::tuple_cat(std:: // The entities that will be used in the flavor. // clang-format off #define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_da_end_gas_kernel_input, main_sel_da_start_gas_kernel_input, main_sel_first, main_sel_l2_end_gas_kernel_input, main_sel_l2_start_gas_kernel_input, main_sel_start_exec, main_zeroes, powers_power_of_2 -#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_gas_u16_r0, main_da_gas_u16_r1, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_gas_u16_r0, main_l2_gas_u16_r1, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_debug_log, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_returndata_copy, main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_u16_r0, mem_u16_r1, mem_u8_r0, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_mem_rng_chk_0_counts, lookup_mem_rng_chk_1_counts, lookup_mem_rng_chk_2_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, lookup_l2_gas_rng_chk_0_counts, lookup_l2_gas_rng_chk_1_counts, lookup_da_gas_rng_chk_0_counts, lookup_da_gas_rng_chk_1_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts -#define DERIVED_WITNESS_ENTITIES perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_l2_start_gas_inv, perm_da_start_gas_inv, perm_l2_end_gas_inv, perm_da_end_gas_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_pos2_fixed_pos2_perm_inv, perm_slice_mem_inv, perm_merkle_poseidon2_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_sha256_inv, perm_main_pos2_perm_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_mem_rng_chk_0_inv, lookup_mem_rng_chk_1_inv, lookup_mem_rng_chk_2_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, lookup_l2_gas_rng_chk_0_inv, lookup_l2_gas_rng_chk_1_inv, lookup_da_gas_rng_chk_0_inv, lookup_da_gas_rng_chk_1_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv +#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_non_ff_gt, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_diff, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_op_non_ff_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_gas_u16_r0, main_da_gas_u16_r1, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_gas_u16_r0, main_l2_gas_u16_r1, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_debug_log, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_returndata_copy, main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_u16_r0, mem_u16_r1, mem_u8_r0, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_cmp_non_ff_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_mem_rng_chk_0_counts, lookup_mem_rng_chk_1_counts, lookup_mem_rng_chk_2_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, lookup_l2_gas_rng_chk_0_counts, lookup_l2_gas_rng_chk_1_counts, lookup_da_gas_rng_chk_0_counts, lookup_da_gas_rng_chk_1_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts +#define DERIVED_WITNESS_ENTITIES perm_rng_non_ff_cmp_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_l2_start_gas_inv, perm_da_start_gas_inv, perm_l2_end_gas_inv, perm_da_end_gas_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_pos2_fixed_pos2_perm_inv, perm_slice_mem_inv, perm_merkle_poseidon2_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_sha256_inv, perm_main_pos2_perm_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_mem_rng_chk_0_inv, lookup_mem_rng_chk_1_inv, lookup_mem_rng_chk_2_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, lookup_l2_gas_rng_chk_0_inv, lookup_l2_gas_rng_chk_1_inv, lookup_da_gas_rng_chk_0_inv, lookup_da_gas_rng_chk_1_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv #define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_end_shift, main_sel_execution_row_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, merkle_tree_leaf_index_shift, merkle_tree_leaf_value_shift, merkle_tree_path_len_shift, poseidon2_full_a_0_shift, poseidon2_full_a_1_shift, poseidon2_full_a_2_shift, poseidon2_full_a_3_shift, poseidon2_full_execute_poseidon_perm_shift, poseidon2_full_input_0_shift, poseidon2_full_input_1_shift, poseidon2_full_input_2_shift, poseidon2_full_num_perm_rounds_rem_shift, poseidon2_full_sel_poseidon_shift, poseidon2_full_start_poseidon_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift #define TO_BE_SHIFTED(e) e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_end, e.main_sel_execution_row, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.merkle_tree_leaf_index, e.merkle_tree_leaf_value, e.merkle_tree_path_len, e.poseidon2_full_a_0, e.poseidon2_full_a_1, e.poseidon2_full_a_2, e.poseidon2_full_a_3, e.poseidon2_full_execute_poseidon_perm, e.poseidon2_full_input_0, e.poseidon2_full_input_1, e.poseidon2_full_input_2, e.poseidon2_full_num_perm_rounds_rem, e.poseidon2_full_sel_poseidon, e.poseidon2_full_start_poseidon, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id #define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES @@ -131,12 +132,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 21; - static constexpr size_t NUM_WITNESS_ENTITIES = 763; + static constexpr size_t NUM_WITNESS_ENTITIES = 768; static constexpr size_t NUM_SHIFTED_ENTITIES = 61; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 845; + static constexpr size_t NUM_ALL_ENTITIES = 850; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES; @@ -227,6 +228,7 @@ class AvmFlavor { perm_rng_alu_relation, perm_rng_cmp_hi_relation, perm_rng_cmp_lo_relation, + perm_rng_non_ff_cmp_relation, perm_slice_mem_relation>; using LookupRelations = LookupRelations_; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp index 7da7e623f3d0..c38c8e849b0e 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp @@ -58,6 +58,7 @@ template std::vector AvmFullRow::names() "alu_cmp_gadget_gt", "alu_cmp_gadget_input_a", "alu_cmp_gadget_input_b", + "alu_cmp_gadget_non_ff_gt", "alu_cmp_gadget_result", "alu_cmp_gadget_sel", "alu_ff_tag", @@ -137,11 +138,13 @@ template std::vector AvmFullRow::names() "cmp_borrow", "cmp_clk", "cmp_cmp_rng_ctr", + "cmp_diff", "cmp_input_a", "cmp_input_b", "cmp_op_eq", "cmp_op_eq_diff_inv", "cmp_op_gt", + "cmp_op_non_ff_gt", "cmp_p_a_borrow", "cmp_p_b_borrow", "cmp_p_sub_a_hi", @@ -667,6 +670,7 @@ template std::vector AvmFullRow::names() "range_check_clk", "range_check_cmp_hi_bits_rng_chk", "range_check_cmp_lo_bits_rng_chk", + "range_check_cmp_non_ff_rng_chk", "range_check_dyn_diff", "range_check_dyn_rng_chk_bits", "range_check_dyn_rng_chk_pow_2", @@ -714,6 +718,7 @@ template std::vector AvmFullRow::names() "slice_sel_start", "slice_space_id", "slice_val", + "perm_rng_non_ff_cmp_inv", "perm_rng_cmp_lo_inv", "perm_rng_cmp_hi_inv", "perm_rng_alu_inv", @@ -847,6 +852,7 @@ template RefVector AvmFullRow::as_vector() const alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, + alu_cmp_gadget_non_ff_gt, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, @@ -926,11 +932,13 @@ template RefVector AvmFullRow::as_vector() const cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, + cmp_diff, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, + cmp_op_non_ff_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, @@ -1456,6 +1464,7 @@ template RefVector AvmFullRow::as_vector() const range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, + range_check_cmp_non_ff_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, @@ -1503,6 +1512,7 @@ template RefVector AvmFullRow::as_vector() const slice_sel_start, slice_space_id, slice_val, + perm_rng_non_ff_cmp_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp index 42dd696e1b79..028645e90be9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp @@ -49,6 +49,7 @@ template struct AvmFullRow { FF alu_cmp_gadget_gt{}; FF alu_cmp_gadget_input_a{}; FF alu_cmp_gadget_input_b{}; + FF alu_cmp_gadget_non_ff_gt{}; FF alu_cmp_gadget_result{}; FF alu_cmp_gadget_sel{}; FF alu_ff_tag{}; @@ -128,11 +129,13 @@ template struct AvmFullRow { FF cmp_borrow{}; FF cmp_clk{}; FF cmp_cmp_rng_ctr{}; + FF cmp_diff{}; FF cmp_input_a{}; FF cmp_input_b{}; FF cmp_op_eq{}; FF cmp_op_eq_diff_inv{}; FF cmp_op_gt{}; + FF cmp_op_non_ff_gt{}; FF cmp_p_a_borrow{}; FF cmp_p_b_borrow{}; FF cmp_p_sub_a_hi{}; @@ -658,6 +661,7 @@ template struct AvmFullRow { FF range_check_clk{}; FF range_check_cmp_hi_bits_rng_chk{}; FF range_check_cmp_lo_bits_rng_chk{}; + FF range_check_cmp_non_ff_rng_chk{}; FF range_check_dyn_diff{}; FF range_check_dyn_rng_chk_bits{}; FF range_check_dyn_rng_chk_pow_2{}; @@ -705,6 +709,7 @@ template struct AvmFullRow { FF slice_sel_start{}; FF slice_space_id{}; FF slice_val{}; + FF perm_rng_non_ff_cmp_inv{}; FF perm_rng_cmp_lo_inv{}; FF perm_rng_cmp_hi_inv{}; FF perm_rng_alu_inv{}; @@ -798,7 +803,7 @@ template struct AvmFullRow { RefVector as_vector() const; static std::vector names(); - static constexpr size_t SIZE = 784; + static constexpr size_t SIZE = 789; }; template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp index abc0a44ddb77..bde7a1f816a1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/alu.hpp @@ -10,10 +10,10 @@ template class aluImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 4, - 2, 2, 3, 3, 4, 4, 5, 5, 5, 4, 7, 3, 3, - 3, 5, 5, 4, 7, 4, 3, 3, 3, 2, 3, 3, 3, - 4, 3, 3, 3, 3, 3, 4, 4, 4, 5 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 4, + 3, 3, 2, 3, 3, 4, 4, 5, 5, 5, 4, 7, 3, + 3, 3, 5, 5, 4, 7, 4, 3, 3, 3, 2, 3, 3, + 3, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -28,6 +28,9 @@ template class aluImpl { const auto constants_MEM_TAG_U32 = FF(4); const auto constants_MEM_TAG_U64 = FF(5); const auto constants_MEM_TAG_U128 = FF(6); + const auto alu_CMP_GADGET_GT = + ((((new_term.alu_op_lt + new_term.alu_op_lte) + new_term.alu_op_div) + new_term.alu_op_shr) + + new_term.alu_op_shl); const auto alu_MAX_BITS = ((((((new_term.alu_u1_tag * FF(1)) + (new_term.alu_u8_tag * FF(8))) + (new_term.alu_u16_tag * FF(16))) + (new_term.alu_u32_tag * FF(32))) + @@ -175,242 +178,247 @@ template class aluImpl { } { using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; - auto tmp = (new_term.alu_cmp_gadget_gt - - ((((new_term.alu_op_lt + new_term.alu_op_lte) + new_term.alu_op_div) + new_term.alu_op_shr) + - new_term.alu_op_shl)); + auto tmp = (new_term.alu_cmp_gadget_gt - (alu_CMP_GADGET_GT * new_term.alu_ff_tag)); tmp *= scaling_factor; std::get<13>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; - auto tmp = (new_term.alu_cmp_gadget_sel - (new_term.alu_cmp_gadget_gt + new_term.alu_op_eq)); + auto tmp = (new_term.alu_cmp_gadget_non_ff_gt - (alu_CMP_GADGET_GT * (FF(1) - new_term.alu_ff_tag))); tmp *= scaling_factor; std::get<14>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; - auto tmp = (((new_term.alu_a_lo * new_term.alu_b_hi) + (new_term.alu_b_lo * new_term.alu_a_hi)) - - (new_term.alu_partial_prod_lo + (alu_LIMB_BITS_POW * new_term.alu_partial_prod_hi))); + auto tmp = (new_term.alu_cmp_gadget_sel - + ((new_term.alu_cmp_gadget_gt + new_term.alu_op_eq) + new_term.alu_cmp_gadget_non_ff_gt)); tmp *= scaling_factor; std::get<15>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; - auto tmp = (new_term.alu_cf * (FF(1) - new_term.alu_cf)); + auto tmp = (((new_term.alu_a_lo * new_term.alu_b_hi) + (new_term.alu_b_lo * new_term.alu_a_hi)) - + (new_term.alu_partial_prod_lo + (alu_LIMB_BITS_POW * new_term.alu_partial_prod_hi))); tmp *= scaling_factor; std::get<16>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_add * ((alu_RESULT - new_term.alu_ic) - (new_term.alu_cf * alu_MAX_BITS_POW))); + auto tmp = (new_term.alu_cf * (FF(1) - new_term.alu_cf)); tmp *= scaling_factor; std::get<17>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_sub * ((alu_RESULT - new_term.alu_ic) + (new_term.alu_cf * alu_MAX_BITS_POW))); + auto tmp = (new_term.alu_op_add * ((alu_RESULT - new_term.alu_ic) - (new_term.alu_cf * alu_MAX_BITS_POW))); tmp *= scaling_factor; std::get<18>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; - auto tmp = - ((new_term.alu_ff_tag * new_term.alu_op_mul) * ((new_term.alu_ia * new_term.alu_ib) - new_term.alu_ic)); + auto tmp = (new_term.alu_op_sub * ((alu_RESULT - new_term.alu_ic) + (new_term.alu_cf * alu_MAX_BITS_POW))); tmp *= scaling_factor; std::get<19>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * - ((new_term.alu_ia - new_term.alu_a_lo) - (alu_LIMB_BITS_POW * new_term.alu_a_hi))); + auto tmp = + ((new_term.alu_ff_tag * new_term.alu_op_mul) * ((new_term.alu_ia * new_term.alu_ib) - new_term.alu_ic)); tmp *= scaling_factor; std::get<20>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * - ((new_term.alu_ib - new_term.alu_b_lo) - (alu_LIMB_BITS_POW * new_term.alu_b_hi))); + ((new_term.alu_ia - new_term.alu_a_lo) - (alu_LIMB_BITS_POW * new_term.alu_a_hi))); tmp *= scaling_factor; std::get<21>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<22, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * (new_term.alu_ic - new_term.alu_c_lo)); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * + ((new_term.alu_ib - new_term.alu_b_lo) - (alu_LIMB_BITS_POW * new_term.alu_b_hi))); tmp *= scaling_factor; std::get<22>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<23, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * - (alu_PRODUCT - (new_term.alu_c_lo + (alu_MAX_BITS_POW * new_term.alu_c_hi)))); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * (new_term.alu_ic - new_term.alu_c_lo)); tmp *= scaling_factor; std::get<23>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_input_a - new_term.alu_ib)); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_mul) * + (alu_PRODUCT - (new_term.alu_c_lo + (alu_MAX_BITS_POW * new_term.alu_c_hi)))); tmp *= scaling_factor; std::get<24>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<25, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_input_b - new_term.alu_remainder)); + auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_input_a - new_term.alu_ib)); tmp *= scaling_factor; std::get<25>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<26, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_result - FF(1))); + auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_input_b - new_term.alu_remainder)); tmp *= scaling_factor; std::get<26>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<27, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * - ((new_term.alu_ib - new_term.alu_a_lo) - (alu_LIMB_BITS_POW * new_term.alu_a_hi))); + auto tmp = (new_term.alu_op_div * (new_term.alu_cmp_gadget_result - FF(1))); tmp *= scaling_factor; std::get<27>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<28, ContainerOverSubrelations>; auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * - ((new_term.alu_ic - new_term.alu_b_lo) - (alu_LIMB_BITS_POW * new_term.alu_b_hi))); + ((new_term.alu_ib - new_term.alu_a_lo) - (alu_LIMB_BITS_POW * new_term.alu_a_hi))); tmp *= scaling_factor; std::get<28>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<29, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * (new_term.alu_ia - new_term.alu_c_lo)); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * + ((new_term.alu_ic - new_term.alu_b_lo) - (alu_LIMB_BITS_POW * new_term.alu_b_hi))); tmp *= scaling_factor; std::get<29>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<30, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * - (alu_PRODUCT - - ((new_term.alu_c_lo - new_term.alu_remainder) + (alu_MAX_BITS_POW * new_term.alu_c_hi)))); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * (new_term.alu_ia - new_term.alu_c_lo)); tmp *= scaling_factor; std::get<30>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<31, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_not) * - ((new_term.alu_ia + new_term.alu_ic) - alu_UINT_MAX)); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_div) * + (alu_PRODUCT - + ((new_term.alu_c_lo - new_term.alu_remainder) + (alu_MAX_BITS_POW * new_term.alu_c_hi)))); tmp *= scaling_factor; std::get<31>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<32, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_eq * (new_term.alu_ia - new_term.alu_cmp_gadget_input_a)); + auto tmp = (((FF(1) - new_term.alu_ff_tag) * new_term.alu_op_not) * + ((new_term.alu_ia + new_term.alu_ic) - alu_UINT_MAX)); tmp *= scaling_factor; std::get<32>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<33, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_eq * (new_term.alu_ib - new_term.alu_cmp_gadget_input_b)); + auto tmp = (new_term.alu_op_eq * (new_term.alu_ia - new_term.alu_cmp_gadget_input_a)); tmp *= scaling_factor; std::get<33>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<34, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_eq * (new_term.alu_ic - new_term.alu_cmp_gadget_result)); + auto tmp = (new_term.alu_op_eq * (new_term.alu_ib - new_term.alu_cmp_gadget_input_b)); tmp *= scaling_factor; std::get<34>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<35, ContainerOverSubrelations>; - auto tmp = (new_term.alu_sel_cmp - (new_term.alu_op_lt + new_term.alu_op_lte)); + auto tmp = (new_term.alu_op_eq * (new_term.alu_ic - new_term.alu_cmp_gadget_result)); tmp *= scaling_factor; std::get<35>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<36, ContainerOverSubrelations>; - auto tmp = ((new_term.alu_op_lt * (new_term.alu_ib - new_term.alu_cmp_gadget_input_a)) + - (new_term.alu_op_lte * (new_term.alu_ia - new_term.alu_cmp_gadget_input_a))); + auto tmp = (new_term.alu_sel_cmp - (new_term.alu_op_lt + new_term.alu_op_lte)); tmp *= scaling_factor; std::get<36>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<37, ContainerOverSubrelations>; - auto tmp = ((new_term.alu_op_lt * (new_term.alu_ia - new_term.alu_cmp_gadget_input_b)) + - (new_term.alu_op_lte * (new_term.alu_ib - new_term.alu_cmp_gadget_input_b))); + auto tmp = ((new_term.alu_op_lt * (new_term.alu_ib - new_term.alu_cmp_gadget_input_a)) + + (new_term.alu_op_lte * (new_term.alu_ia - new_term.alu_cmp_gadget_input_a))); tmp *= scaling_factor; std::get<37>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<38, ContainerOverSubrelations>; - auto tmp = ((new_term.alu_op_lte * ((FF(1) - new_term.alu_cmp_gadget_result) - new_term.alu_ic)) + - (new_term.alu_op_lt * (new_term.alu_cmp_gadget_result - new_term.alu_ic))); + auto tmp = ((new_term.alu_op_lt * (new_term.alu_ia - new_term.alu_cmp_gadget_input_b)) + + (new_term.alu_op_lte * (new_term.alu_ib - new_term.alu_cmp_gadget_input_b))); tmp *= scaling_factor; std::get<38>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<39, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_cast * - ((new_term.alu_ia - new_term.alu_a_lo) - (alu_MAX_BITS_POW * new_term.alu_a_hi))); + auto tmp = ((new_term.alu_op_lte * ((FF(1) - new_term.alu_cmp_gadget_result) - new_term.alu_ic)) + + (new_term.alu_op_lt * (new_term.alu_cmp_gadget_result - new_term.alu_ic))); tmp *= scaling_factor; std::get<39>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<40, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_cast * (new_term.alu_ic - new_term.alu_a_lo)); + auto tmp = (new_term.alu_op_cast * + ((new_term.alu_ia - new_term.alu_a_lo) - (alu_MAX_BITS_POW * new_term.alu_a_hi))); tmp *= scaling_factor; std::get<40>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<41, ContainerOverSubrelations>; - auto tmp = - ((new_term.alu_op_shl + new_term.alu_op_shr) * (new_term.alu_cmp_gadget_input_a - new_term.alu_ib)); + auto tmp = (new_term.alu_op_cast * (new_term.alu_ic - new_term.alu_a_lo)); tmp *= scaling_factor; std::get<41>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<42, ContainerOverSubrelations>; - auto tmp = ((new_term.alu_op_shl + new_term.alu_op_shr) * - (new_term.alu_cmp_gadget_input_b - (alu_MAX_BITS - FF(1)))); + auto tmp = + ((new_term.alu_op_shl + new_term.alu_op_shr) * (new_term.alu_cmp_gadget_input_a - new_term.alu_ib)); tmp *= scaling_factor; std::get<42>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<43, ContainerOverSubrelations>; auto tmp = ((new_term.alu_op_shl + new_term.alu_op_shr) * - (new_term.alu_zero_shift - new_term.alu_cmp_gadget_result)); + (new_term.alu_cmp_gadget_input_b - (alu_MAX_BITS - FF(1)))); tmp *= scaling_factor; std::get<43>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<44, ContainerOverSubrelations>; - auto tmp = - (new_term.alu_sel_shift_which - ((new_term.alu_op_shr + new_term.alu_op_shl) * alu_NON_TRIVIAL_SHIFT)); + auto tmp = ((new_term.alu_op_shl + new_term.alu_op_shr) * + (new_term.alu_zero_shift - new_term.alu_cmp_gadget_result)); tmp *= scaling_factor; std::get<44>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<45, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_shr * - ((new_term.alu_ia - new_term.alu_a_lo) - (new_term.alu_b_pow * new_term.alu_a_hi))); + auto tmp = + (new_term.alu_sel_shift_which - ((new_term.alu_op_shr + new_term.alu_op_shl) * alu_NON_TRIVIAL_SHIFT)); tmp *= scaling_factor; std::get<45>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<46, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_shr * (new_term.alu_ic - (new_term.alu_a_hi * alu_NON_TRIVIAL_SHIFT))); + auto tmp = (new_term.alu_op_shr * + ((new_term.alu_ia - new_term.alu_a_lo) - (new_term.alu_b_pow * new_term.alu_a_hi))); tmp *= scaling_factor; std::get<46>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<47, ContainerOverSubrelations>; - auto tmp = (new_term.alu_op_shl * ((new_term.alu_ia - new_term.alu_a_lo) - - (new_term.alu_max_bits_sub_b_pow * new_term.alu_a_hi))); + auto tmp = (new_term.alu_op_shr * (new_term.alu_ic - (new_term.alu_a_hi * alu_NON_TRIVIAL_SHIFT))); tmp *= scaling_factor; std::get<47>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<48, ContainerOverSubrelations>; + auto tmp = (new_term.alu_op_shl * ((new_term.alu_ia - new_term.alu_a_lo) - + (new_term.alu_max_bits_sub_b_pow * new_term.alu_a_hi))); + tmp *= scaling_factor; + std::get<48>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<49, ContainerOverSubrelations>; auto tmp = (new_term.alu_op_shl * (new_term.alu_ic - ((new_term.alu_a_lo * new_term.alu_b_pow) * alu_NON_TRIVIAL_SHIFT))); tmp *= scaling_factor; - std::get<48>(evals) += typename Accumulator::View(tmp); + std::get<49>(evals) += typename Accumulator::View(tmp); } } }; @@ -422,13 +430,13 @@ template class alu : public Relation> { static std::string get_subrelation_label(size_t index) { switch (index) { - case 19: + case 20: return "ALU_MULTIPLICATION_FF"; - case 23: + case 24: return "ALU_PROD_MUL"; - case 30: - return "DIVISION_RELATION"; case 31: + return "DIVISION_RELATION"; + case 32: return "ALU_OP_NOT"; } return std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp index ba42e4f4bfbd..51748bd9661c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/cmp.hpp @@ -10,8 +10,8 @@ template class cmpImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 2, 3, 5, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, - 3, 2, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 4, 2, 3, 5, 3, 3, 3, 3, 3, 3, 3, 3, 5, + 5, 3, 2, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -19,6 +19,8 @@ template class cmpImpl { [[maybe_unused]] const RelationParameters&, [[maybe_unused]] const FF& scaling_factor) { + const auto cmp_A_GT_B = ((new_term.cmp_input_a - new_term.cmp_input_b) - FF(1)); + const auto cmp_B_GTE_A = (new_term.cmp_input_b - new_term.cmp_input_a); const auto cmp_DIFF = (new_term.cmp_input_a - new_term.cmp_input_b); const auto cmp_POW_128 = FF(uint256_t{ 0UL, 0UL, 1UL, 0UL }); const auto cmp_P_LO = FF(uint256_t{ 4891460686036598784UL, 2896914383306846353UL, 0UL, 0UL }); @@ -39,176 +41,183 @@ template class cmpImpl { } { using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_sel_cmp - (new_term.cmp_op_eq + new_term.cmp_op_gt)); + auto tmp = (new_term.cmp_op_non_ff_gt * ((new_term.cmp_diff - (cmp_A_GT_B * new_term.cmp_result)) - + (cmp_B_GTE_A * (FF(1) - new_term.cmp_result)))); tmp *= scaling_factor; std::get<1>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_result * (FF(1) - new_term.cmp_result)); + auto tmp = (new_term.cmp_sel_cmp - ((new_term.cmp_op_eq + new_term.cmp_op_gt) + new_term.cmp_op_non_ff_gt)); tmp *= scaling_factor; std::get<2>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>; - auto tmp = - (new_term.cmp_op_eq * (((cmp_DIFF * ((new_term.cmp_result * (FF(1) - new_term.cmp_op_eq_diff_inv)) + - new_term.cmp_op_eq_diff_inv)) - - FF(1)) + - new_term.cmp_result)); + auto tmp = (new_term.cmp_result * (FF(1) - new_term.cmp_result)); tmp *= scaling_factor; std::get<3>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>; auto tmp = - (new_term.cmp_op_gt * (new_term.cmp_input_a - (new_term.cmp_a_lo + (cmp_POW_128 * new_term.cmp_a_hi)))); + (new_term.cmp_op_eq * (((cmp_DIFF * ((new_term.cmp_result * (FF(1) - new_term.cmp_op_eq_diff_inv)) + + new_term.cmp_op_eq_diff_inv)) - + FF(1)) + + new_term.cmp_result)); tmp *= scaling_factor; std::get<4>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>; auto tmp = - (new_term.cmp_op_gt * (new_term.cmp_input_b - (new_term.cmp_b_lo + (cmp_POW_128 * new_term.cmp_b_hi)))); + (new_term.cmp_op_gt * (new_term.cmp_input_a - (new_term.cmp_a_lo + (cmp_POW_128 * new_term.cmp_a_hi)))); tmp *= scaling_factor; std::get<5>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_p_a_borrow * (FF(1) - new_term.cmp_p_a_borrow)); + auto tmp = + (new_term.cmp_op_gt * (new_term.cmp_input_b - (new_term.cmp_b_lo + (cmp_POW_128 * new_term.cmp_b_hi)))); tmp *= scaling_factor; std::get<6>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_a_lo - ((cmp_P_LO - new_term.cmp_a_lo) + - (new_term.cmp_p_a_borrow * cmp_POW_128)))); + auto tmp = (new_term.cmp_p_a_borrow * (FF(1) - new_term.cmp_p_a_borrow)); tmp *= scaling_factor; std::get<7>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * - (new_term.cmp_p_sub_a_hi - ((cmp_P_HI - new_term.cmp_a_hi) - new_term.cmp_p_a_borrow))); + auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_a_lo - ((cmp_P_LO - new_term.cmp_a_lo) + + (new_term.cmp_p_a_borrow * cmp_POW_128)))); tmp *= scaling_factor; std::get<8>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_p_b_borrow * (FF(1) - new_term.cmp_p_b_borrow)); + auto tmp = (new_term.cmp_op_gt * + (new_term.cmp_p_sub_a_hi - ((cmp_P_HI - new_term.cmp_a_hi) - new_term.cmp_p_a_borrow))); tmp *= scaling_factor; std::get<9>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_b_lo - ((cmp_P_LO - new_term.cmp_b_lo) + - (new_term.cmp_p_b_borrow * cmp_POW_128)))); + auto tmp = (new_term.cmp_p_b_borrow * (FF(1) - new_term.cmp_p_b_borrow)); tmp *= scaling_factor; std::get<10>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * - (new_term.cmp_p_sub_b_hi - ((cmp_P_HI - new_term.cmp_b_hi) - new_term.cmp_p_b_borrow))); + auto tmp = (new_term.cmp_op_gt * (new_term.cmp_p_sub_b_lo - ((cmp_P_LO - new_term.cmp_b_lo) + + (new_term.cmp_p_b_borrow * cmp_POW_128)))); tmp *= scaling_factor; std::get<11>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_lo - - ((cmp_A_SUB_B_LO * cmp_IS_GT) + (cmp_B_SUB_A_LO * (FF(1) - cmp_IS_GT))))); + auto tmp = (new_term.cmp_op_gt * + (new_term.cmp_p_sub_b_hi - ((cmp_P_HI - new_term.cmp_b_hi) - new_term.cmp_p_b_borrow))); tmp *= scaling_factor; std::get<12>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_hi - - ((cmp_A_SUB_B_HI * cmp_IS_GT) + (cmp_B_SUB_A_HI * (FF(1) - cmp_IS_GT))))); + auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_lo - + ((cmp_A_SUB_B_LO * cmp_IS_GT) + (cmp_B_SUB_A_LO * (FF(1) - cmp_IS_GT))))); tmp *= scaling_factor; std::get<13>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_sel_rng_chk * (FF(1) - new_term.cmp_sel_rng_chk)); + auto tmp = (new_term.cmp_op_gt * (new_term.cmp_res_hi - + ((cmp_A_SUB_B_HI * cmp_IS_GT) + (cmp_B_SUB_A_HI * (FF(1) - cmp_IS_GT))))); tmp *= scaling_factor; std::get<14>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_sel_rng_chk_shift - (new_term.cmp_shift_sel + new_term.cmp_op_gt_shift)); + auto tmp = (new_term.cmp_sel_rng_chk * (FF(1) - new_term.cmp_sel_rng_chk)); tmp *= scaling_factor; std::get<15>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>; - auto tmp = - (((new_term.cmp_cmp_rng_ctr_shift - new_term.cmp_cmp_rng_ctr) + FF(1)) * new_term.cmp_cmp_rng_ctr); + auto tmp = (new_term.cmp_sel_rng_chk_shift - (new_term.cmp_shift_sel + new_term.cmp_op_gt_shift)); tmp *= scaling_factor; std::get<16>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>; - auto tmp = (new_term.cmp_op_gt * (new_term.cmp_cmp_rng_ctr - FF(4))); + auto tmp = + (((new_term.cmp_cmp_rng_ctr_shift - new_term.cmp_cmp_rng_ctr) + FF(1)) * new_term.cmp_cmp_rng_ctr); tmp *= scaling_factor; std::get<17>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_cmp_rng_ctr * - (((FF(1) - new_term.cmp_shift_sel) * (FF(1) - new_term.cmp_op_eq_diff_inv)) + - new_term.cmp_op_eq_diff_inv)) - - new_term.cmp_shift_sel); + auto tmp = (new_term.cmp_op_gt * (new_term.cmp_cmp_rng_ctr - FF(4))); tmp *= scaling_factor; std::get<18>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_a_lo_shift - new_term.cmp_b_lo) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_cmp_rng_ctr * + (((FF(1) - new_term.cmp_shift_sel) * (FF(1) - new_term.cmp_op_eq_diff_inv)) + + new_term.cmp_op_eq_diff_inv)) - + new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<19>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_a_hi_shift - new_term.cmp_b_hi) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_a_lo_shift - new_term.cmp_b_lo) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<20>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<21, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_b_lo_shift - new_term.cmp_p_sub_a_lo) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_a_hi_shift - new_term.cmp_b_hi) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<21>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<22, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_b_hi_shift - new_term.cmp_p_sub_a_hi) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_b_lo_shift - new_term.cmp_p_sub_a_lo) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<22>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<23, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_p_sub_a_lo_shift - new_term.cmp_p_sub_b_lo) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_b_hi_shift - new_term.cmp_p_sub_a_hi) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<23>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_p_sub_a_hi_shift - new_term.cmp_p_sub_b_hi) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_p_sub_a_lo_shift - new_term.cmp_p_sub_b_lo) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<24>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<25, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_p_sub_b_lo_shift - new_term.cmp_res_lo) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_p_sub_a_hi_shift - new_term.cmp_p_sub_b_hi) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<25>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<26, ContainerOverSubrelations>; - auto tmp = ((new_term.cmp_p_sub_b_hi_shift - new_term.cmp_res_hi) * new_term.cmp_shift_sel); + auto tmp = ((new_term.cmp_p_sub_b_lo_shift - new_term.cmp_res_lo) * new_term.cmp_shift_sel); tmp *= scaling_factor; std::get<26>(evals) += typename Accumulator::View(tmp); } + { + using Accumulator = typename std::tuple_element_t<27, ContainerOverSubrelations>; + auto tmp = ((new_term.cmp_p_sub_b_hi_shift - new_term.cmp_res_hi) * new_term.cmp_shift_sel); + tmp *= scaling_factor; + std::get<27>(evals) += typename Accumulator::View(tmp); + } } }; @@ -219,39 +228,39 @@ template class cmp : public Relation> { static std::string get_subrelation_label(size_t index) { switch (index) { - case 2: - return "CMP_RES_IS_BOOL"; case 3: - return "CMP_OP_EQ"; + return "CMP_RES_IS_BOOL"; case 4: - return "INPUT_DECOMP_1"; + return "CMP_OP_EQ"; case 5: + return "INPUT_DECOMP_1"; + case 6: return "INPUT_DECOMP_2"; - case 7: - return "SUB_LO_1"; case 8: + return "SUB_LO_1"; + case 9: return "SUB_HI_1"; - case 10: - return "SUB_LO_2"; case 11: - return "SUB_HI_2"; + return "SUB_LO_2"; case 12: - return "RES_LO"; + return "SUB_HI_2"; case 13: + return "RES_LO"; + case 14: return "RES_HI"; - case 16: - return "CMP_CTR_REL_1"; case 17: - return "CMP_CTR_REL_2"; + return "CMP_CTR_REL_1"; case 18: - return "CTR_NON_ZERO_REL"; + return "CMP_CTR_REL_2"; case 19: + return "CTR_NON_ZERO_REL"; + case 20: return "SHIFT_RELS_0"; - case 21: + case 22: return "SHIFT_RELS_1"; - case 23: + case 24: return "SHIFT_RELS_2"; - case 25: + case 26: return "SHIFT_RELS_3"; } return std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_cmp_alu.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_cmp_alu.hpp index fd66a4aed550..a7b3db16d104 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_cmp_alu.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_cmp_alu.hpp @@ -11,7 +11,7 @@ namespace bb { class perm_cmp_alu_permutation_settings { public: // This constant defines how many columns are bundled together to form each set. - constexpr static size_t COLUMNS_PER_SET = 6; + constexpr static size_t COLUMNS_PER_SET = 7; template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) { @@ -30,12 +30,14 @@ class perm_cmp_alu_permutation_settings { in.cmp_result, in.cmp_op_eq, in.cmp_op_gt, + in.cmp_op_non_ff_gt, in.alu_clk, in.alu_cmp_gadget_input_a, in.alu_cmp_gadget_input_b, in.alu_cmp_gadget_result, in.alu_op_eq, - in.alu_cmp_gadget_gt); + in.alu_cmp_gadget_gt, + in.alu_cmp_gadget_non_ff_gt); } template static inline auto get_nonconst_entities(AllEntities& in) @@ -50,12 +52,14 @@ class perm_cmp_alu_permutation_settings { in.cmp_result, in.cmp_op_eq, in.cmp_op_gt, + in.cmp_op_non_ff_gt, in.alu_clk, in.alu_cmp_gadget_input_a, in.alu_cmp_gadget_input_b, in.alu_cmp_gadget_result, in.alu_op_eq, - in.alu_cmp_gadget_gt); + in.alu_cmp_gadget_gt, + in.alu_cmp_gadget_non_ff_gt); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp new file mode 100644 index 000000000000..2e5258e71523 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/perm_rng_non_ff_cmp.hpp @@ -0,0 +1,53 @@ +// AUTOGENERATED FILE +#pragma once + +#include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" + +#include +#include + +namespace bb { + +class perm_rng_non_ff_cmp_permutation_settings { + public: + // This constant defines how many columns are bundled together to form each set. + constexpr static size_t COLUMNS_PER_SET = 2; + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.range_check_cmp_non_ff_rng_chk == 1 || in.cmp_op_non_ff_gt == 1); + } + + template static inline auto get_const_entities(const AllEntities& in) + { + return std::forward_as_tuple(in.perm_rng_non_ff_cmp_inv, + in.range_check_cmp_non_ff_rng_chk, + in.range_check_cmp_non_ff_rng_chk, + in.cmp_op_non_ff_gt, + in.range_check_clk, + in.range_check_value, + in.cmp_range_chk_clk, + in.cmp_diff); + } + + template static inline auto get_nonconst_entities(AllEntities& in) + { + return std::forward_as_tuple(in.perm_rng_non_ff_cmp_inv, + in.range_check_cmp_non_ff_rng_chk, + in.range_check_cmp_non_ff_rng_chk, + in.cmp_op_non_ff_gt, + in.range_check_clk, + in.range_check_value, + in.cmp_range_chk_clk, + in.cmp_diff); + } +}; + +template +class perm_rng_non_ff_cmp_relation : public GenericPermutationRelation { + public: + static constexpr const char* NAME = "PERM_RNG_NON_FF_CMP"; +}; +template using perm_rng_non_ff_cmp = GenericPermutation; + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp index 6f05962b1e27..5a6f317d75ca 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/range_check.hpp @@ -10,8 +10,8 @@ template class range_checkImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 2, - 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3 }; + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 2, 3, + 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -243,6 +243,12 @@ template class range_checkImpl { tmp *= scaling_factor; std::get<23>(evals) += typename Accumulator::View(tmp); } + { + using Accumulator = typename std::tuple_element_t<24, ContainerOverSubrelations>; + auto tmp = (new_term.range_check_cmp_non_ff_rng_chk * (new_term.range_check_rng_chk_bits - FF(128))); + tmp *= scaling_factor; + std::get<24>(evals) += typename Accumulator::View(tmp); + } } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/arithmetic.test.cpp index ebf0264e43bd..46a00c1a004a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/arithmetic.test.cpp @@ -403,24 +403,27 @@ std::vector> positive_op_div_test_values = { { // Test on basic addition over finite field type. TEST_F(AvmArithmeticTestsFF, addition) { - std::vector const calldata = { 37, 4, 11 }; + const FF a = FF::modulus - 19; + const FF b = FF::modulus - 5; + const FF c = FF::modulus - 24; // c = a + b + std::vector const calldata = { a, b, 4 }; gen_trace_builder(calldata); trace_builder.op_set(0, 0, 0, AvmMemoryTag::U32); trace_builder.op_set(0, 3, 1, AvmMemoryTag::U32); trace_builder.op_calldata_copy(0, 0, 1, 0); - // Memory layout: [37,4,11,0,0,0,....] - trace_builder.op_add(0, 0, 1, 4); // [37,4,11,0,41,0,....] + // Memory layout: [a,b,4,0,0,....] + trace_builder.op_add(0, 0, 1, 4); // [a,b,4,0,c,0,....] trace_builder.op_set(0, 5, 100, AvmMemoryTag::U32); trace_builder.op_return(0, 0, 100); auto trace = trace_builder.finalize(); - auto alu_row = common_validate_add(trace, FF(37), FF(4), FF(41), FF(0), FF(1), FF(4), AvmMemoryTag::FF); + auto alu_row = common_validate_add(trace, a, b, c, FF(0), FF(1), FF(4), AvmMemoryTag::FF); EXPECT_EQ(alu_row.alu_ff_tag, FF(1)); EXPECT_EQ(alu_row.alu_cf, FF(0)); - std::vector const returndata = { 37, 4, 11, 0, 41 }; + std::vector const returndata = { a, b, 4, 0, c }; validate_trace(std::move(trace), public_inputs, calldata, returndata); } @@ -428,49 +431,55 @@ TEST_F(AvmArithmeticTestsFF, addition) // Test on basic subtraction over finite field type. TEST_F(AvmArithmeticTestsFF, subtraction) { - std::vector const calldata = { 8, 4, 17 }; + const FF a = 8; + const FF b = FF::modulus - 5; + const FF c = 13; // c = a - b + std::vector const calldata = { b, 4, a }; gen_trace_builder(calldata); trace_builder.op_set(0, 0, 0, AvmMemoryTag::U32); trace_builder.op_set(0, 3, 1, AvmMemoryTag::U32); trace_builder.op_calldata_copy(0, 0, 1, 0); - // Memory layout: [8,4,17,0,0,0,....] - trace_builder.op_sub(0, 2, 0, 1); // [8,9,17,0,0,0....] + // Memory layout: [b,4,a,0,0,0,....] + trace_builder.op_sub(0, 2, 0, 1); // [b,c,a,0,0,0....] trace_builder.op_set(0, 3, 100, AvmMemoryTag::U32); trace_builder.op_return(0, 0, 100); auto trace = trace_builder.finalize(); - auto alu_row = common_validate_sub(trace, FF(17), FF(8), FF(9), FF(2), FF(0), FF(1), AvmMemoryTag::FF); + auto alu_row = common_validate_sub(trace, a, b, c, FF(2), FF(0), FF(1), AvmMemoryTag::FF); EXPECT_EQ(alu_row.alu_ff_tag, FF(1)); EXPECT_EQ(alu_row.alu_cf, FF(0)); - std::vector const returndata = { 8, 9, 17 }; + std::vector const returndata = { b, c, a }; validate_trace(std::move(trace), public_inputs, calldata, returndata); } // Test on basic multiplication over finite field type. TEST_F(AvmArithmeticTestsFF, multiplication) { - std::vector const calldata = { 5, 0, 20 }; + const FF a = FF::modulus - 1; + const FF b = 278; + const FF c = FF::modulus - 278; + std::vector const calldata = { b, 0, a }; gen_trace_builder(calldata); trace_builder.op_set(0, 0, 0, AvmMemoryTag::U32); trace_builder.op_set(0, 3, 1, AvmMemoryTag::U32); trace_builder.op_calldata_copy(0, 0, 1, 0); - // Memory layout: [5,0,20,0,0,0,....] - trace_builder.op_mul(0, 2, 0, 1); // [5,100,20,0,0,0....] + // Memory layout: [b,0,a,0,0,0,....] + trace_builder.op_mul(0, 2, 0, 1); // [b,c,a,0,0,0....] trace_builder.op_set(0, 3, 100, AvmMemoryTag::U32); trace_builder.op_return(0, 0, 100); auto trace = trace_builder.finalize(); - auto alu_row_index = common_validate_mul(trace, FF(20), FF(5), FF(100), FF(2), FF(0), FF(1), AvmMemoryTag::FF); + auto alu_row_index = common_validate_mul(trace, a, b, c, FF(2), FF(0), FF(1), AvmMemoryTag::FF); auto alu_row = trace.at(alu_row_index); EXPECT_EQ(alu_row.alu_ff_tag, FF(1)); EXPECT_EQ(alu_row.alu_cf, FF(0)); - std::vector const returndata = { 5, 100, 20 }; + std::vector const returndata = { b, c, a }; validate_trace(std::move(trace), public_inputs, calldata, returndata); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.cpp index 00857da903fd..3b4f198b1274 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.cpp @@ -106,10 +106,14 @@ void AvmAluTraceBuilder::reset() FF AvmAluTraceBuilder::op_add(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) { bool carry = false; - uint256_t c_u256 = uint256_t(a) + uint256_t(b); - FF c = cast_to_mem_tag(c_u256, in_tag); + FF c; + + if (in_tag == AvmMemoryTag::FF) { + c = a + b; + } else { + uint256_t c_u256 = uint256_t(a) + uint256_t(b); + c = cast_to_mem_tag(c_u256, in_tag); - if (in_tag != AvmMemoryTag::FF) { // a_u128 + b_u128 >= 2^128 <==> c_u128 < a_u128 if (uint128_t(c) < uint128_t(a)) { carry = true; @@ -150,10 +154,14 @@ FF AvmAluTraceBuilder::op_add(FF const& a, FF const& b, AvmMemoryTag in_tag, uin FF AvmAluTraceBuilder::op_sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) { bool carry = false; - uint256_t c_u256 = uint256_t(a) - uint256_t(b); - FF c = cast_to_mem_tag(c_u256, in_tag); + FF c; + + if (in_tag == AvmMemoryTag::FF) { + c = a - b; + } else { + uint256_t c_u256 = uint256_t(a) - uint256_t(b); + c = cast_to_mem_tag(c_u256, in_tag); - if (in_tag != AvmMemoryTag::FF) { // Underflow when a_u128 < b_u128 if (uint128_t(a) < uint128_t(b)) { carry = true; @@ -189,29 +197,41 @@ FF AvmAluTraceBuilder::op_sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uin */ FF AvmAluTraceBuilder::op_mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) { - uint256_t a_u256{ a }; - uint256_t b_u256{ b }; - uint256_t c_u256 = a_u256 * b_u256; // Multiplication over the integers (not mod. 2^128) + FF c = 0; + uint256_t alu_a_lo = 0; + uint256_t alu_a_hi = 0; + uint256_t alu_b_lo = 0; + uint256_t alu_b_hi = 0; + uint256_t c_hi = 0; + uint256_t partial_prod_lo = 0; + uint256_t partial_prod_hi = 0; - FF c = cast_to_mem_tag(c_u256, in_tag); + if (in_tag == AvmMemoryTag::FF) { + c = a * b; + } else { - uint8_t bits = mem_tag_bits(in_tag); - // limbs are size 1 for u1 - uint8_t limb_bits = bits == 1 ? 1 : bits / 2; - uint8_t num_bits = bits; + uint256_t a_u256{ a }; + uint256_t b_u256{ b }; + uint256_t c_u256 = a_u256 * b_u256; // Multiplication over the integers (not mod. 2^128) - // Decompose a - auto [alu_a_lo, alu_a_hi] = decompose(a_u256, limb_bits); - // Decompose b - auto [alu_b_lo, alu_b_hi] = decompose(b_u256, limb_bits); + c = cast_to_mem_tag(c_u256, in_tag); - uint256_t partial_prod = alu_a_lo * alu_b_hi + alu_a_hi * alu_b_lo; - // Decompose the partial product - auto [partial_prod_lo, partial_prod_hi] = decompose(partial_prod, limb_bits); + uint8_t bits = mem_tag_bits(in_tag); + // limbs are size 1 for u1 + uint8_t limb_bits = bits == 1 ? 1 : bits / 2; + uint8_t num_bits = bits; - auto c_hi = c_u256 >> num_bits; + // Decompose a + std::tie(alu_a_lo, alu_a_hi) = decompose(a_u256, limb_bits); + // Decompose b + std::tie(alu_b_lo, alu_b_hi) = decompose(b_u256, limb_bits); + + uint256_t partial_prod = alu_a_lo * alu_b_hi + alu_a_hi * alu_b_lo; + // Decompose the partial product + std::tie(partial_prod_lo, partial_prod_hi) = decompose(partial_prod, limb_bits); + + c_hi = c_u256 >> num_bits; - if (in_tag != AvmMemoryTag::FF) { cmp_builder.range_check_builder.assert_range(uint128_t(c), mem_tag_bits(in_tag), EventEmitter::ALU, clk); } @@ -267,7 +287,7 @@ FF AvmAluTraceBuilder::op_div(FF const& a, FF const& b, AvmMemoryTag in_tag, uin static_cast(c_u256), mem_tag_bits(in_tag), EventEmitter::ALU, clk); } // Also check the remainder < divisor (i.e. remainder < b) - bool is_gt = cmp_builder.constrained_gt(b, rem_u256, clk, EventEmitter::ALU); + bool is_gt = cmp_builder.constrained_non_ff_gt(uint128_t(b), uint128_t(rem_u256), clk, EventEmitter::ALU); AvmAluTraceBuilder::AluTraceEntry row{ .alu_clk = clk, @@ -348,7 +368,12 @@ FF AvmAluTraceBuilder::op_eq(FF const& a, FF const& b, AvmMemoryTag in_tag, uint FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) { // Note: This is counter-intuitive, to show that a < b we use the GT gadget with the inputs swapped - bool result = cmp_builder.constrained_gt(b, a, clk, EventEmitter::ALU); + bool result = false; + if (in_tag == AvmMemoryTag::FF) { + result = cmp_builder.constrained_gt(b, a, clk, EventEmitter::ALU); + } else { + result = cmp_builder.constrained_non_ff_gt(uint128_t(b), uint128_t(a), clk, EventEmitter::ALU); + } bool c = result; // The subtlety is here that the circuit is designed as a GT(x,y) circuit, therefore we swap the inputs a & b @@ -383,7 +408,12 @@ FF AvmAluTraceBuilder::op_lt(FF const& a, FF const& b, AvmMemoryTag in_tag, uint FF AvmAluTraceBuilder::op_lte(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) { // Note: This is counter-intuitive, to show that a <= b we actually show that a > b and then invert the answer - bool result = cmp_builder.constrained_gt(a, b, clk, EventEmitter::ALU); + bool result = false; + if (in_tag == AvmMemoryTag::FF) { + result = cmp_builder.constrained_gt(a, b, clk, EventEmitter::ALU); + } else { + result = cmp_builder.constrained_non_ff_gt(uint128_t(a), uint128_t(b), clk, EventEmitter::ALU); + } bool c = !result; // Construct the row that performs the lte check @@ -465,7 +495,7 @@ FF AvmAluTraceBuilder::op_shl(FF const& a, FF const& b, AvmMemoryTag in_tag, uin auto [a_lo, a_hi] = decompose(a, num_bits - b_u8); // Check if this is a trivial shift - i.e. we shift more than the max bits of our input - bool zero_shift = cmp_builder.constrained_gt(b, num_bits - 1, clk, EventEmitter::ALU); + bool zero_shift = cmp_builder.constrained_non_ff_gt(uint128_t(b), num_bits - 1, clk, EventEmitter::ALU); if (!zero_shift) { u8_pow_2_counters[0][b_u8]++; u8_pow_2_counters[1][num_bits - b_u8]++; @@ -524,7 +554,7 @@ FF AvmAluTraceBuilder::op_shr(FF const& a, FF const& b, AvmMemoryTag in_tag, uin FF c = cast_to_mem_tag(c_u256, in_tag); uint8_t num_bits = mem_tag_bits(in_tag); - bool zero_shift = cmp_builder.constrained_gt(b, num_bits - 1, clk, EventEmitter::ALU); + bool zero_shift = cmp_builder.constrained_non_ff_gt(uint128_t(b), num_bits - 1, clk, EventEmitter::ALU); if (!zero_shift) { // Add counters for the pow of two lookups u8_pow_2_counters[0][b_u8]++; @@ -706,8 +736,9 @@ void AvmAluTraceBuilder::finalize(std::vector>& main_trace) dest.alu_cmp_gadget_input_a = src.cmp_input_a; dest.alu_cmp_gadget_input_b = src.cmp_input_b; dest.alu_cmp_gadget_result = src.cmp_result; - dest.alu_cmp_gadget_gt = FF(static_cast(src.cmp_op_is_gt)); - dest.alu_cmp_gadget_sel = dest.alu_cmp_gadget_gt + dest.alu_op_eq; + dest.alu_cmp_gadget_gt = FF(static_cast(src.cmp_op_is_gt && src.tag == AvmMemoryTag::FF)); + dest.alu_cmp_gadget_non_ff_gt = FF(static_cast(src.cmp_op_is_gt && src.tag != AvmMemoryTag::FF)); + dest.alu_cmp_gadget_sel = dest.alu_cmp_gadget_gt + dest.alu_op_eq + dest.alu_cmp_gadget_non_ff_gt; } reset(); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.hpp index f75bd99d6c10..a75fc8cb2506 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/alu_trace.hpp @@ -59,6 +59,7 @@ class AvmAluTraceBuilder { FF cmp_input_b{}; FF cmp_result{}; bool cmp_op_is_gt = false; + bool cmp_op_is_gt_non_ff = false; bool cmp_op_is_eq = false; }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp index a653054fba50..c29057911193 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp @@ -8,6 +8,104 @@ namespace bb::avm_trace { using FF = AvmFlavorSettings::FF; using AffinePoint = grumpkin::g1::affine_element; +struct PublicDataTreeLeafPreimage { + FF slot; + FF value; + FF next_index; + FF next_slot; +}; + +inline void read(uint8_t const*& it, PublicDataTreeLeafPreimage& hint) +{ + using serialize::read; + read(it, hint.slot); + read(it, hint.value); + read(it, hint.next_index); + read(it, hint.next_slot); +} + +struct PublicDataReadTreeHint { + PublicDataTreeLeafPreimage leaf_preimage; + FF leaf_index; + std::vector sibling_path; +}; + +inline void read(uint8_t const*& it, PublicDataReadTreeHint& hint) +{ + using serialize::read; + read(it, hint.leaf_preimage); + read(it, hint.leaf_index); + read(it, hint.sibling_path); +} + +struct PublicDataWriteTreeHint { + PublicDataReadTreeHint low_leaf_membership; + PublicDataTreeLeafPreimage new_leaf_preimage; + std::vector insertion_path; +}; + +inline void read(uint8_t const*& it, PublicDataWriteTreeHint& hint) +{ + using serialize::read; + read(it, hint.low_leaf_membership); + read(it, hint.new_leaf_preimage); + read(it, hint.insertion_path); +} + +struct NullifierLeafPreimage { + FF nullifier; + FF next_nullifier; + FF next_index; +}; + +inline void read(uint8_t const*& it, NullifierLeafPreimage& hint) +{ + using serialize::read; + read(it, hint.nullifier); + read(it, hint.next_nullifier); + read(it, hint.next_index); +} + +struct NullifierReadTreeHint { + NullifierLeafPreimage low_leaf_preimage; + FF low_leaf_index; + std::vector low_leaf_sibling_path; +}; + +inline void read(uint8_t const*& it, NullifierReadTreeHint& hint) +{ + using serialize::read; + read(it, hint.low_leaf_preimage); + read(it, hint.low_leaf_index); + read(it, hint.low_leaf_sibling_path); +} + +struct NullifierWriteTreeHint { + NullifierReadTreeHint low_leaf_membership; + std::vector insertion_path; +}; + +inline void read(uint8_t const*& it, NullifierWriteTreeHint& hint) +{ + using serialize::read; + read(it, hint.low_leaf_membership); + read(it, hint.insertion_path); +} + +struct AppendTreeHint { + FF leaf_index; + FF leaf_value; + std::vector sibling_path; +}; + +inline void read(uint8_t const*& it, AppendTreeHint& hint) +{ + using serialize::read; + read(it, hint.leaf_index); + read(it, hint.leaf_value); + read(it, hint.sibling_path); +} + struct ExternalCallHint { FF success{}; std::vector return_data; @@ -128,6 +226,13 @@ struct ExecutionHints { std::map contract_instance_hints; // We could make this address-indexed std::vector all_contract_bytecode; + std::vector storage_read_hints; + std::vector storage_write_hints; + std::vector nullifier_read_hints; + std::vector nullifier_write_hints; + std::vector note_hash_read_hints; + std::vector note_hash_write_hints; + std::vector l1_to_l2_message_read_hints; ExecutionHints() = default; @@ -222,6 +327,27 @@ struct ExecutionHints { std::vector all_contract_bytecode; read(it, all_contract_bytecode); + std::vector storage_read_hints; + read(it, storage_read_hints); + + std::vector storage_write_hints; + read(it, storage_write_hints); + + std::vector nullifier_read_hints; + read(it, nullifier_read_hints); + + std::vector nullifier_write_hints; + read(it, nullifier_write_hints); + + std::vector note_hash_read_hints; + read(it, note_hash_read_hints); + + std::vector note_hash_write_hints; + read(it, note_hash_write_hints); + + std::vector l1_to_l2_message_read_hints; + read(it, l1_to_l2_message_read_hints); + if (it != data.data() + data.size()) { throw_or_abort("Failed to deserialize ExecutionHints: only read " + std::to_string(it - data.data()) + " bytes out of " + std::to_string(data.size()) + " bytes"); @@ -230,7 +356,12 @@ struct ExecutionHints { return { std::move(storage_value_hints), std::move(note_hash_exists_hints), std::move(nullifier_exists_hints), std::move(l1_to_l2_message_exists_hints), std::move(externalcall_hints), std::move(contract_instance_hints), - std::move(all_contract_bytecode) }; + std::move(all_contract_bytecode), std::move(storage_read_hints), + std::move(storage_write_hints), std::move(nullifier_read_hints), + std::move(nullifier_write_hints), std::move(note_hash_read_hints), + std::move(note_hash_write_hints), std::move(l1_to_l2_message_read_hints) + + }; } private: @@ -240,7 +371,15 @@ struct ExecutionHints { std::vector> l1_to_l2_message_exists_hints, std::vector externalcall_hints, std::map contract_instance_hints, - std::vector all_contract_bytecode) + std::vector all_contract_bytecode, + std::vector storage_read_hints, + std::vector storage_write_hints, + std::vector nullifier_read_hints, + std::vector nullifier_write_hints, + std::vector note_hash_read_hints, + std::vector note_hash_write_hints, + std::vector l1_to_l2_message_read_hints) + : storage_value_hints(std::move(storage_value_hints)) , note_hash_exists_hints(std::move(note_hash_exists_hints)) , nullifier_exists_hints(std::move(nullifier_exists_hints)) @@ -248,6 +387,13 @@ struct ExecutionHints { , externalcall_hints(std::move(externalcall_hints)) , contract_instance_hints(std::move(contract_instance_hints)) , all_contract_bytecode(std::move(all_contract_bytecode)) + , storage_read_hints(std::move(storage_read_hints)) + , storage_write_hints(std::move(storage_write_hints)) + , nullifier_read_hints(std::move(nullifier_read_hints)) + , nullifier_write_hints(std::move(nullifier_write_hints)) + , note_hash_read_hints(std::move(note_hash_read_hints)) + , note_hash_write_hints(std::move(note_hash_write_hints)) + , l1_to_l2_message_read_hints(std::move(l1_to_l2_message_read_hints)) {} }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.cpp index 742a2efdb91e..a2e289b8f765 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.cpp @@ -70,6 +70,14 @@ bool AvmCmpBuilder::constrained_gt(FF a, FF b, uint64_t clk, EventEmitter e) return uint256_t(a) > uint256_t(b); } +bool AvmCmpBuilder::constrained_non_ff_gt(uint128_t a, uint128_t b, uint64_t clk, EventEmitter e) +{ + auto a_ff = FF(uint256_t::from_uint128(a)); + auto b_ff = FF(uint256_t::from_uint128(b)); + cmp_events.push_back({ clk, a_ff, b_ff, e, CmpOp::GT_NON_FF }); + return a > b; +} + /************************************************************************************************** * FINALIZE **************************************************************************************************/ @@ -91,6 +99,13 @@ std::vector AvmCmpBuilder::finalize() entry.result = diff == FF::zero() ? FF::one() : FF::zero(); entry.op_eq_diff_inv = diff == FF::zero() ? FF::zero() : diff.invert(); entry.is_eq = true; + } else if (CmpOp::GT_NON_FF == event.op) { + entry.result = input_a_u256 > input_b_u256; + FF diff = + (input_a_u256 > input_b_u256) ? input_a_u256 - input_b_u256 - FF::one() : input_b_u256 - input_a_u256; + entry.is_gt_non_ff = true; + auto range_chk_clk = (entry.clk * (static_cast(1) << 8)); + range_check_builder.assert_range(static_cast(diff), 128, EventEmitter::NON_FF_GT, range_chk_clk); } else { entry.result = input_a_u256 > input_b_u256; auto range_chk_clk = (entry.clk * (uint64_t(1) << 8)) + 4; // 4 is the range check counter @@ -144,6 +159,7 @@ std::vector AvmCmpBuilder::into_canonical(std::vector(entry.is_gt)); row.op_eq = FF(static_cast(entry.is_eq)); + row.op_non_ff_gt = FF(static_cast(entry.is_gt_non_ff)); row.a_lo = std::get<0>(entry.a_limbs); row.a_hi = std::get<1>(entry.a_limbs); @@ -200,6 +216,11 @@ std::vector AvmCmpBuilder::into_canonical(std::vector(1) << 8); + row.diff = uint256_t(row.input_a) > uint256_t(row.input_b) ? row.input_a - row.input_b - FF::one() + : row.input_b - row.input_a; + dest_rows.push_back(row); } else { // EQ operations just have the single row dest_rows.push_back(row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.hpp index 4afd75174179..557a34457385 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/cmp.hpp @@ -6,7 +6,7 @@ #include "barretenberg/vm/avm/trace/gadgets/range_check.hpp" #include -enum class CmpOp { EQ, GT }; +enum class CmpOp { EQ, GT, GT_NON_FF }; namespace bb::avm_trace { class AvmCmpBuilder { @@ -26,6 +26,7 @@ class AvmCmpBuilder { FF result; FF op_eq_diff_inv; bool is_gt; + bool is_gt_non_ff; bool is_eq; std::tuple a_limbs; std::tuple b_limbs; @@ -42,6 +43,9 @@ class AvmCmpBuilder { FF op_eq_diff_inv; FF op_gt; FF op_eq; + FF op_non_ff_gt; + FF non_ff_gt_diff_inv; + FF diff; FF a_lo; FF a_hi; FF b_lo; @@ -69,6 +73,8 @@ class AvmCmpBuilder { bool constrained_eq(FF a, FF b, uint64_t clk, EventEmitter e); // Constrains a > b bool constrained_gt(FF a, FF b, uint64_t clk, EventEmitter e); + // Constrains a > b when a and b are at most 128 bits + bool constrained_non_ff_gt(uint128_t a, uint128_t b, uint64_t clk, EventEmitter e); uint32_t get_cmp_trace_size() const; @@ -83,8 +89,11 @@ class AvmCmpBuilder { row.cmp_result = entry.result; row.cmp_op_eq_diff_inv = entry.op_eq_diff_inv; row.cmp_op_gt = entry.op_gt; + row.cmp_op_non_ff_gt = entry.op_non_ff_gt; row.cmp_op_eq = entry.op_eq; + row.cmp_diff = entry.diff; + row.cmp_a_lo = entry.a_lo; row.cmp_a_hi = entry.a_hi; row.cmp_b_lo = entry.b_lo; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp index 5dea409ea77e..f7d55fde3407 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.cpp @@ -102,6 +102,9 @@ std::vector AvmRangeCheckBuilder::finaliz case EventEmitter::CMP_HI: entry.is_cmp_hi = true; break; + case EventEmitter::NON_FF_GT: + entry.is_cmp_non_ff = true; + break; } entries.push_back(entry); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp index eb9c85a3236c..177099f2b61d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/gadgets/range_check.hpp @@ -5,7 +5,7 @@ #include "barretenberg/vm/avm/trace/common.hpp" #include -enum class EventEmitter { ALU, MEMORY, GAS_L2, GAS_DA, CMP_LO, CMP_HI }; +enum class EventEmitter { ALU, MEMORY, GAS_L2, GAS_DA, CMP_LO, CMP_HI, NON_FF_GT }; namespace bb::avm_trace { class AvmRangeCheckBuilder { @@ -38,6 +38,7 @@ class AvmRangeCheckBuilder { bool is_gas_da_sel; bool is_cmp_lo; bool is_cmp_hi; + bool is_cmp_non_ff; // Need this for sorting bool operator<(RangeCheckEntry const& other) const { return clk < other.clk; } @@ -96,6 +97,7 @@ class AvmRangeCheckBuilder { row.range_check_gas_da_rng_chk = entry.is_gas_da_sel; row.range_check_cmp_lo_bits_rng_chk = entry.is_cmp_lo; row.range_check_cmp_hi_bits_rng_chk = entry.is_cmp_hi; + row.range_check_cmp_non_ff_rng_chk = entry.is_cmp_non_ff; } private: diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index 495856339ffd..52df3243076b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -36,8 +36,9 @@ #define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 866 #define PUBLIC_CONTEXT_INPUTS_LENGTH 41 #define AVM_ACCUMULATED_DATA_LENGTH 318 +#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1006 #define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86 -#define AVM_PROOF_LENGTH_IN_FIELDS 4266 +#define AVM_PROOF_LENGTH_IN_FIELDS 4291 #define AVM_PUBLIC_COLUMN_MAX_SIZE 1024 #define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2914 #define MEM_TAG_FF 0 diff --git a/barretenberg/ts/src/barretenberg/backend.ts b/barretenberg/ts/src/barretenberg/backend.ts index 4d8e89116b35..db292c1a9268 100644 --- a/barretenberg/ts/src/barretenberg/backend.ts +++ b/barretenberg/ts/src/barretenberg/backend.ts @@ -125,12 +125,20 @@ export class UltraPlonkBackend { return await this.api.acirVerifyProof(this.acirComposer, proof); } + /** @description Returns the verification key */ async getVerificationKey(): Promise { await this.instantiate(); await this.api.acirInitVerificationKey(this.acirComposer); return await this.api.acirGetVerificationKey(this.acirComposer); } + /** @description Returns a solidity verifier */ + async getSolidityVerifier(): Promise { + await this.instantiate(); + await this.api.acirInitVerificationKey(this.acirComposer); + return await this.api.acirGetSolidityVerifier(this.acirComposer); + } + async destroy(): Promise { if (!this.api) { return; @@ -218,6 +226,13 @@ export class UltraHonkBackend { return await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); } + /** @description Returns a solidity verifier */ + async getSolidityVerifier(): Promise { + await this.instantiate(); + await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); + return await this.api.getHonkSolidityVerifier(this.acirUncompressedBytecode, this.circuitOptions.recursive); + } + // TODO(https://github.com/noir-lang/noir/issues/5661): Update this to handle Honk recursive aggregation in the browser once it is ready in the backend itself async generateRecursiveProofArtifacts( // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 4d95dfa18873..202239039dce 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -593,6 +593,18 @@ export class BarretenbergApi { return out[0]; } + async getHonkSolidityVerifier(acirVec: Uint8Array, recursive: boolean): Promise { + const inArgs = [acirVec, recursive].map(serializeBufferable); + const outTypes: OutputType[] = [BufferDeserializer()]; + const result = await this.wasm.callWasmExport( + 'get_honk_solidity_verifier_vk', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + async acirProofAsFieldsUltraHonk(proofBuf: Uint8Array): Promise { const inArgs = [proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [VectorDeserializer(Fr)]; diff --git a/docs/docs/guides/developer_guides/getting_started.md b/docs/docs/guides/developer_guides/getting_started.md index f665739c8d9f..ce015ba29dba 100644 --- a/docs/docs/guides/developer_guides/getting_started.md +++ b/docs/docs/guides/developer_guides/getting_started.md @@ -139,12 +139,12 @@ In the next step, let's mint some tokens! Call the public mint function like this: ```bash -aztec-wallet send mint_public --from accounts:my-wallet --contract-address contracts:testtoken --args accounts:my-wallet 100 +aztec-wallet send mint_to_public --from accounts:my-wallet --contract-address contracts:testtoken --args accounts:my-wallet 100 ``` This takes -- the function name as the argument, which is `mint_public` +- the function name as the argument, which is `mint_to_public` - the `from` account (caller) which is `accounts:my-wallet` - the contract address, which is aliased as `contracts:testtoken` (or simply `testtoken`) - the args that the function takes, which is the account to mint the tokens into (`my-wallet`), and `amount` (`100`). @@ -165,7 +165,7 @@ Transaction has been mined Status: success Block number: 17 Block hash: 1e27d200600bc45ab94d467c230490808d1e7d64f5ee6cee5e94a08ee9580809 -Transaction hash stored in database with aliases last & mint_public-9044 +Transaction hash stored in database with aliases last & mint_to_public-9044 ``` You can double-check by calling the function that checks your public account balance: diff --git a/docs/docs/guides/developer_guides/js_apps/authwit.md b/docs/docs/guides/developer_guides/js_apps/authwit.md index d4db5d8c5cd5..92dd49dc6775 100644 --- a/docs/docs/guides/developer_guides/js_apps/authwit.md +++ b/docs/docs/guides/developer_guides/js_apps/authwit.md @@ -68,9 +68,9 @@ Then create the message hash by hashing the inner hash with the authwit receiver ## Create the authwit -There are slightly different interfaces depending on whether your contract is checking the authwit in private or public. +There are slightly different interfaces depending on whether your contract is checking the authwit in private or public. -Public authwits are stored in the account contract and batched with the authwit action call, so a user must send a transaction to update their account contract, authorizing an action before the authorized contract's public call will succeed. +Public authwits are stored in the account contract and batched with the authwit action call, so a user must send a transaction to update their account contract, authorizing an action before the authorized contract's public call will succeed. Private execution uses oracles and are executed locally by the PXE, so the authwit needs to be created by the authwit giver and then added to the authwit receiver's PXE. @@ -107,7 +107,7 @@ Set a public authwit like this: Remember it is a transaction and calls a method in the account contract. In this example, - `wallets[0]` is the authwit giver -- `wallets[1]` is the authwit reciever and caller of the function +- `wallets[1]` is the authwit receiver and caller of the function - `action` was [defined previously](#define-the-action) - `true` sets the `authorized` boolean (`false` would revoke this authwit) diff --git a/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md b/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md index c356ddb15449..902230fa304c 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md +++ b/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md @@ -199,8 +199,8 @@ export class TokenContract extends ContractBase { /** Type-safe wrappers for the public methods exposed by the contract. */ public override methods!: { - /** transfer_public(from: struct, to: struct, amount: field, nonce: field) */ - transfer_public: (( + /** transfer_in_public(from: struct, to: struct, amount: field, nonce: field) */ + transfer_in_public: (( from: AztecAddressLike, to: AztecAddressLike, amount: FieldLike, diff --git a/docs/docs/guides/developer_guides/smart_contracts/testing_contracts/testing.md b/docs/docs/guides/developer_guides/smart_contracts/testing_contracts/testing.md index 2449195013bc..86d470de6644 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/testing_contracts/testing.md +++ b/docs/docs/guides/developer_guides/smart_contracts/testing_contracts/testing.md @@ -118,13 +118,13 @@ Our test environment is capable of utilizing the autogenerated contract interfac For example, to call the private `transfer` function on the token contract: -#include_code txe_test_transfer_private /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust +#include_code txe_test_transfer_private /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr rust #### Public -To call the public `transfer_public` function: +To call the public `transfer_in_public` function: -#include_code call_public /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr rust +#include_code call_public /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr rust #### Unconstrained @@ -178,11 +178,11 @@ Reading notes: You can add [authwits](../writing_contracts/authwit.md) to the TXE. Here is an example of testing a private token transfer using authwits: -#include_code private_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust +#include_code private_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr rust #### Public -#include_code public_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr rust +#include_code public_authwit /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr rust ### Storing notes in cache @@ -206,7 +206,7 @@ You can test functions that you expect to fail generically, with the `#[test(sho For example: -#include_code fail_with_message /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rust +#include_code fail_with_message /noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr rust You can also use the `assert_public_call_fails` or `assert_private_call_fails` methods on the `TestEnvironment` to check that a call fails. diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md index fb288b5ef3d4..ac40dbc36c02 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md +++ b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md @@ -141,7 +141,7 @@ Then you will be able to import it into your contracts as follows. Based on the diagram earlier on this page let's take a look at how we can implement the `transfer` function such that it checks if the tokens are to be transferred `from` the caller or needs to be authenticated with an authentication witness. -#include_code transfer_from /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code transfer_in_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust The first thing we see in the snippet above, is that if `from` is not the call we are calling the `assert_current_call_valid_authwit` function from [earlier](#private-functions). If the call is not throwing, we are all good and can continue with the transfer. @@ -151,7 +151,7 @@ In the snippet we are constraining the `else` case such that only `nonce = 0` is Cool, so we have a function that checks if the current call is authenticated, but how do we actually authenticate it? Well, assuming that we use a wallet that is following the spec, we import `computeAuthWitMessageHash` from `aztec.js` to help us compute the hash, and then we simply `addAuthWitness` to the wallet. Behind the scenes this will make the witness available to the oracle. -#include_code authwit_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts typescript +#include_code authwit_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts typescript Learn more about authwits in Aztec.js by [following this guide](../../js_apps/authwit.md). @@ -161,7 +161,7 @@ With private functions covered, how can we use this in a public function? Well, #### Checking if the current call is authenticated -#include_code transfer_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code transfer_in_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust #### Authenticating an action in TypeScript @@ -169,7 +169,7 @@ Authenticating an action in the public domain is slightly different from the pri In the snippet below, this is done as a separate contract call, but can also be done as part of a batch as mentioned in the [Accounts concepts](../../../../aztec/concepts/accounts/authwit.md#what-about-public). -#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts typescript +#include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts typescript #### Updating approval state in Noir diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md index 848fffa0e1fe..0e601ef307b0 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md +++ b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md @@ -21,7 +21,7 @@ We call this the "authentication witness" pattern or authwit for short. Here you approve a contract to burn funds on your behalf. - Approve in public domain: - #include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts typescript + #include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts typescript Here you approve someone to transfer funds publicly on your behalf @@ -84,8 +84,6 @@ Let's say you have some storage in public and want to move them into the private So you have to create a custom note in the public domain that is not encrypted by some owner - we call such notes a "TransparentNote" since it is created in public, anyone can see the amount and the note is not encrypted by some owner. -This pattern is discussed in detail in [the codealong token tutorial in the shield() method](../../../../../tutorials/codealong/contract_tutorials/token_contract.md#redeem_shield). - ### Discovering my notes When you send someone a note, the note hash gets added to the note hash tree. To spend the note, the receiver needs to get the note itself (the note hash preimage). There are two ways you can get a hold of your notes: diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md index 8c497e3f41c0..d08078b0aec1 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md +++ b/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md @@ -53,7 +53,7 @@ The `content_hash` is a sha256 truncated to a field element (~ 254 bits). In Azt ### Token portal hash library -#include_code mint_public_content_hash_nr /noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr rust +#include_code mint_to_public_content_hash_nr /noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr rust ### Token Portal contract diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 4e44286b40c0..9a7adc06ad13 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -6,6 +6,21 @@ keywords: [sandbox, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. +## 0.63.0 +### [Token contract] Partial notes related refactor +We've decided to replace the old "shield" flow with one leveraging partial notes. +This led to a removal of `shield` and `redeem_shield` functions and an introduction of `transfer_to_private`. +An advantage of the new approach is that only 1 tx is required and the API of partial notes is generally nicer. +For more information on partial notes refer to docs. + +### [Token contract] Function naming changes +There have been a few naming changes done for improved consistency. +These are the renamings: +`transfer_public` --> `transfer_in_public` +`transfer_from` --> `transfer_in_private` +`mint_public` --> `mint_to_public` +`burn` --> `burn_private` + ## 0.62.0 ### [TXE] Single execution environment Thanks to recent advancements in Brillig TXE performs every single call as if it was a nested call, spawning a new ACVM or AVM simulator without performance loss. diff --git a/docs/docs/reference/developer_references/sandbox_reference/cli_wallet_reference.md b/docs/docs/reference/developer_references/sandbox_reference/cli_wallet_reference.md index 593415d21d9b..12a837c227ac 100644 --- a/docs/docs/reference/developer_references/sandbox_reference/cli_wallet_reference.md +++ b/docs/docs/reference/developer_references/sandbox_reference/cli_wallet_reference.md @@ -104,10 +104,10 @@ The authwit management in private is a two-step process: create and add. It's no #### Example -An example for authorizing an operator (ex. a DeFi protocol) to call the transfer_from action (transfer on the user's behalf): +An example for authorizing an operator (ex. a DeFi protocol) to call the transfer_in_private action (transfer on the user's behalf): ```bash -aztec-wallet create-authwit transfer_from accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master -a secret_trade +aztec-wallet create-authwit transfer_in_private accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master -a secret_trade aztec-wallet add-authwit authwits:secret_trade accounts:jedi_master -f accounts:coruscant_trader ``` @@ -117,7 +117,7 @@ aztec-wallet add-authwit authwits:secret_trade accounts:jedi_master -f accounts: A similar call to the above, but in public: ```bash -aztec-wallet authorize-action transfer_public accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master +aztec-wallet authorize-action transfer_in_public accounts:coruscant_trader -ca contracts:token --args accounts:jedi_master accounts:coruscant_trader 20 secrets:auth_nonce -f accounts:jedi_master ``` ### Simulate diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md b/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md index dfd7d5530ef5..cfe794984f6a 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md +++ b/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md @@ -210,8 +210,6 @@ The `insert_from_public` allow public function to insert notes into private stor The usage is similar to using the `insert` method with the difference that this one is called in public functions. -#include_code insert_from_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust - ### `pop_notes` This function pops (gets, removes and returns) the notes the account has access to based on the provided filter. diff --git a/docs/docs/tutorials/codealong/aztecjs-getting-started.md b/docs/docs/tutorials/codealong/aztecjs-getting-started.md index e0f03f62b9b3..72168fc5da55 100644 --- a/docs/docs/tutorials/codealong/aztecjs-getting-started.md +++ b/docs/docs/tutorials/codealong/aztecjs-getting-started.md @@ -283,7 +283,7 @@ Our output should now look like this: Here, we used the same contract abstraction as was previously used for reading Alice's balance. But this time we called `send()` generating and sending a transaction to the network. After waiting for the transaction to settle we were able to check the new balance values. Finally, the contract has 2 `mint` functions that can be used to generate new tokens for an account. -We will focus only on `mint_private`. +We will focus only on `mint_to_private`. This function is public but it mints tokens privately. This function takes: diff --git a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md b/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md index 73d04e960b9f..fc9b89d6b24b 100644 --- a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md +++ b/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md @@ -103,9 +103,9 @@ You should get a prompt to sign this transaction. You can now mint, transfer, an ```bash aztec-wallet create-account -a new_recipient # creating a schnorr account -aztec-wallet send mint_public -ca last --args accounts:my-wallet 10 -f accounts:my-wallet # minting some tokens in public +aztec-wallet send mint_to_public -ca last --args accounts:my-wallet 10 -f accounts:my-wallet # minting some tokens in public aztec-wallet simulate balance_of_public -ca contracts:devtoken --args accounts:my-wallet -f my-wallet # checking that my-wallet has 10 tokens -aztec-wallet send transfer_public -ca contracts:devtoken --args accounts:my-wallet accounts:new_recipient 10 0 -f accounts:my-wallet # transferring some tokens in public +aztec-wallet send transfer_in_public -ca contracts:devtoken --args accounts:my-wallet accounts:new_recipient 10 0 -f accounts:my-wallet # transferring some tokens in public aztec-wallet simulate balance_of_public -ca contracts:devtoken --args accounts:new_recipient -f my-wallet # checking that new_recipient has 10 tokens ``` diff --git a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md index 0d7632cc1bc2..cb426b2ef987 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md +++ b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md @@ -57,7 +57,7 @@ Here is an explanation of what it is doing: - The content is limited to a single field (~254 bits). So if the content is larger, we have to hash it and the hash can be passed along. - We use our utility method that creates a sha256 hash but truncates it to fit into a field - Since we want to mint tokens on Aztec publicly, the content here is the amount to mint and the address on Aztec who will receive the tokens. - - We encode this message as a mint_public function call, to specify the exact intentions and parameters we want to execute on L2. + - We encode this message as a mint_to_public function call, to specify the exact intentions and parameters we want to execute on L2. - In reality the content can be constructed in any manner as long as the sister contract on L2 can also create it. But for clarity, we are constructing the content like an ABI encoded function call. - It is good practice to include all parameters used by L2 into this content (like the amount and to) so that a malicious actor can’t change the to to themselves when consuming the message. 3. The tokens are transferred from the user to the portal using `underlying.safeTransferFrom()`. This puts the funds under the portal's control. @@ -78,8 +78,7 @@ Let’s do the similar for the private flow: Here we want to send a message to mint tokens privately on Aztec! Some key differences from the previous method are: -- The content hash uses a different function name - `mint_private`. This is done to make it easy to separate concerns. If the contentHash between the public and private message was the same, then an attacker could consume a private message publicly! -- Since we want to mint tokens privately, we shouldn’t specify a `to` Aztec address (remember that Ethereum is completely public). Instead, we will use a secret hash - `secretHashForRedeemingMintedNotes`. Only he who knows the preimage to the secret hash can actually mint the notes. This is similar to the mechanism we use for message consumption on L2 +- The content hash uses a different function name - `mint_to_private`. This is done to make it easy to separate concerns. If the contentHash between the public and private message was the same, then an attacker could consume a private message publicly! - Like with the public flow, we move the user’s funds to the portal - We now send the message to the inbox with the `recipient` (the sister contract on L2 along with the version of aztec the message is intended for) and the `secretHashForL2MessageConsumption` (such that on L2, the consumption of the message can be private). diff --git a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/2_minting_on_aztec.md b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/2_minting_on_aztec.md index 7316793ec39e..8effc323e744 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/2_minting_on_aztec.md +++ b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/2_minting_on_aztec.md @@ -28,15 +28,15 @@ The `claim_public` function enables anyone to consume the message on the user's **What’s happening here?** -1. We first recompute the L1->L2 message content by calling `get_mint_public_content_hash()`. Note that the method does exactly the same as what the TokenPortal contract does in `depositToAztecPublic()` to create the content hash. +1. We first recompute the L1->L2 message content by calling `get_mint_to_public_content_hash()`. Note that the method does exactly the same as what the TokenPortal contract does in `depositToAztecPublic()` to create the content hash. 2. We then attempt to consume the L1->L2 message. Since we are depositing to Aztec publicly, all of the inputs are public. - `context.consume_l1_to_l2_message()` takes in the few parameters: - - `content_hash`: The content - which is reconstructed in the `get_mint_public_content_hash()` + - `content_hash`: The content - which is reconstructed in the `get_mint_to_public_content_hash()` - `secret`: The secret used for consumption, often 0 for public messages - `sender`: Who on L1 sent the message. Which should match the stored `portal_address` in our case as we only want to allow messages from a specific sender. - `message_leaf_index`: The index in the message tree of the message. - Note that the `content_hash` requires `to` and `amount`. If a malicious user tries to mint tokens to their address by changing the to address, the content hash will be different to what the token portal had calculated on L1 and thus not be in the tree, failing the consumption. This is why we add these parameters into the content. -3. Then we call `Token::at(storage.token.read()).mint_public()` to mint the tokens to the to address. +3. Then we call `Token::at(storage.token.read()).mint_to_public()` to mint the tokens to the to address. ## Private flow @@ -46,12 +46,12 @@ Now we will create a function to mint the amount privately. Paste this into your #include_code call_mint_on_token /noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr rust -The `get_mint_private_content_hash` function is imported from the `token_portal_content_hash_lib`. +The `get_mint_to_private_content_hash` function is imported from the `token_portal_content_hash_lib`. -If the content hashes were constructed similarly for `mint_private` and `mint_publicly`, then content intended for private execution could have been consumed by calling the `claim_public` method. By making these two content hashes distinct, we prevent this scenario. +If the content hashes were constructed similarly for `mint_to_private` and `mint_to_public`, then content intended for private execution could have been consumed by calling the `claim_public` method. By making these two content hashes distinct, we prevent this scenario. While we mint the tokens on L2, we _still don’t actually mint them to a certain address_. Instead we continue to pass the `secret_hash_for_redeeming_minted_notes` like we did on L1. This means that a user could reveal their secret for L2 message consumption for anyone to mint tokens on L2 but they can redeem these notes at a later time. **This enables a paradigm where an app can manage user’s secrets for L2 message consumption on their behalf**. **The app or any external party can also mint tokens on the user’s behalf should they be comfortable with leaking the secret for L2 Message consumption.** This doesn’t leak any new information to the app because their smart contract on L1 knew that a user wanted to move some amount of tokens to L2. The app still doesn’t know which address on L2 the user wants these notes to be in, but they can mint tokens nevertheless on their behalf. -To mint tokens privately, `claim_private` calls an internal function `_call_mint_on_token()` which then calls [token.mint_private()](../../token_contract.md#mint_private). +To mint tokens privately, `claim_private` calls an internal function `_call_mint_on_token()` which then calls [token.mint_to_private()](../../token_contract.md#mint_to_private). In the next step we will see how we can cancel a message. diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md b/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md index c9b9410d4168..c94c39534e72 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md +++ b/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md @@ -67,20 +67,18 @@ These are functions that have transparent logic, will execute in a publicly veri - `set_admin` enables the admin to be updated - `set_minter` enables accounts to be added / removed from the approved minter list -- `mint_public` enables tokens to be minted to the public balance of an account -- `mint_private` enables tokens to be minted to the private balance of an account (with some caveats we will dig into) -- `shield` enables tokens to be moved from a public balance to a private balance, not necessarily the same account (step 1 of a 2 step process) -- `transfer_public` enables users to transfer tokens from one account's public balance to another account's public balance +- `mint_to_public` enables tokens to be minted to the public balance of an account +- `mint_to_private` enables tokens to be minted to the private balance of an account (with some caveats we will dig into) +- `transfer_to_public` enables tokens to be moved from a public balance to a private balance, not necessarily the same account (step 1 of a 2 step process) +- `transfer_in_public` enables users to transfer tokens from one account's public balance to another account's public balance - `burn_public` enables users to burn tokens ### Private functions These are functions that have private logic and will be executed on user devices to maintain privacy. The only data that is submitted to the network is a proof of correct execution, new data commitments and nullifiers, so users will not reveal which contract they are interacting with or which function they are executing. The only information that will be revealed publicly is that someone executed a private transaction on Aztec. -- `redeem_shield` enables accounts to claim tokens that have been made private via `mint_private` or `shield` by providing the secret -- `transfer_to_public` enables an account to send tokens from their private balance to any other account's public balance - `transfer` enables an account to send tokens from their private balance to another account's private balance -- `transfer_from` enables an account to send tokens from another account's private balance to another account's private balance +- `transfer_in_private` enables an account to send tokens from another account's private balance to another account's private balance - `cancel_authwit` enables an account to cancel an authorization to spend tokens - `burn` enables tokens to be burned privately @@ -160,7 +158,6 @@ Reading through the storage variables: - `minters` is a mapping of Aztec addresses in public state. This will store whether an account is an approved minter on the contract. - `balances` is a mapping of private balances. Private balances are stored in a `PrivateSet` of `UintNote`s. The balance is the sum of all of an account's `UintNote`s. - `total_supply` is an unsigned integer (max 128 bit value) stored in public state and represents the total number of tokens minted. -- `pending_shields` is a `PrivateSet` of `TransparentNote`s stored in private state. What is stored publicly is a set of commitments to `TransparentNote`s. - `public_balances` is a mapping of Aztec addresses in public state and represents the publicly viewable balances of accounts. - `symbol`, `name`, and `decimals` are similar in meaning to ERC20 tokens on Ethereum. @@ -178,7 +175,7 @@ This function sets the creator of the contract (passed as `msg_sender` from the Public functions are declared with the `#[public]` macro above the function name. -As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to prepare data to be used in a private context, as we will go over below (e.g. see the [shield](#shield) function). +As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to finalize prepared in a private context (partial notes flow). Storage is referenced as `storage.variable`. @@ -194,27 +191,33 @@ This function allows the `admin` to add or a remove a `minter` from the public ` #include_code set_minter /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust -#### `mint_public` +#### `mint_to_public` This function allows an account approved in the public `minters` mapping to create new public tokens owned by the provided `to` address. First, storage is initialized. Then the function checks that the `msg_sender` is approved to mint in the `minters` mapping. If it is, a new `U128` value is created of the `amount` provided. The function reads the recipients public balance and then adds the amount to mint, saving the output as `new_balance`, then reads to total supply and adds the amount to mint, saving the output as `supply`. `new_balance` and `supply` are then written to storage. -#include_code mint_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code mint_to_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust -#### `mint_private` +#### `mint_to_private` -This public function allows an account approved in the public `minters` mapping to create new private tokens that can be claimed by anyone that has the pre-image to the `secret_hash`. +This public function allows an account approved in the public `minters` mapping to create new private tokens. -First, public storage is initialized. Then it checks that the `msg_sender` is an approved minter. Then a new `TransparentNote` is created with the specified `amount` and `secret_hash`. You can read the details of the `TransparentNote` in the `types.nr` file [here (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/noir-contracts/contracts/token_contract/src/types.nr#L61). The `amount` is added to the existing public `total_supply` and the storage value is updated. Then the new `TransparentNote` is added to the `pending_shields` using the `insert_from_public` function, which is accessible on the `PrivateSet` type. Then it's ready to be claimed by anyone with the `secret_hash` pre-image using the `redeem_shield` function. +First, partial note is prepared by the call to `_prepare_private_balance_increase` for the minted tokens recipient. Then a public call to `_finalize_mint_to_private_unsafe` is enqueued while `msg_sender`, `amount` and the `hiding_point_slot` are passed in via arguments. Since we set `from` to `msg_sender` here the usage of the unsafe function is safe. The enqueued call then checks the minter permissions of `from` and it finalizes the partial note for `to`. -#include_code mint_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code mint_to_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust -#### `shield` +#### `transfer_to_private` -This public function enables an account to stage tokens from it's `public_balance` to be claimed as a private `TransparentNote` by any account that has the pre-image to the `secret_hash`. +This public function enables an account to send tokens from its `public_balance` to a private balance of an arbitrary recipient. -First, storage is initialized. Then it checks whether the calling contract (`context.msg_sender`) matches the account that the funds will be debited from. +First a partial note is prepared then a call to `_finalize_transfer_to_private_unsafe` is enqueued. The enqueued public call subtracts the `amount` from public balance of `msg_sender` and finalizes the partial note with the `amount`. + +#include_code transfer_to_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust + +#### `transfer_in_public` + +This public function enables public transfers between Aztec accounts. The sender's public balance will be debited the specified `amount` and the recipient's public balances will be credited with that amount. ##### Authorizing token spends @@ -224,15 +227,7 @@ If the `msg_sender` is the same as the account to debit tokens from, the authori It returns `1` to indicate successful execution. -#include_code shield /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust - -#### `transfer_public` - -This public function enables public transfers between Aztec accounts. The sender's public balance will be debited the specified `amount` and the recipient's public balances will be credited with that amount. - -After storage is initialized, the [authorization flow specified above](#authorizing-token-spends) is checked. Then the sender and recipient's balances are updated and saved to storage. - -#include_code transfer_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code transfer_in_public /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust #### `burn_public` @@ -248,26 +243,16 @@ Private functions are declared with the `#[private]` macro above the function na ```rust #[private] - fn redeem_shield( + fn transfer_to_public( ``` As described in the [execution contexts section above](#execution-contexts), private function logic and transaction information is hidden from the world and is executed on user devices. Private functions update private state, but can pass data to the public execution context (e.g. see the [`transfer_to_public`](#transfer_to_public) function). Storage is referenced as `storage.variable`. -#### `redeem_shield` - -This private function enables an account to move tokens from a `TransparentNote` in the `pending_shields` mapping to a `UintNote` in private `balances`. The `UintNote` will be associated with a nullifier key, so any account that knows this key can spend this note. - -Going through the function logic, first the `secret_hash` is generated from the given secret. This ensures that only the entity possessing the secret can use it to redeem the note. Following this, a `TransparentNote` is retrieved from the set, using the provided amount and secret. The note is subsequently removed from the set, allowing it to be redeemed only once. The recipient's private balance is then increased using the `increment` helper function from the `value_note` [library (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/value-note/src/utils.nr). - -The function returns `1` to indicate successful execution. - -#include_code redeem_shield /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust - #### `transfer_to_public` -This private function enables un-shielding of private `UintNote`s stored in `balances` to any Aztec account's `public_balance`. +This private function enables transferring of private balance (`UintNote` stored in `balances`) to any Aztec account's `public_balance`. After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. See [the Authorizing token spends section](#authorizing-token-spends) above for more detail--the only difference being that `assert_valid_message_for` is modified to work specifically in the private context. After the authorization check, the sender's private balance is decreased using the `decrement` helper function for the `value_note` library. Then it stages a public function call on this contract ([`_increase_public_balance`](#_increase_public_balance)) to be executed in the [public execution phase](#execution-contexts) of transaction execution. `_increase_public_balance` is marked as an `internal` function, so can only be called by this token contract. @@ -283,19 +268,19 @@ After initializing storage, the function checks that the `msg_sender` is authori #include_code transfer /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust -#### `transfer_from` +#### `transfer_in_private` This private function enables an account to transfer tokens on behalf of another account. The account that tokens are being debited from must have authorized the `msg_sender` to spend tokens on its behalf. -#include_code transfer_from /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code transfer_in_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust -#### `burn` +#### `burn_private` This private function enables accounts to privately burn (destroy) tokens. After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. Then it gets the sender's current balance and decrements it. Finally it stages a public function call to [`_reduce_total_supply`](#_reduce_total_supply). -#include_code burn /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust +#include_code burn_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust ### Internal function implementations @@ -303,7 +288,7 @@ Internal functions are functions that can only be called by this contract. The f #### `_increase_public_balance` -This function is called from [`transfer_to_public`](#transfer_to_public). The account's private balance is decremented in `shield` and the public balance is increased in this function. +This function is called from [`transfer_to_public`](#transfer_to_public). The account's private balance is decremented in `transfer_to_public` and the public balance is increased in this function. #include_code increase_public_balance /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust diff --git a/docs/docs/tutorials/examples/uniswap/l2_contract.md b/docs/docs/tutorials/examples/uniswap/l2_contract.md index b8f9101e7a13..f1f311043259 100644 --- a/docs/docs/tutorials/examples/uniswap/l2_contract.md +++ b/docs/docs/tutorials/examples/uniswap/l2_contract.md @@ -47,7 +47,7 @@ This uses a util function `compute_swap_private_content_hash()` - find that [her This flow works similarly to the public flow with a few notable changes: - Notice how in the `swap_private()`, user has to pass in `token` address which they didn't in the public flow? Since `swap_private()` is a private method, it can't read what token is publicly stored on the token bridge, so instead the user passes a token address, and `_assert_token_is_same()` checks that this user provided address is same as the one in storage. Note that because public functions are executed by the sequencer while private methods are executed locally, all public calls are always done after all private calls are done. So first the burn would happen and only later the sequencer asserts that the token is same. Note that the sequencer just sees a request to `execute_assert_token_is_same` and therefore has no context on what the appropriate private method was. If the assertion fails, then the kernel circuit will fail to create a proof and hence the transaction will be dropped. -- In the public flow, the user calls `transfer_public()`. Here instead, the user calls `transfer_to_public()`. Why? The user can't directly transfer their private tokens (their notes) to the uniswap contract, because later the Uniswap contract has to approve the bridge to burn these notes and withdraw to L1. The authwit flow for the private domain requires a signature from the `sender`, which in this case would be the Uniswap contract. For the contract to sign, it would need a private key associated to it. But who would operate this key? +- In the public flow, the user calls `transfer_in_public()`. Here instead, the user calls `transfer_to_public()`. Why? The user can't directly transfer their private tokens (their notes) to the uniswap contract, because later the Uniswap contract has to approve the bridge to burn these notes and withdraw to L1. The authwit flow for the private domain requires a signature from the `sender`, which in this case would be the Uniswap contract. For the contract to sign, it would need a private key associated to it. But who would operate this key? - To work around this, the user can transfer to public their private tokens into Uniswap L2 contract. Transferring to public would convert user's private notes to public balance. It is a private method on the token contract that reduces a user’s private balance and then calls a public method to increase the recipient’s (ie Uniswap) public balance. **Remember that first all private methods are executed and then later all public methods will be - so the Uniswap contract won’t have the funds until public execution begins.** - Now uniswap has public balance (like with the public flow). Hence, `swap_private()` calls the internal public method which approves the input token bridge to burn Uniswap’s tokens and calls `exit_to_l1_public` to create an L2 → L1 message to exit to L1. - Constructing the message content for swapping works exactly as the public flow except instead of specifying who would be the Aztec address that receives the swapped funds, we specify a secret hash (`secret_hash_for_redeeming_minted_notes`). Only those who know the preimage to the secret can later redeem the minted notes to themselves. diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index dbf806aecb9c..5a630c1ae5fb 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -17,6 +17,7 @@ fs_permissions = [ {access = "read", path = "./test/fixtures/mixed_block_2.json"}, {access = "read", path = "./test/fixtures/empty_block_1.json"}, {access = "read", path = "./test/fixtures/empty_block_2.json"}, + {access = "read", path = "./test/fixtures/fee_data_points.json"} ] [fmt] diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index e8c683f1974d..2f9ba8e4d62e 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -1,6 +1,6 @@ // GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js // SPDX-License-Identifier: Apache-2.0 -// Copyright 2024 Aztec Labs. +// Copyright 2023 Aztec Labs. pragma solidity >=0.8.27; /** @@ -31,6 +31,7 @@ library Constants { uint256 internal constant MAX_NOTE_ENCRYPTED_LOGS_PER_CALL = 16; uint256 internal constant MAX_ENCRYPTED_LOGS_PER_CALL = 4; uint256 internal constant MAX_UNENCRYPTED_LOGS_PER_CALL = 4; + uint256 internal constant MAX_CONTRACT_CLASS_LOGS_PER_CALL = 1; uint256 internal constant ARCHIVE_HEIGHT = 29; uint256 internal constant VK_TREE_HEIGHT = 6; uint256 internal constant PROTOCOL_CONTRACT_TREE_HEIGHT = 3; @@ -70,6 +71,7 @@ library Constants { uint256 internal constant MAX_NOTE_ENCRYPTED_LOGS_PER_TX = 64; uint256 internal constant MAX_ENCRYPTED_LOGS_PER_TX = 8; uint256 internal constant MAX_UNENCRYPTED_LOGS_PER_TX = 8; + uint256 internal constant MAX_CONTRACT_CLASS_LOGS_PER_TX = 1; uint256 internal constant MAX_PUBLIC_DATA_HINTS = 128; uint256 internal constant NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; uint256 internal constant EMPTY_NESTED_INDEX = 0; @@ -97,7 +99,7 @@ library Constants { uint256 internal constant AZTEC_MAX_EPOCH_DURATION = 32; uint256 internal constant GENESIS_ARCHIVE_ROOT = 19007378675971183768036762391356802220352606103602592933942074152320327194720; - uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000; + uint256 internal constant FEE_JUICE_INITIAL_MINT = 200000000000000; uint256 internal constant PUBLIC_DISPATCH_SELECTOR = 3578010381; uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000; uint256 internal constant MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; @@ -202,7 +204,7 @@ library Constants { uint256 internal constant TX_REQUEST_LENGTH = 12; uint256 internal constant TOTAL_FEES_LENGTH = 1; uint256 internal constant HEADER_LENGTH = 24; - uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 499; + uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 490; uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 866; uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 37; uint256 internal constant PUBLIC_CONTEXT_INPUTS_LENGTH = 41; @@ -214,20 +216,20 @@ library Constants { uint256 internal constant NUM_PUBLIC_VALIDATION_REQUEST_ARRAYS = 5; uint256 internal constant PUBLIC_VALIDATION_REQUESTS_LENGTH = 834; uint256 internal constant PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; - uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 545; + uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 550; uint256 internal constant TX_CONSTANT_DATA_LENGTH = 34; uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 43; - uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1064; - uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1877; + uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1036; + uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1849; uint256 internal constant PUBLIC_ACCUMULATED_DATA_LENGTH = 1023; uint256 internal constant NUM_PUBLIC_ACCUMULATED_DATA_ARRAYS = 8; - uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 576; + uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 548; uint256 internal constant PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH = 160; uint256 internal constant NUM_PRIVATE_TO_AVM_ACCUMULATED_DATA_ARRAYS = 3; - uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1196; + uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1140; uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2931; uint256 internal constant VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2340; - uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 600; + uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 605; uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 13; uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 30; uint256 internal constant BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 90; diff --git a/l1-contracts/src/core/libraries/Errors.sol b/l1-contracts/src/core/libraries/Errors.sol index 6e8454bfe33a..a53b8c10f62d 100644 --- a/l1-contracts/src/core/libraries/Errors.sol +++ b/l1-contracts/src/core/libraries/Errors.sol @@ -109,4 +109,8 @@ library Errors { error ProofCommitmentEscrow__InsufficientBalance(uint256 balance, uint256 requested); // 0x09b8b789 error ProofCommitmentEscrow__NotOwner(address caller); // 0x2ac332c1 error ProofCommitmentEscrow__WithdrawRequestNotReady(uint256 current, Timestamp readyAt); // 0xb32ab8a7 + + // FeeMath + error FeeMath__InvalidProvingCostModifier(); // 0x8b9d62ac + error FeeMath__InvalidFeeAssetPriceModifier(); // 0xf2fb32ad } diff --git a/l1-contracts/src/core/libraries/FeeMath.sol b/l1-contracts/src/core/libraries/FeeMath.sol new file mode 100644 index 000000000000..1ffddbc170ca --- /dev/null +++ b/l1-contracts/src/core/libraries/FeeMath.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. +pragma solidity >=0.8.27; + +import {Math} from "@oz/utils/math/Math.sol"; +import {SafeCast} from "@oz/utils/math/SafeCast.sol"; +import {SignedMath} from "@oz/utils/math/SignedMath.sol"; + +import {Errors} from "./Errors.sol"; + +struct OracleInput { + int256 provingCostModifier; + int256 feeAssetPriceModifier; +} + +library FeeMath { + using Math for uint256; + using SafeCast for int256; + using SafeCast for uint256; + using SignedMath for int256; + + // These values are taken from the model, but mostly pulled out of the ass + uint256 internal constant MINIMUM_PROVING_COST_PER_MANA = 5415357955; + uint256 internal constant MAX_PROVING_COST_MODIFIER = 1000000000; + uint256 internal constant PROVING_UPDATE_FRACTION = 100000000000; + + uint256 internal constant MINIMUM_FEE_ASSET_PRICE = 10000000000; + uint256 internal constant MAX_FEE_ASSET_PRICE_MODIFIER = 1000000000; + uint256 internal constant FEE_ASSET_PRICE_UPDATE_FRACTION = 100000000000; + + function assertValid(OracleInput memory _self) internal pure returns (bool) { + require( + SignedMath.abs(_self.provingCostModifier) <= MAX_PROVING_COST_MODIFIER, + Errors.FeeMath__InvalidProvingCostModifier() + ); + require( + SignedMath.abs(_self.feeAssetPriceModifier) <= MAX_FEE_ASSET_PRICE_MODIFIER, + Errors.FeeMath__InvalidFeeAssetPriceModifier() + ); + return true; + } + + function clampedAdd(uint256 _a, int256 _b) internal pure returns (uint256) { + if (_b >= 0) { + return _a + _b.toUint256(); + } + + uint256 sub = SignedMath.abs(_b); + + if (_a > sub) { + return _a - sub; + } + + return 0; + } + + function provingCostPerMana(uint256 _numerator) internal pure returns (uint256) { + return fakeExponential(MINIMUM_PROVING_COST_PER_MANA, _numerator, PROVING_UPDATE_FRACTION); + } + + function feeAssetPriceModifier(uint256 _numerator) internal pure returns (uint256) { + return fakeExponential(MINIMUM_FEE_ASSET_PRICE, _numerator, FEE_ASSET_PRICE_UPDATE_FRACTION); + } + + function fakeExponential(uint256 _factor, uint256 _numerator, uint256 _denominator) + private + pure + returns (uint256) + { + uint256 i = 1; + uint256 output = 0; + uint256 numeratorAccumulator = _factor * _denominator; + while (numeratorAccumulator > 0) { + output += numeratorAccumulator; + numeratorAccumulator = (numeratorAccumulator * _numerator) / (_denominator * i); + i += 1; + } + return output / _denominator; + } +} diff --git a/l1-contracts/src/core/libraries/TxsDecoder.sol b/l1-contracts/src/core/libraries/TxsDecoder.sol index 287491a8ec59..9bf8ef5329ea 100644 --- a/l1-contracts/src/core/libraries/TxsDecoder.sol +++ b/l1-contracts/src/core/libraries/TxsDecoder.sol @@ -56,6 +56,7 @@ library TxsDecoder { uint256 noteEncryptedLogsLength; uint256 encryptedLogsLength; uint256 unencryptedLogsLength; + uint256 contractClassLogsLength; } struct Counts { @@ -72,9 +73,11 @@ library TxsDecoder { uint256 kernelNoteEncryptedLogsLength; uint256 kernelEncryptedLogsLength; uint256 kernelUnencryptedLogsLength; + uint256 kernelContractClassLogsLength; bytes32 noteEncryptedLogsHash; bytes32 encryptedLogsHash; bytes32 unencryptedLogsHash; + bytes32 contractClassLogsHash; bytes32 txOutHash; } @@ -166,8 +169,12 @@ library TxsDecoder { offsets.unencryptedLogsLength = offset; offset += 0x20; + // CONTRACT CLASS LOGS LENGTH + offsets.contractClassLogsLength = offset; + offset += 0x20; + /** - * Compute note, encrypted and unencrypted logs hashes corresponding to the current leaf. + * Compute note, encrypted, unencrypted, and contract class logs hashes corresponding to the current leaf. * Note: will advance offsets by the number of bytes processed. */ // NOTE ENCRYPTED LOGS HASH @@ -178,7 +185,11 @@ library TxsDecoder { computeKernelEncryptedLogsHash(offset, _body); // UNENCRYPTED LOGS HASH (vars.unencryptedLogsHash, offset, vars.kernelUnencryptedLogsLength) = - computeKernelUnencryptedLogsHash(offset, _body); + computeKernelUnencryptedLogsHash(offset, _body, false); + // CONTRACT CLASS LOGS HASH + // Note: the logic for unenc. and contract class logs hashing is the same: + (vars.contractClassLogsHash, offset, vars.kernelContractClassLogsLength) = + computeKernelUnencryptedLogsHash(offset, _body, true); // TX LEVEL OUT HASH (vars.txOutHash) = computeTxOutHash(offsets.l2ToL1Msgs, _body); @@ -208,6 +219,14 @@ library TxsDecoder { vars.kernelUnencryptedLogsLength ) ); + require( + uint256(bytes32(slice(_body, offsets.contractClassLogsLength, 0x20))) + == vars.kernelContractClassLogsLength, + Errors.TxsDecoder__InvalidLogsLength( + uint256(bytes32(slice(_body, offsets.contractClassLogsLength, 0x20))), + vars.kernelContractClassLogsLength + ) + ); // Insertions are split into multiple `bytes.concat` to work around stack too deep. vars.baseLeaf = bytes.concat( @@ -239,10 +258,18 @@ library TxsDecoder { ), bytes.concat( slice(_body, offsets.noteEncryptedLogsLength, 0x20), - slice(_body, offsets.encryptedLogsLength, 0x20), - slice(_body, offsets.unencryptedLogsLength, 0x20) + slice(_body, offsets.encryptedLogsLength, 0x20) + ), + bytes.concat( + slice(_body, offsets.unencryptedLogsLength, 0x20), + slice(_body, offsets.contractClassLogsLength, 0x20) ), - bytes.concat(vars.noteEncryptedLogsHash, vars.encryptedLogsHash, vars.unencryptedLogsHash) + bytes.concat( + vars.noteEncryptedLogsHash, + vars.encryptedLogsHash, + vars.unencryptedLogsHash, + vars.contractClassLogsHash + ) ); vars.baseLeaves[i] = Hash.sha256ToField(vars.baseLeaf); @@ -251,7 +278,7 @@ library TxsDecoder { // We pad base leaves with hashes of empty tx effect. for (uint256 i = numTxEffects; i < vars.baseLeaves.length; i++) { // Value taken from tx_effect.test.ts "hash of empty tx effect matches snapshot" test case - vars.baseLeaves[i] = hex"00f0aa51fc81f8242316fcf2cb3b28196241ed3fa26dd320a959bce6c529b270"; + vars.baseLeaves[i] = hex"00c2dece9c9f14c67b8aafabdcb80793f1cffe95a801e15d648fd214a0522ee8"; } } @@ -421,18 +448,18 @@ library TxsDecoder { } /** - * @notice Computes unencrypted logs hash as is done in the kernel circuits. + * @notice Computes unencrypted or contract class logs hash as is done in the kernel circuits. * @param _offsetInBlock - The offset of kernel's logs in a block. * @param _body - The L2 block calldata. * @return The hash of the logs and offset in a block after processing the logs. - * @dev See above for details. The only difference here is that unencrypted logs are + * @dev See above for details. The only difference here is that unencrypted and contract class logs are * siloed with their contract address. */ - function computeKernelUnencryptedLogsHash(uint256 _offsetInBlock, bytes calldata _body) - internal - pure - returns (bytes32, uint256, uint256) - { + function computeKernelUnencryptedLogsHash( + uint256 _offsetInBlock, + bytes calldata _body, + bool _contractClassLogs + ) internal pure returns (bytes32, uint256, uint256) { uint256 offset = _offsetInBlock; uint256 remainingLogsLength = read4(_body, offset); uint256 kernelLogsLength = remainingLogsLength; @@ -473,10 +500,17 @@ library TxsDecoder { } // padded to MAX_LOGS * 32 bytes - flattenedLogHashes = bytes.concat( - flattenedLogHashes, - new bytes(Constants.MAX_UNENCRYPTED_LOGS_PER_TX * 32 - flattenedLogHashes.length) - ); + if (_contractClassLogs) { + flattenedLogHashes = bytes.concat( + flattenedLogHashes, + new bytes(Constants.MAX_CONTRACT_CLASS_LOGS_PER_TX * 32 - flattenedLogHashes.length) + ); + } else { + flattenedLogHashes = bytes.concat( + flattenedLogHashes, + new bytes(Constants.MAX_UNENCRYPTED_LOGS_PER_TX * 32 - flattenedLogHashes.length) + ); + } bytes32 kernelPublicInputsLogsHash = Hash.sha256ToField(flattenedLogHashes); diff --git a/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol b/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol index db038cfe772a..fc68df1a4441 100644 --- a/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol +++ b/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol @@ -81,6 +81,8 @@ contract DepositToAztecPublic is Test { uint256 amount = 100 ether; uint256 expectedIndex = 2 ** Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT; + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. DataStructures.L1ToL2Msg memory message = DataStructures.L1ToL2Msg({ sender: DataStructures.L1Actor(address(feeJuicePortal), block.chainid), recipient: DataStructures.L2Actor(feeJuicePortal.L2_TOKEN_ADDRESS(), 1 + numberOfRollups), diff --git a/l1-contracts/test/fees/FeeModelTestPoints.t.sol b/l1-contracts/test/fees/FeeModelTestPoints.t.sol new file mode 100644 index 000000000000..1bd2c6f48f41 --- /dev/null +++ b/l1-contracts/test/fees/FeeModelTestPoints.t.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. +// solhint-disable var-name-mixedcase +pragma solidity >=0.8.27; + +import {Test} from "forge-std/Test.sol"; + +// Remember that foundry json parsing is alphabetically done, so you MUST +// sort the struct fields alphabetically or prepare for a headache. + +struct L1Fees { + uint256 base_fee; + uint256 blob_fee; +} + +struct Header { + uint256 excess_mana; + uint256 fee_asset_price_numerator; + uint256 mana_used; + uint256 proving_cast_per_mana_numerator; +} + +struct OracleInput { + int256 fee_asset_price_modifier; + int256 proving_cost_modifier; +} + +struct ManaBaseFeeComponents { + uint256 congestion_cost; + uint256 congestion_multiplier; + uint256 data_cost; + uint256 gas_cost; + uint256 proving_cost; +} + +struct TestPointOutputs { + uint256 fee_asset_price_at_execution; + ManaBaseFeeComponents mana_base_fee_components_in_fee_asset; + ManaBaseFeeComponents mana_base_fee_components_in_wei; +} + +struct TestPoint { + uint256 l1_block_number; + L1Fees l1_fees; + Header header; + OracleInput oracle_input; + TestPointOutputs outputs; + Header parent_header; +} + +contract FeeModelTestPoints is Test { + TestPoint[] public points; + + constructor() { + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/test/fixtures/fee_data_points.json"); + string memory json = vm.readFile(path); + bytes memory jsonBytes = vm.parseJson(json); + TestPoint[] memory dataPoints = abi.decode(jsonBytes, (TestPoint[])); + + for (uint256 i = 0; i < dataPoints.length; i++) { + points.push(dataPoints[i]); + } + } +} diff --git a/l1-contracts/test/fees/MinimalFeeModel.sol b/l1-contracts/test/fees/MinimalFeeModel.sol new file mode 100644 index 000000000000..d0e8b649f774 --- /dev/null +++ b/l1-contracts/test/fees/MinimalFeeModel.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. +pragma solidity >=0.8.27; + +import {FeeMath, OracleInput} from "@aztec/core/libraries/FeeMath.sol"; + +contract MinimalFeeModel { + using FeeMath for OracleInput; + using FeeMath for uint256; + + struct DataPoint { + uint256 provingCostNumerator; + uint256 feeAssetPriceNumerator; + } + + uint256 public populatedThrough = 0; + mapping(uint256 _slotNumber => DataPoint _dataPoint) public dataPoints; + + constructor() { + dataPoints[0] = DataPoint({provingCostNumerator: 0, feeAssetPriceNumerator: 0}); + } + + // See the `add_slot` function in the `fee-model.ipynb` notebook for more context. + function addSlot(OracleInput memory _oracleInput) public { + _oracleInput.assertValid(); + + DataPoint memory parent = dataPoints[populatedThrough]; + + dataPoints[++populatedThrough] = DataPoint({ + provingCostNumerator: parent.provingCostNumerator.clampedAdd(_oracleInput.provingCostModifier), + feeAssetPriceNumerator: parent.feeAssetPriceNumerator.clampedAdd( + _oracleInput.feeAssetPriceModifier + ) + }); + } + + function getFeeAssetPrice(uint256 _slotNumber) public view returns (uint256) { + return FeeMath.feeAssetPriceModifier(dataPoints[_slotNumber].feeAssetPriceNumerator); + } + + function getProvingCost(uint256 _slotNumber) public view returns (uint256) { + return FeeMath.provingCostPerMana(dataPoints[_slotNumber].provingCostNumerator); + } +} diff --git a/l1-contracts/test/fees/MinimalFeeModel.t.sol b/l1-contracts/test/fees/MinimalFeeModel.t.sol new file mode 100644 index 000000000000..2cf0b787235f --- /dev/null +++ b/l1-contracts/test/fees/MinimalFeeModel.t.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.27; + +import {OracleInput, FeeMath} from "@aztec/core/libraries/FeeMath.sol"; +import {FeeModelTestPoints} from "./FeeModelTestPoints.t.sol"; +import {MinimalFeeModel} from "./MinimalFeeModel.sol"; +import {Errors} from "@aztec/core/libraries/Errors.sol"; + +contract MinimalFeeModelTest is FeeModelTestPoints { + MinimalFeeModel internal feeContract; + + function setUp() public { + feeContract = new MinimalFeeModel(); + + for (uint256 i = 0; i < points.length; i++) { + feeContract.addSlot( + OracleInput({ + provingCostModifier: points[i].oracle_input.proving_cost_modifier, + feeAssetPriceModifier: points[i].oracle_input.fee_asset_price_modifier + }) + ); + } + } + + function test_computeProvingCost() public { + for (uint256 i = 0; i < points.length; i++) { + assertEq( + feeContract.getProvingCost(i), + points[i].outputs.mana_base_fee_components_in_wei.proving_cost, + "Computed proving cost does not match expected value" + ); + } + } + + function test_computeFeeAssetPrice() public { + for (uint256 i = 0; i < points.length; i++) { + assertEq( + feeContract.getFeeAssetPrice(i), + points[i].outputs.fee_asset_price_at_execution, + "Computed fee asset price does not match expected value" + ); + } + } + + function test_invalidOracleInput() public { + uint256 provingBoundary = FeeMath.MAX_PROVING_COST_MODIFIER + 1; + uint256 feeAssetPriceBoundary = FeeMath.MAX_FEE_ASSET_PRICE_MODIFIER + 1; + + vm.expectRevert(abi.encodeWithSelector(Errors.FeeMath__InvalidProvingCostModifier.selector)); + feeContract.addSlot( + OracleInput({provingCostModifier: int256(provingBoundary), feeAssetPriceModifier: 0}) + ); + + vm.expectRevert(abi.encodeWithSelector(Errors.FeeMath__InvalidProvingCostModifier.selector)); + feeContract.addSlot( + OracleInput({provingCostModifier: -int256(provingBoundary), feeAssetPriceModifier: 0}) + ); + + vm.expectRevert(abi.encodeWithSelector(Errors.FeeMath__InvalidFeeAssetPriceModifier.selector)); + feeContract.addSlot( + OracleInput({provingCostModifier: 0, feeAssetPriceModifier: int256(feeAssetPriceBoundary)}) + ); + + vm.expectRevert(abi.encodeWithSelector(Errors.FeeMath__InvalidFeeAssetPriceModifier.selector)); + feeContract.addSlot( + OracleInput({provingCostModifier: 0, feeAssetPriceModifier: -int256(feeAssetPriceBoundary)}) + ); + } +} diff --git a/l1-contracts/test/fixtures/empty_block_1.json b/l1-contracts/test/fixtures/empty_block_1.json index 3502a5f7b9e3..0070d3ebdd8e 100644 --- a/l1-contracts/test/fixtures/empty_block_1.json +++ b/l1-contracts/test/fixtures/empty_block_1.json @@ -8,25 +8,25 @@ "l2ToL1Messages": [] }, "block": { - "archive": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f", - "blockHash": "0x1e273844400064424f4b091fd7944446a32bb7a96d8bf69a05e32f01a1a40cde", + "archive": "0x1f80d0f24457c066a8b752a2c424ee0c8bd61143db120fa0841d0f4233f7e21d", + "blockHash": "0x267f79fe7e757b20e924fac9f78264a0d1c8c4b481fea21d0bbe74650d87a1f1", "body": "0x00000000", - "txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6", + "txsEffectsHash": "0x002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c9", "decodedHeader": { "contentCommitment": { "inHash": "0x00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c", "outHash": "0x00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb", "numTxs": 2, - "txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6" + "txsEffectsHash": "0x002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c9" }, "globalVariables": { "blockNumber": 1, "slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000012", "chainId": 31337, - "timestamp": 1731107199, + "timestamp": 1731434785, "version": 1, - "coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2", - "feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26", + "coinbase": "0x4f6cd865d580ac0011a4776d8dc51db519c2318a", + "feeRecipient": "0x1ae8b5e1d9882013ea5271b1e71b307bc48c191549588587a227c8a118834864", "gasFees": { "feePerDaGas": 0, "feePerL2Gas": 0 @@ -57,8 +57,8 @@ } } }, - "header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce190046777986000000001000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000672e997f8a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "publicInputsHash": "0x00fc461dff8a8b9e2397bb5d40053b87281dd9fd28e77834a2749bfc5f32bfb9", + "header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce1900467779860000000010000000000000000000000000000000000000000000000000000000000000002002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c900089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000101fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000000800c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000673399214f6cd865d580ac0011a4776d8dc51db519c2318a1ae8b5e1d9882013ea5271b1e71b307bc48c191549588587a227c8a118834864000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "publicInputsHash": "0x00f45c9ec73df38136aa1fed90362a5df796817e37a36d02df4700f80bc356b2", "numTxs": 0 } } \ No newline at end of file diff --git a/l1-contracts/test/fixtures/empty_block_2.json b/l1-contracts/test/fixtures/empty_block_2.json index 4c6c504350ec..447934f005bc 100644 --- a/l1-contracts/test/fixtures/empty_block_2.json +++ b/l1-contracts/test/fixtures/empty_block_2.json @@ -8,25 +8,25 @@ "l2ToL1Messages": [] }, "block": { - "archive": "0x19b0447418d0e86728db9266ecf57b26b3e4a47388c4241e16f5f9e4b2d20492", - "blockHash": "0x07effa5ee44661e8167d238e02729e739543aa4cfbf619878850a440e021ce72", + "archive": "0x1120ec22c3dd3dd6904b9520f086189726776a41c75c53f8f4cea4a53bc45844", + "blockHash": "0x2d48eea4aa6c13eea47df326e22cd76e74ecc24ee272d6b4207eb5f494f891d3", "body": "0x00000000", - "txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6", + "txsEffectsHash": "0x002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c9", "decodedHeader": { "contentCommitment": { "inHash": "0x00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c", "outHash": "0x00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb", "numTxs": 2, - "txsEffectsHash": "0x00e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d6" + "txsEffectsHash": "0x002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c9" }, "globalVariables": { "blockNumber": 2, "slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000013", "chainId": 31337, - "timestamp": 1731107223, + "timestamp": 1731434809, "version": 1, - "coinbase": "0x8a914126f71d7c294a01833665b9a9019347d6a2", - "feeRecipient": "0x1d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26", + "coinbase": "0x4f6cd865d580ac0011a4776d8dc51db519c2318a", + "feeRecipient": "0x1ae8b5e1d9882013ea5271b1e71b307bc48c191549588587a227c8a118834864", "gasFees": { "feePerDaGas": 0, "feePerL2Gas": 0 @@ -34,7 +34,7 @@ }, "lastArchive": { "nextAvailableLeafIndex": 2, - "root": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f" + "root": "0x1f80d0f24457c066a8b752a2c424ee0c8bd61143db120fa0841d0f4233f7e21d" }, "stateReference": { "l1ToL2MessageTree": { @@ -57,8 +57,8 @@ } } }, - "header": "0x01c96319c544c46399dcc0f48c344210ae5bf846507a202512d3aaa4768aad7f00000002000000000000000000000000000000000000000000000000000000000000000200e994e16b3763fd5039413cf99c2b3c378e2bab939e7992a77bd201b28160d600089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000672e99978a914126f71d7c294a01833665b9a9019347d6a21d2bd70d60e15b1148d6c5590d5ed3dd0427419f862ee389b12abf25481ffd26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "publicInputsHash": "0x006d28d243077e67b4570884f2b6d0b30aba890a326b21308690d5f279e47ab9", + "header": "0x1f80d0f24457c066a8b752a2c424ee0c8bd61143db120fa0841d0f4233f7e21d000000020000000000000000000000000000000000000000000000000000000000000002002dcd61493c9a7f3ce4605573ee657e6ced4a3dd10bfb216f44a796b3d585c900089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c00f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb2e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d6000000201fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb000001000c499b373a1f0fe1b510a63563546d2d39e206895056a5af0143c5f30d6390730000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001300000000000000000000000000000000000000000000000000000000673399394f6cd865d580ac0011a4776d8dc51db519c2318a1ae8b5e1d9882013ea5271b1e71b307bc48c191549588587a227c8a118834864000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "publicInputsHash": "0x0050ad1c615efe79df6f8ed137584b719b7043725a87ff1b1e2a29f22f0827c8", "numTxs": 0 } } \ No newline at end of file diff --git a/l1-contracts/test/fixtures/fee_data_points.json b/l1-contracts/test/fixtures/fee_data_points.json new file mode 100644 index 000000000000..82228b4288d9 --- /dev/null +++ b/l1-contracts/test/fixtures/fee_data_points.json @@ -0,0 +1,26682 @@ +[ + { + "l1_block_number": 20973164, + "l1_fees": { + "blob_fee": 23, + "base_fee": 14402849460 + }, + "parent_header": { + "excess_mana": 0, + "mana_used": 0, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 0, + "mana_used": 199990283, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 669375682 + }, + "oracle_input": { + "proving_cost_modifier": -59048622, + "fee_asset_price_modifier": 669375682 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 47709438, + "proving_cost": 5415357955, + "congestion_cost": 0, + "congestion_multiplier": 1000000000 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 477094380, + "proving_cost": 54153579550, + "congestion_cost": 0, + "congestion_multiplier": 1000000000 + } + } + }, + { + "l1_block_number": 20973167, + "l1_fees": { + "blob_fee": 25, + "base_fee": 14415907878 + }, + "parent_header": { + "excess_mana": 0, + "mana_used": 199990283, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 669375682 + }, + "header": { + "excess_mana": 99990283, + "mana_used": 199990996, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1462908027 + }, + "oracle_input": { + "proving_cost_modifier": -178362315, + "fee_asset_price_modifier": 793532345 + }, + "outputs": { + "fee_asset_price_at_execution": 10067162100, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 47752694, + "proving_cost": 5415357955, + "congestion_cost": 678008355, + "congestion_multiplier": 1124106649 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 480734111, + "proving_cost": 54517286362, + "congestion_cost": 6825620014, + "congestion_multiplier": 1124106649 + } + } + }, + { + "l1_block_number": 20973170, + "l1_fees": { + "blob_fee": 31, + "base_fee": 13994212243 + }, + "parent_header": { + "excess_mana": 99990283, + "mana_used": 199990996, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1462908027 + }, + "header": { + "excess_mana": 199981279, + "mana_used": 199997039, + "proving_cost_per_mana_numerator": 17455936, + "fee_asset_price_numerator": 1631363588 + }, + "oracle_input": { + "proving_cost_modifier": 17455936, + "fee_asset_price_modifier": 168455561 + }, + "outputs": { + "fee_asset_price_at_execution": 10147366089, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 46355828, + "proving_cost": 5415357955, + "congestion_cost": 1439799586, + "congestion_multiplier": 1263616814 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 470389557, + "proving_cost": 54951619672, + "congestion_cost": 14610173493, + "congestion_multiplier": 1263616814 + } + } + }, + { + "l1_block_number": 20973173, + "l1_fees": { + "blob_fee": 29, + "base_fee": 14784230064 + }, + "parent_header": { + "excess_mana": 199981279, + "mana_used": 199997039, + "proving_cost_per_mana_numerator": 17455936, + "fee_asset_price_numerator": 1631363588 + }, + "header": { + "excess_mana": 299978318, + "mana_used": 199997697, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1040346471 + }, + "oracle_input": { + "proving_cost_modifier": -99066077, + "fee_asset_price_modifier": -591017117 + }, + "outputs": { + "fee_asset_price_at_execution": 10164474298, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 48972762, + "proving_cost": 5416303338, + "congestion_cost": 2297882391, + "congestion_multiplier": 1420451291 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 497782380, + "proving_cost": 55053876069, + "congestion_cost": 23356766503, + "congestion_multiplier": 1420451291 + } + } + }, + { + "l1_block_number": 20973176, + "l1_fees": { + "blob_fee": 32, + "base_fee": 15016479747 + }, + "parent_header": { + "excess_mana": 299978318, + "mana_used": 199997697, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1040346471 + }, + "header": { + "excess_mana": 399976015, + "mana_used": 199996235, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1412024221 + }, + "oracle_input": { + "proving_cost_modifier": -142153798, + "fee_asset_price_modifier": 371677750 + }, + "outputs": { + "fee_asset_price_at_execution": 10104577689, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 49742089, + "proving_cost": 5415357955, + "congestion_cost": 3261312622, + "congestion_multiplier": 1596752593 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 502622802, + "proving_cost": 54719905170, + "congestion_cost": 32954186757, + "congestion_multiplier": 1596752593 + } + } + }, + { + "l1_block_number": 20973179, + "l1_fees": { + "blob_fee": 35, + "base_fee": 14552539238 + }, + "parent_header": { + "excess_mana": 399976015, + "mana_used": 199996235, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1412024221 + }, + "header": { + "excess_mana": 499972250, + "mana_used": 199997933, + "proving_cost_per_mana_numerator": 40177098, + "fee_asset_price_numerator": 1893950162 + }, + "oracle_input": { + "proving_cost_modifier": 40177098, + "fee_asset_price_modifier": 481925941 + }, + "outputs": { + "fee_asset_price_at_execution": 10142204037, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 48205286, + "proving_cost": 5415357955, + "congestion_cost": 4343165122, + "congestion_multiplier": 1794932708 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 488907846, + "proving_cost": 54923665313, + "congestion_cost": 44049266833, + "congestion_multiplier": 1794932708 + } + } + }, + { + "l1_block_number": 20973182, + "l1_fees": { + "blob_fee": 50, + "base_fee": 14547546861 + }, + "parent_header": { + "excess_mana": 499972250, + "mana_used": 199997933, + "proving_cost_per_mana_numerator": 40177098, + "fee_asset_price_numerator": 1893950162 + }, + "header": { + "excess_mana": 599970183, + "mana_used": 199994817, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1856798629 + }, + "oracle_input": { + "proving_cost_modifier": -60537230, + "fee_asset_price_modifier": -37151533 + }, + "outputs": { + "fee_asset_price_at_execution": 10191199916, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 48188748, + "proving_cost": 5417534125, + "congestion_cost": 5562541884, + "congestion_multiplier": 2017713853 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 491101164, + "proving_cost": 55211173319, + "congestion_cost": 56688976380, + "congestion_multiplier": 2017713853 + } + } + }, + { + "l1_block_number": 20973185, + "l1_fees": { + "blob_fee": 72, + "base_fee": 14232502274 + }, + "parent_header": { + "excess_mana": 599970183, + "mana_used": 199994817, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1856798629 + }, + "header": { + "excess_mana": 699965000, + "mana_used": 199996278, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1582709589 + }, + "oracle_input": { + "proving_cost_modifier": -50166503, + "fee_asset_price_modifier": -274089040 + }, + "outputs": { + "fee_asset_price_at_execution": 10187414432, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 47145163, + "proving_cost": 5415357955, + "congestion_cost": 6927205544, + "congestion_multiplier": 2268137591 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 480287313, + "proving_cost": 55168495785, + "congestion_cost": 70570313732, + "congestion_multiplier": 2268137591 + } + } + }, + { + "l1_block_number": 20973188, + "l1_fees": { + "blob_fee": 98, + "base_fee": 14127655188 + }, + "parent_header": { + "excess_mana": 699965000, + "mana_used": 199996278, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1582709589 + }, + "header": { + "excess_mana": 799961278, + "mana_used": 199984012, + "proving_cost_per_mana_numerator": 33783426, + "fee_asset_price_numerator": 1246258072 + }, + "oracle_input": { + "proving_cost_modifier": 33783426, + "fee_asset_price_modifier": -336451517 + }, + "outputs": { + "fee_asset_price_at_execution": 10159530077, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 46797857, + "proving_cost": 5415357955, + "congestion_cost": 8464410270, + "congestion_multiplier": 2549646433 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 475444235, + "proving_cost": 55017492021, + "congestion_cost": 85994430722, + "congestion_multiplier": 2549646433 + } + } + }, + { + "l1_block_number": 20973191, + "l1_fees": { + "blob_fee": 115, + "base_fee": 14102980851 + }, + "parent_header": { + "excess_mana": 799961278, + "mana_used": 199984012, + "proving_cost_per_mana_numerator": 33783426, + "fee_asset_price_numerator": 1246258072 + }, + "header": { + "excess_mana": 899945290, + "mana_used": 199999674, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 954592539 + }, + "oracle_input": { + "proving_cost_modifier": -106484723, + "fee_asset_price_modifier": -291665533 + }, + "outputs": { + "fee_asset_price_at_execution": 10125405622, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 46716124, + "proving_cost": 5417187757, + "congestion_cost": 10195936862, + "congestion_multiplier": 2866053482 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 473019704, + "proving_cost": 54851223370, + "congestion_cost": 103237996424, + "congestion_multiplier": 2866053482 + } + } + }, + { + "l1_block_number": 20973194, + "l1_fees": { + "blob_fee": 120, + "base_fee": 14702466429 + }, + "parent_header": { + "excess_mana": 899945290, + "mana_used": 199999674, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 954592539 + }, + "header": { + "excess_mana": 999944964, + "mana_used": 199996424, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1071432807 + }, + "oracle_input": { + "proving_cost_modifier": -52977520, + "fee_asset_price_modifier": 116840268 + }, + "outputs": { + "fee_asset_price_at_execution": 10095916330, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 48701920, + "proving_cost": 5415357955, + "congestion_cost": 12139967236, + "congestion_multiplier": 3221785177 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 491690509, + "proving_cost": 54673000810, + "congestion_cost": 122564093463, + "congestion_multiplier": 3221785177 + } + } + }, + { + "l1_block_number": 20973197, + "l1_fees": { + "blob_fee": 106, + "base_fee": 14850593518 + }, + "parent_header": { + "excess_mana": 999944964, + "mana_used": 199996424, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1071432807 + }, + "header": { + "excess_mana": 1099941388, + "mana_used": 177366071, + "proving_cost_per_mana_numerator": 60087242, + "fee_asset_price_numerator": 758010157 + }, + "oracle_input": { + "proving_cost_modifier": 60087242, + "fee_asset_price_modifier": -313422650 + }, + "outputs": { + "fee_asset_price_at_execution": 10107719320, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 49192591, + "proving_cost": 5415357955, + "congestion_cost": 14326172616, + "congestion_multiplier": 3621656163 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 497224902, + "proving_cost": 54736918226, + "congestion_cost": 144804931732, + "congestion_multiplier": 3621656163 + } + } + }, + { + "l1_block_number": 20973200, + "l1_fees": { + "blob_fee": 87, + "base_fee": 15618137990 + }, + "parent_header": { + "excess_mana": 1099941388, + "mana_used": 177366071, + "proving_cost_per_mana_numerator": 60087242, + "fee_asset_price_numerator": 758010157 + }, + "header": { + "excess_mana": 1177307459, + "mana_used": 105632955, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1098791969 + }, + "oracle_input": { + "proving_cost_modifier": -134258021, + "fee_asset_price_modifier": 340781812 + }, + "outputs": { + "fee_asset_price_at_execution": 10076089032, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 51735082, + "proving_cost": 5418612872, + "congestion_cost": 16218364323, + "congestion_multiplier": 3964777462 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 521287292, + "proving_cost": 54598425728, + "congestion_cost": 163417682871, + "congestion_multiplier": 3964777462 + } + } + }, + { + "l1_block_number": 20973203, + "l1_fees": { + "blob_fee": 98, + "base_fee": 15809788248 + }, + "parent_header": { + "excess_mana": 1177307459, + "mana_used": 105632955, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1098791969 + }, + "header": { + "excess_mana": 1182940414, + "mana_used": 199957829, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1670588844 + }, + "oracle_input": { + "proving_cost_modifier": -46759887, + "fee_asset_price_modifier": 571796875 + }, + "outputs": { + "fee_asset_price_at_execution": 10110485085, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 52369923, + "proving_cost": 5415357955, + "congestion_cost": 16353940462, + "congestion_multiplier": 3990993851 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 529485325, + "proving_cost": 54751895833, + "congestion_cost": 165346271122, + "congestion_multiplier": 3990993851 + } + } + }, + { + "l1_block_number": 20973206, + "l1_fees": { + "blob_fee": 130, + "base_fee": 16615048160 + }, + "parent_header": { + "excess_mana": 1182940414, + "mana_used": 199957829, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1670588844 + }, + "header": { + "excess_mana": 1282898243, + "mana_used": 120218002, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1430564163 + }, + "oracle_input": { + "proving_cost_modifier": -30308858, + "fee_asset_price_modifier": -240024681 + }, + "outputs": { + "fee_asset_price_at_execution": 10168462121, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 55037347, + "proving_cost": 5415357955, + "congestion_cost": 19070522199, + "congestion_multiplier": 4486132381 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 559645178, + "proving_cost": 55065862237, + "congestion_cost": 193917882608, + "congestion_multiplier": 4486132381 + } + } + }, + { + "l1_block_number": 20973209, + "l1_fees": { + "blob_fee": 164, + "base_fee": 17184203834 + }, + "parent_header": { + "excess_mana": 1282898243, + "mana_used": 120218002, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1430564163 + }, + "header": { + "excess_mana": 1303116245, + "mana_used": 108663083, + "proving_cost_per_mana_numerator": 42974511, + "fee_asset_price_numerator": 1398913434 + }, + "oracle_input": { + "proving_cost_modifier": 42974511, + "fee_asset_price_modifier": -31650729 + }, + "outputs": { + "fee_asset_price_at_execution": 10144084570, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 56922675, + "proving_cost": 5415357955, + "congestion_cost": 19664734632, + "congestion_multiplier": 4593517212 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 577428429, + "proving_cost": 54933849072, + "congestion_cost": 199480731153, + "congestion_multiplier": 4593517212 + } + } + }, + { + "l1_block_number": 20973212, + "l1_fees": { + "blob_fee": 164, + "base_fee": 19878985864 + }, + "parent_header": { + "excess_mana": 1303116245, + "mana_used": 108663083, + "proving_cost_per_mana_numerator": 42974511, + "fee_asset_price_numerator": 1398913434 + }, + "header": { + "excess_mana": 1311779328, + "mana_used": 98368116, + "proving_cost_per_mana_numerator": 65600657, + "fee_asset_price_numerator": 1496985754 + }, + "oracle_input": { + "proving_cost_modifier": 22626146, + "fee_asset_price_modifier": 98072320 + }, + "outputs": { + "fee_asset_price_at_execution": 10140874401, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 65849140, + "proving_cost": 5417685678, + "congestion_cost": 19961782930, + "congestion_multiplier": 4640312972 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 667767858, + "proving_cost": 54940070004, + "congestion_cost": 202429933513, + "congestion_multiplier": 4640312972 + } + } + }, + { + "l1_block_number": 20973215, + "l1_fees": { + "blob_fee": 200, + "base_fee": 18840462804 + }, + "parent_header": { + "excess_mana": 1311779328, + "mana_used": 98368116, + "proving_cost_per_mana_numerator": 65600657, + "fee_asset_price_numerator": 1496985754 + }, + "header": { + "excess_mana": 1310147444, + "mana_used": 105469376, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 954626605 + }, + "oracle_input": { + "proving_cost_modifier": -66070337, + "fee_asset_price_modifier": -542359149 + }, + "outputs": { + "fee_asset_price_at_execution": 10150824670, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 62409033, + "proving_cost": 5418911630, + "congestion_cost": 19905205811, + "congestion_multiplier": 4631461656 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 633503151, + "proving_cost": 55006421858, + "congestion_cost": 202054254207, + "congestion_multiplier": 4631461656 + } + } + }, + { + "l1_block_number": 20973218, + "l1_fees": { + "blob_fee": 216, + "base_fee": 17587430794 + }, + "parent_header": { + "excess_mana": 1310147444, + "mana_used": 105469376, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 954626605 + }, + "header": { + "excess_mana": 1315616820, + "mana_used": 105844331, + "proving_cost_per_mana_numerator": 141121635, + "fee_asset_price_numerator": 1612884691 + }, + "oracle_input": { + "proving_cost_modifier": 141121635, + "fee_asset_price_modifier": 658258086 + }, + "outputs": { + "fee_asset_price_at_execution": 10095919769, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 58258364, + "proving_cost": 5415357955, + "congestion_cost": 20039972298, + "congestion_multiplier": 4661194196 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 588171768, + "proving_cost": 54673019434, + "congestion_cost": 202321952493, + "congestion_multiplier": 4661194196 + } + } + }, + { + "l1_block_number": 20973221, + "l1_fees": { + "blob_fee": 192, + "base_fee": 18240173510 + }, + "parent_header": { + "excess_mana": 1315616820, + "mana_used": 105844331, + "proving_cost_per_mana_numerator": 141121635, + "fee_asset_price_numerator": 1612884691 + }, + "header": { + "excess_mana": 1321461151, + "mana_used": 98446274, + "proving_cost_per_mana_numerator": 96693946, + "fee_asset_price_numerator": 1167331383 + }, + "oracle_input": { + "proving_cost_modifier": -44427689, + "fee_asset_price_modifier": -445553308 + }, + "outputs": { + "fee_asset_price_at_execution": 10162596188, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 60420574, + "proving_cost": 5423005591, + "congestion_cost": 20251258146, + "congestion_multiplier": 4693176043 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 614029895, + "proving_cost": 55111815946, + "congestion_cost": 205805358836, + "congestion_multiplier": 4693176043 + } + } + }, + { + "l1_block_number": 20973224, + "l1_fees": { + "blob_fee": 171, + "base_fee": 21493716770 + }, + "parent_header": { + "excess_mana": 1321461151, + "mana_used": 98446274, + "proving_cost_per_mana_numerator": 96693946, + "fee_asset_price_numerator": 1167331383 + }, + "header": { + "excess_mana": 1319907425, + "mana_used": 84600050, + "proving_cost_per_mana_numerator": 224636242, + "fee_asset_price_numerator": 1265476079 + }, + "oracle_input": { + "proving_cost_modifier": 127942296, + "fee_asset_price_modifier": 98144696 + }, + "outputs": { + "fee_asset_price_at_execution": 10117417128, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 71197936, + "proving_cost": 5420596810, + "congestion_cost": 20235353911, + "congestion_multiplier": 4684652258 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 720339217, + "proving_cost": 54842439009, + "congestion_cost": 204729516250, + "congestion_multiplier": 4684652258 + } + } + }, + { + "l1_block_number": 20973227, + "l1_fees": { + "blob_fee": 152, + "base_fee": 21129802751 + }, + "parent_header": { + "excess_mana": 1319907425, + "mana_used": 84600050, + "proving_cost_per_mana_numerator": 224636242, + "fee_asset_price_numerator": 1265476079 + }, + "header": { + "excess_mana": 1304507475, + "mana_used": 110635621, + "proving_cost_per_mana_numerator": 289339939, + "fee_asset_price_numerator": 1664231361 + }, + "oracle_input": { + "proving_cost_modifier": 64703697, + "fee_asset_price_modifier": 398755282 + }, + "outputs": { + "fee_asset_price_at_execution": 10127351711, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 69992471, + "proving_cost": 5427536485, + "congestion_cost": 19796603683, + "congestion_multiplier": 4601000348 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 708838370, + "proving_cost": 54966570907, + "congestion_cost": 200487168181, + "congestion_multiplier": 4601000348 + } + } + }, + { + "l1_block_number": 20973230, + "l1_fees": { + "blob_fee": 216, + "base_fee": 19428171353 + }, + "parent_header": { + "excess_mana": 1304507475, + "mana_used": 110635621, + "proving_cost_per_mana_numerator": 289339939, + "fee_asset_price_numerator": 1664231361 + }, + "header": { + "excess_mana": 1315143096, + "mana_used": 107193381, + "proving_cost_per_mana_numerator": 203772621, + "fee_asset_price_numerator": 2266740945 + }, + "oracle_input": { + "proving_cost_modifier": -85567318, + "fee_asset_price_modifier": 602509584 + }, + "outputs": { + "fee_asset_price_at_execution": 10167815683, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 64355817, + "proving_cost": 5431049438, + "congestion_cost": 20105552379, + "congestion_multiplier": 4658611412 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 654358085, + "proving_cost": 55221909650, + "congestion_cost": 204429550794, + "congestion_multiplier": 4658611412 + } + } + }, + { + "l1_block_number": 20973233, + "l1_fees": { + "blob_fee": 243, + "base_fee": 20070480259 + }, + "parent_header": { + "excess_mana": 1315143096, + "mana_used": 107193381, + "proving_cost_per_mana_numerator": 203772621, + "fee_asset_price_numerator": 2266740945 + }, + "header": { + "excess_mana": 1322336477, + "mana_used": 101466733, + "proving_cost_per_mana_numerator": 34521604, + "fee_asset_price_numerator": 2167173930 + }, + "oracle_input": { + "proving_cost_modifier": -169251017, + "fee_asset_price_modifier": -99567015 + }, + "outputs": { + "fee_asset_price_at_execution": 10229262673, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 66483465, + "proving_cost": 5426404222, + "congestion_cost": 20312615910, + "congestion_multiplier": 4697984934 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 680076826, + "proving_cost": 55508114156, + "congestion_cost": 207783083719, + "congestion_multiplier": 4697984934 + } + } + }, + { + "l1_block_number": 20973236, + "l1_fees": { + "blob_fee": 333, + "base_fee": 18248910855 + }, + "parent_header": { + "excess_mana": 1322336477, + "mana_used": 101466733, + "proving_cost_per_mana_numerator": 34521604, + "fee_asset_price_numerator": 2167173930 + }, + "header": { + "excess_mana": 1323803210, + "mana_used": 91541959, + "proving_cost_per_mana_numerator": 76429561, + "fee_asset_price_numerator": 1301363172 + }, + "oracle_input": { + "proving_cost_modifier": 41907957, + "fee_asset_price_modifier": -865810758 + }, + "outputs": { + "fee_asset_price_at_execution": 10219082770, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 60449517, + "proving_cost": 5417227746, + "congestion_cost": 20300567526, + "congestion_multiplier": 4706053962 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 617738617, + "proving_cost": 55359098720, + "congestion_cost": 207453179826, + "congestion_multiplier": 4706053962 + } + } + }, + { + "l1_block_number": 20973239, + "l1_fees": { + "blob_fee": 347, + "base_fee": 20770060420 + }, + "parent_header": { + "excess_mana": 1323803210, + "mana_used": 91541959, + "proving_cost_per_mana_numerator": 76429561, + "fee_asset_price_numerator": 1301363172 + }, + "header": { + "excess_mana": 1315345169, + "mana_used": 122131829, + "proving_cost_per_mana_numerator": 262665832, + "fee_asset_price_numerator": 335413966 + }, + "oracle_input": { + "proving_cost_modifier": 186236271, + "fee_asset_price_modifier": -965949206 + }, + "outputs": { + "fee_asset_price_at_execution": 10130986775, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 68800825, + "proving_cost": 5419498471, + "congestion_cost": 20085600043, + "congestion_multiplier": 4659712956 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 697020248, + "proving_cost": 54904867336, + "congestion_cost": 203486948403, + "congestion_multiplier": 4659712956 + } + } + }, + { + "l1_block_number": 20973242, + "l1_fees": { + "blob_fee": 263, + "base_fee": 20083364753 + }, + "parent_header": { + "excess_mana": 1315345169, + "mana_used": 122131829, + "proving_cost_per_mana_numerator": 262665832, + "fee_asset_price_numerator": 335413966 + }, + "header": { + "excess_mana": 1337476998, + "mana_used": 94686801, + "proving_cost_per_mana_numerator": 285649568, + "fee_asset_price_numerator": 522653958 + }, + "oracle_input": { + "proving_cost_modifier": 22983736, + "fee_asset_price_modifier": 187239992 + }, + "outputs": { + "fee_asset_price_at_execution": 10033597710, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 66526145, + "proving_cost": 5429600947, + "congestion_cost": 20786069334, + "congestion_multiplier": 4781948449 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 667496576, + "proving_cost": 54478431628, + "congestion_cost": 208559057669, + "congestion_multiplier": 4781948449 + } + } + }, + { + "l1_block_number": 20973245, + "l1_fees": { + "blob_fee": 333, + "base_fee": 18976916853 + }, + "parent_header": { + "excess_mana": 1337476998, + "mana_used": 94686801, + "proving_cost_per_mana_numerator": 285649568, + "fee_asset_price_numerator": 522653958 + }, + "header": { + "excess_mana": 1332163799, + "mana_used": 98391768, + "proving_cost_per_mana_numerator": 327049540, + "fee_asset_price_numerator": 466383850 + }, + "oracle_input": { + "proving_cost_modifier": 41399972, + "fee_asset_price_modifier": -56270108 + }, + "outputs": { + "fee_asset_price_at_execution": 10052402217, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 62861037, + "proving_cost": 5430849016, + "congestion_cost": 20614124850, + "congestion_multiplier": 4752313946 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 631904427, + "proving_cost": 54593078688, + "congestion_cost": 207221474343, + "congestion_multiplier": 4752313946 + } + } + }, + { + "l1_block_number": 20973248, + "l1_fees": { + "blob_fee": 347, + "base_fee": 18939331593 + }, + "parent_header": { + "excess_mana": 1332163799, + "mana_used": 98391768, + "proving_cost_per_mana_numerator": 327049540, + "fee_asset_price_numerator": 466383850 + }, + "header": { + "excess_mana": 1330555567, + "mana_used": 97285971, + "proving_cost_per_mana_numerator": 349440774, + "fee_asset_price_numerator": 1263490118 + }, + "oracle_input": { + "proving_cost_modifier": 22391234, + "fee_asset_price_modifier": 797106268 + }, + "outputs": { + "fee_asset_price_at_execution": 10046747311, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 62736535, + "proving_cost": 5433097851, + "congestion_cost": 20572997901, + "congestion_multiplier": 4743380250 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 630298114, + "proving_cost": 54584961224, + "congestion_cost": 206691711341, + "congestion_multiplier": 4743380250 + } + } + }, + { + "l1_block_number": 20973251, + "l1_fees": { + "blob_fee": 361, + "base_fee": 18547987166 + }, + "parent_header": { + "excess_mana": 1330555567, + "mana_used": 97285971, + "proving_cost_per_mana_numerator": 349440774, + "fee_asset_price_numerator": 1263490118 + }, + "header": { + "excess_mana": 1327841538, + "mana_used": 94195956, + "proving_cost_per_mana_numerator": 521756115, + "fee_asset_price_numerator": 634906412 + }, + "oracle_input": { + "proving_cost_modifier": 172315341, + "fee_asset_price_modifier": -628583706 + }, + "outputs": { + "fee_asset_price_at_execution": 10127150587, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 61440207, + "proving_cost": 5434314525, + "congestion_cost": 20490052884, + "congestion_multiplier": 4728341944 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 622214228, + "proving_cost": 55034121531, + "congestion_cost": 207505851091, + "congestion_multiplier": 4728341944 + } + } + }, + { + "l1_block_number": 20973254, + "l1_fees": { + "blob_fee": 406, + "base_fee": 19027558519 + }, + "parent_header": { + "excess_mana": 1327841538, + "mana_used": 94195956, + "proving_cost_per_mana_numerator": 521756115, + "fee_asset_price_numerator": 634906412 + }, + "header": { + "excess_mana": 1322037494, + "mana_used": 104831684, + "proving_cost_per_mana_numerator": 328317385, + "fee_asset_price_numerator": 1493437131 + }, + "oracle_input": { + "proving_cost_modifier": -193438730, + "fee_asset_price_modifier": 858530719 + }, + "outputs": { + "fee_asset_price_at_execution": 10063692621, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 63028787, + "proving_cost": 5443686755, + "congestion_cost": 20354702941, + "congestion_multiplier": 4696341818 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 634302338, + "proving_cost": 54783590227, + "congestion_cost": 204843473789, + "congestion_multiplier": 4696341818 + } + } + }, + { + "l1_block_number": 20973257, + "l1_fees": { + "blob_fee": 285, + "base_fee": 19960437790 + }, + "parent_header": { + "excess_mana": 1322037494, + "mana_used": 104831684, + "proving_cost_per_mana_numerator": 328317385, + "fee_asset_price_numerator": 1493437131 + }, + "header": { + "excess_mana": 1326869178, + "mana_used": 95091170, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 683470723 + }, + "oracle_input": { + "proving_cost_modifier": -408184922, + "fee_asset_price_modifier": -809966408 + }, + "outputs": { + "fee_asset_price_at_execution": 10150464462, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 66118950, + "proving_cost": 5433166735, + "congestion_cost": 20473652263, + "congestion_multiplier": 4722965751 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 671138052, + "proving_cost": 55149165859, + "congestion_cost": 207817079702, + "congestion_multiplier": 4722965751 + } + } + }, + { + "l1_block_number": 20973260, + "l1_fees": { + "blob_fee": 320, + "base_fee": 20847107469 + }, + "parent_header": { + "excess_mana": 1326869178, + "mana_used": 95091170, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 683470723 + }, + "header": { + "excess_mana": 1321960348, + "mana_used": 98931930, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 263974984 + }, + "oracle_input": { + "proving_cost_modifier": -89389051, + "fee_asset_price_modifier": -419495739 + }, + "outputs": { + "fee_asset_price_at_execution": 10068581171, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 69056043, + "proving_cost": 5415357955, + "congestion_cost": 20269944100, + "congestion_multiplier": 4695917942 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 695296374, + "proving_cost": 54524971139, + "congestion_cost": 204089577502, + "congestion_multiplier": 4695917942 + } + } + }, + { + "l1_block_number": 20973263, + "l1_fees": { + "blob_fee": 375, + "base_fee": 18902464529 + }, + "parent_header": { + "excess_mana": 1321960348, + "mana_used": 98931930, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 263974984 + }, + "header": { + "excess_mana": 1320892278, + "mana_used": 95278001, + "proving_cost_per_mana_numerator": 100690211, + "fee_asset_price_numerator": 311174512 + }, + "oracle_input": { + "proving_cost_modifier": 100690211, + "fee_asset_price_modifier": 47199528 + }, + "outputs": { + "fee_asset_price_at_execution": 10026432370, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 62614413, + "proving_cost": 5415357955, + "congestion_cost": 20214010516, + "congestion_multiplier": 4690053391 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 627799177, + "proving_cost": 54296720295, + "congestion_cost": 202674409365, + "congestion_multiplier": 4690053391 + } + } + }, + { + "l1_block_number": 20973266, + "l1_fees": { + "blob_fee": 308, + "base_fee": 18299097163 + }, + "parent_header": { + "excess_mana": 1320892278, + "mana_used": 95278001, + "proving_cost_per_mana_numerator": 100690211, + "fee_asset_price_numerator": 311174512 + }, + "header": { + "excess_mana": 1316170279, + "mana_used": 101936608, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 630116718 + }, + "oracle_input": { + "proving_cost_modifier": -154605323, + "fee_asset_price_modifier": 318942206 + }, + "outputs": { + "fee_asset_price_at_execution": 10031165916, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 60615759, + "proving_cost": 5420813436, + "congestion_cost": 20085126946, + "congestion_multiplier": 4664213516 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 608046735, + "proving_cost": 54377078976, + "congestion_cost": 201477240839, + "congestion_multiplier": 4664213516 + } + } + }, + { + "l1_block_number": 20973269, + "l1_fees": { + "blob_fee": 375, + "base_fee": 18189059913 + }, + "parent_header": { + "excess_mana": 1316170279, + "mana_used": 101936608, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 630116718 + }, + "header": { + "excess_mana": 1318106887, + "mana_used": 99042382, + "proving_cost_per_mana_numerator": 3337252, + "fee_asset_price_numerator": 195106265 + }, + "oracle_input": { + "proving_cost_modifier": 3337252, + "fee_asset_price_modifier": -435010453 + }, + "outputs": { + "fee_asset_price_at_execution": 10063210612, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 60251260, + "proving_cost": 5415357955, + "congestion_cost": 20121734902, + "congestion_multiplier": 4674793819 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 606321119, + "proving_cost": 54495887640, + "congestion_cost": 202489256197, + "congestion_multiplier": 4674793819 + } + } + }, + { + "l1_block_number": 20973272, + "l1_fees": { + "blob_fee": 361, + "base_fee": 17956791785 + }, + "parent_header": { + "excess_mana": 1318106887, + "mana_used": 99042382, + "proving_cost_per_mana_numerator": 3337252, + "fee_asset_price_numerator": 195106265 + }, + "header": { + "excess_mana": 1317149269, + "mana_used": 114460674, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -158447076, + "fee_asset_price_modifier": -941718501 + }, + "outputs": { + "fee_asset_price_at_execution": 10019529672, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 59481872, + "proving_cost": 5415538682, + "congestion_cost": 20090911237, + "congestion_multiplier": 4669559052 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 595980381, + "proving_cost": 54261150514, + "congestion_cost": 201301481276, + "congestion_multiplier": 4669559052 + } + } + }, + { + "l1_block_number": 20973275, + "l1_fees": { + "blob_fee": 422, + "base_fee": 18168683930 + }, + "parent_header": { + "excess_mana": 1317149269, + "mana_used": 114460674, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1331609943, + "mana_used": 101559769, + "proving_cost_per_mana_numerator": 21048022, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 21048022, + "fee_asset_price_modifier": -5887937 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 60183765, + "proving_cost": 5415357955, + "congestion_cost": 20529094799, + "congestion_multiplier": 4749235390 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 601837650, + "proving_cost": 54153579550, + "congestion_cost": 205290947990, + "congestion_multiplier": 4749235390 + } + } + }, + { + "l1_block_number": 20973278, + "l1_fees": { + "blob_fee": 422, + "base_fee": 17010109252 + }, + "parent_header": { + "excess_mana": 1331609943, + "mana_used": 101559769, + "proving_cost_per_mana_numerator": 21048022, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1333169712, + "mana_used": 102249578, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 515233807 + }, + "oracle_input": { + "proving_cost_modifier": -92908145, + "fee_asset_price_modifier": 515233807 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 56345986, + "proving_cost": 5416497900, + "congestion_cost": 20566456544, + "congestion_multiplier": 4757910324 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 563459860, + "proving_cost": 54164979000, + "congestion_cost": 205664565440, + "congestion_multiplier": 4757910324 + } + } + }, + { + "l1_block_number": 20973281, + "l1_fees": { + "blob_fee": 361, + "base_fee": 17657903515 + }, + "parent_header": { + "excess_mana": 1333169712, + "mana_used": 102249578, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 515233807 + }, + "header": { + "excess_mana": 1335419290, + "mana_used": 92477431, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -31551963, + "fee_asset_price_modifier": -549794876 + }, + "outputs": { + "fee_asset_price_at_execution": 10051656341, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 58491805, + "proving_cost": 5415357955, + "congestion_cost": 20638875014, + "congestion_multiplier": 4770449668 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 587939522, + "proving_cost": 54433317127, + "congestion_cost": 207454878905, + "congestion_multiplier": 4770449668 + } + } + }, + { + "l1_block_number": 20973284, + "l1_fees": { + "blob_fee": 422, + "base_fee": 18297705033 + }, + "parent_header": { + "excess_mana": 1335419290, + "mana_used": 92477431, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1327896721, + "mana_used": 96681271, + "proving_cost_per_mana_numerator": 79671009, + "fee_asset_price_numerator": 592774955 + }, + "oracle_input": { + "proving_cost_modifier": 79671009, + "fee_asset_price_modifier": 592774955 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 60611147, + "proving_cost": 5415357955, + "congestion_cost": 20417957054, + "congestion_multiplier": 4728647235 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 606111470, + "proving_cost": 54153579550, + "congestion_cost": 204179570540, + "congestion_multiplier": 4728647235 + } + } + }, + { + "l1_block_number": 20973287, + "l1_fees": { + "blob_fee": 361, + "base_fee": 19092004533 + }, + "parent_header": { + "excess_mana": 1327896721, + "mana_used": 96681271, + "proving_cost_per_mana_numerator": 79671009, + "fee_asset_price_numerator": 592774955 + }, + "header": { + "excess_mana": 1324577992, + "mana_used": 89190304, + "proving_cost_per_mana_numerator": 288691509, + "fee_asset_price_numerator": 1507728668 + }, + "oracle_input": { + "proving_cost_modifier": 209020500, + "fee_asset_price_modifier": 914953713 + }, + "outputs": { + "fee_asset_price_at_execution": 10059453534, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 63242265, + "proving_cost": 5419674144, + "congestion_cost": 20343384886, + "congestion_multiplier": 4710321910 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 636182626, + "proving_cost": 54518960220, + "congestion_cost": 204643334984, + "congestion_multiplier": 4710321910 + } + } + }, + { + "l1_block_number": 20973290, + "l1_fees": { + "blob_fee": 390, + "base_fee": 18698500008 + }, + "parent_header": { + "excess_mana": 1324577992, + "mana_used": 89190304, + "proving_cost_per_mana_numerator": 288691509, + "fee_asset_price_numerator": 1507728668 + }, + "header": { + "excess_mana": 1313768296, + "mana_used": 105278121, + "proving_cost_per_mana_numerator": 133541491, + "fee_asset_price_numerator": 1803567814 + }, + "oracle_input": { + "proving_cost_modifier": -155150018, + "fee_asset_price_modifier": 295839146 + }, + "outputs": { + "fee_asset_price_at_execution": 10151915223, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 61938781, + "proving_cost": 5431014221, + "congestion_cost": 20055452452, + "congestion_multiplier": 4651123984 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 628797253, + "proving_cost": 55135195946, + "congestion_cost": 203601253051, + "congestion_multiplier": 4651123984 + } + } + }, + { + "l1_block_number": 20973293, + "l1_fees": { + "blob_fee": 285, + "base_fee": 18642710735 + }, + "parent_header": { + "excess_mana": 1313768296, + "mana_used": 105278121, + "proving_cost_per_mana_numerator": 133541491, + "fee_asset_price_numerator": 1803567814 + }, + "header": { + "excess_mana": 1319046417, + "mana_used": 86926182, + "proving_cost_per_mana_numerator": 75741087, + "fee_asset_price_numerator": 2094753268 + }, + "oracle_input": { + "proving_cost_modifier": -57800404, + "fee_asset_price_modifier": 291185454 + }, + "outputs": { + "fee_asset_price_at_execution": 10181993031, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 61753979, + "proving_cost": 5422594535, + "congestion_cost": 20182048312, + "congestion_multiplier": 4679935412 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 628778583, + "proving_cost": 55212819765, + "congestion_cost": 205493475264, + "congestion_multiplier": 4679935412 + } + } + }, + { + "l1_block_number": 20973296, + "l1_fees": { + "blob_fee": 406, + "base_fee": 17157660059 + }, + "parent_header": { + "excess_mana": 1319046417, + "mana_used": 86926182, + "proving_cost_per_mana_numerator": 75741087, + "fee_asset_price_numerator": 2094753268 + }, + "header": { + "excess_mana": 1305972599, + "mana_used": 121671900, + "proving_cost_per_mana_numerator": 194735085, + "fee_asset_price_numerator": 1536756867 + }, + "oracle_input": { + "proving_cost_modifier": 118993998, + "fee_asset_price_modifier": -557996401 + }, + "outputs": { + "fee_asset_price_at_execution": 10211684722, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 56834748, + "proving_cost": 5419461159, + "congestion_cost": 19763372123, + "congestion_multiplier": 4608894124 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 580378527, + "proving_cost": 55341828718, + "congestion_cost": 201817325163, + "congestion_multiplier": 4608894124 + } + } + }, + { + "l1_block_number": 20973299, + "l1_fees": { + "blob_fee": 578, + "base_fee": 17844563894 + }, + "parent_header": { + "excess_mana": 1305972599, + "mana_used": 121671900, + "proving_cost_per_mana_numerator": 194735085, + "fee_asset_price_numerator": 1536756867 + }, + "header": { + "excess_mana": 1327644499, + "mana_used": 94239640, + "proving_cost_per_mana_numerator": 144284685, + "fee_asset_price_numerator": 1259440678 + }, + "oracle_input": { + "proving_cost_modifier": -50450400, + "fee_asset_price_modifier": -277316189 + }, + "outputs": { + "fee_asset_price_at_execution": 10154862569, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 59110117, + "proving_cost": 5425913831, + "congestion_cost": 20444066586, + "congestion_multiplier": 4727252018 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 600255114, + "proving_cost": 55099409265, + "congestion_cost": 207606686532, + "congestion_multiplier": 4727252018 + } + } + }, + { + "l1_block_number": 20973302, + "l1_fees": { + "blob_fee": 514, + "base_fee": 18350427669 + }, + "parent_header": { + "excess_mana": 1327644499, + "mana_used": 94239640, + "proving_cost_per_mana_numerator": 144284685, + "fee_asset_price_numerator": 1259440678 + }, + "header": { + "excess_mana": 1321884139, + "mana_used": 104298436, + "proving_cost_per_mana_numerator": 150042426, + "fee_asset_price_numerator": 714535872 + }, + "oracle_input": { + "proving_cost_modifier": 5757741, + "fee_asset_price_modifier": -544904806 + }, + "outputs": { + "fee_asset_price_at_execution": 10126740503, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 60785791, + "proving_cost": 5423177126, + "congestion_cost": 20265980859, + "congestion_multiplier": 4695499251 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 615561931, + "proving_cost": 54919107456, + "congestion_cost": 205228329197, + "congestion_multiplier": 4695499251 + } + } + }, + { + "l1_block_number": 20973305, + "l1_fees": { + "blob_fee": 556, + "base_fee": 18935369029 + }, + "parent_header": { + "excess_mana": 1321884139, + "mana_used": 104298436, + "proving_cost_per_mana_numerator": 150042426, + "fee_asset_price_numerator": 714535872 + }, + "header": { + "excess_mana": 1326182575, + "mana_used": 95940065, + "proving_cost_per_mana_numerator": 143665287, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -6377139, + "fee_asset_price_modifier": -730072379 + }, + "outputs": { + "fee_asset_price_at_execution": 10071709477, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 62723409, + "proving_cost": 5423489388, + "congestion_cost": 20404175589, + "congestion_multiplier": 4719173196 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 631731952, + "proving_cost": 54623809467, + "congestion_cost": 205504928650, + "congestion_multiplier": 4719173196 + } + } + }, + { + "l1_block_number": 20973308, + "l1_fees": { + "blob_fee": 494, + "base_fee": 18629157863 + }, + "parent_header": { + "excess_mana": 1326182575, + "mana_used": 95940065, + "proving_cost_per_mana_numerator": 143665287, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1322122640, + "mana_used": 118650737, + "proving_cost_per_mana_numerator": 27347406, + "fee_asset_price_numerator": 126873686 + }, + "oracle_input": { + "proving_cost_modifier": -116317881, + "fee_asset_price_modifier": 126873686 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 61709085, + "proving_cost": 5423143535, + "congestion_cost": 20276456344, + "congestion_multiplier": 4696809695 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 617090850, + "proving_cost": 54231435350, + "congestion_cost": 202764563440, + "congestion_multiplier": 4696809695 + } + } + }, + { + "l1_block_number": 20973311, + "l1_fees": { + "blob_fee": 556, + "base_fee": 17703911185 + }, + "parent_header": { + "excess_mana": 1322122640, + "mana_used": 118650737, + "proving_cost_per_mana_numerator": 27347406, + "fee_asset_price_numerator": 126873686 + }, + "header": { + "excess_mana": 1340773377, + "mana_used": 83539329, + "proving_cost_per_mana_numerator": 33755883, + "fee_asset_price_numerator": 330994440 + }, + "oracle_input": { + "proving_cost_modifier": 6408477, + "fee_asset_price_modifier": 204120754 + }, + "outputs": { + "fee_asset_price_at_execution": 10012695420, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 58644205, + "proving_cost": 5416839117, + "congestion_cost": 20809174136, + "congestion_multiplier": 4800426904 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 587186562, + "proving_cost": 54237160217, + "congestion_cost": 208355922565, + "congestion_multiplier": 4800426904 + } + } + }, + { + "l1_block_number": 20973314, + "l1_fees": { + "blob_fee": 625, + "base_fee": 19202542875 + }, + "parent_header": { + "excess_mana": 1340773377, + "mana_used": 83539329, + "proving_cost_per_mana_numerator": 33755883, + "fee_asset_price_numerator": 330994440 + }, + "header": { + "excess_mana": 1324312706, + "mana_used": 102397541, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 189252938 + }, + "oracle_input": { + "proving_cost_modifier": -191695900, + "fee_asset_price_modifier": -141741502 + }, + "outputs": { + "fee_asset_price_at_execution": 10033154283, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 63608423, + "proving_cost": 5417186265, + "congestion_cost": 20327500884, + "congestion_multiplier": 4708860126 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 638193121, + "proving_cost": 54351465576, + "congestion_cost": 203948952556, + "congestion_multiplier": 4708860126 + } + } + }, + { + "l1_block_number": 20973317, + "l1_fees": { + "blob_fee": 556, + "base_fee": 20520058840 + }, + "parent_header": { + "excess_mana": 1324312706, + "mana_used": 102397541, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 189252938 + }, + "header": { + "excess_mana": 1326710247, + "mana_used": 58716486, + "proving_cost_per_mana_numerator": 92573408, + "fee_asset_price_numerator": 635898020 + }, + "oracle_input": { + "proving_cost_modifier": 92573408, + "fee_asset_price_modifier": 446645082 + }, + "outputs": { + "fee_asset_price_at_execution": 10018943213, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 67972694, + "proving_cost": 5415357955, + "congestion_cost": 20409437028, + "congestion_multiplier": 4722087601 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 681014561, + "proving_cost": 54256163829, + "congestion_cost": 204480990592, + "congestion_multiplier": 4722087601 + } + } + }, + { + "l1_block_number": 20973320, + "l1_fees": { + "blob_fee": 791, + "base_fee": 19995965669 + }, + "parent_header": { + "excess_mana": 1326710247, + "mana_used": 58716486, + "proving_cost_per_mana_numerator": 92573408, + "fee_asset_price_numerator": 635898020 + }, + "header": { + "excess_mana": 1285426733, + "mana_used": 121832935, + "proving_cost_per_mana_numerator": 160371045, + "fee_asset_price_numerator": 448986186 + }, + "oracle_input": { + "proving_cost_modifier": 67797637, + "fee_asset_price_modifier": -186911834 + }, + "outputs": { + "fee_asset_price_at_execution": 10063792414, + "mana_base_fee_components_in_wei": { + "data_cost": 3, + "gas_cost": 66236636, + "proving_cost": 5420373457, + "congestion_cost": 19199972338, + "congestion_multiplier": 4499423506 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 30, + "gas_cost": 666591754, + "proving_cost": 54549513277, + "congestion_cost": 193224535964, + "congestion_multiplier": 4499423506 + } + } + }, + { + "l1_block_number": 20973323, + "l1_fees": { + "blob_fee": 703, + "base_fee": 19348276407 + }, + "parent_header": { + "excess_mana": 1285426733, + "mana_used": 121832935, + "proving_cost_per_mana_numerator": 160371045, + "fee_asset_price_numerator": 448986186 + }, + "header": { + "excess_mana": 1307259668, + "mana_used": 107794157, + "proving_cost_per_mana_numerator": 101292328, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -59078717, + "fee_asset_price_modifier": -711503255 + }, + "outputs": { + "fee_asset_price_at_execution": 10044999563, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 64091165, + "proving_cost": 5424049588, + "congestion_cost": 19844237501, + "congestion_multiplier": 4615839751 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 643795724, + "proving_cost": 54484575741, + "congestion_cost": 199335357025, + "congestion_multiplier": 4615839751 + } + } + }, + { + "l1_block_number": 20973326, + "l1_fees": { + "blob_fee": 1002, + "base_fee": 19136803008 + }, + "parent_header": { + "excess_mana": 1307259668, + "mana_used": 107794157, + "proving_cost_per_mana_numerator": 101292328, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1315053825, + "mana_used": 104770501, + "proving_cost_per_mana_numerator": 67807403, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -33484925, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 3, + "gas_cost": 63390659, + "proving_cost": 5420846076, + "congestion_cost": 20062022743, + "congestion_multiplier": 4658124859 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 30, + "gas_cost": 633906590, + "proving_cost": 54208460760, + "congestion_cost": 200620227430, + "congestion_multiplier": 4658124859 + } + } + }, + { + "l1_block_number": 20973329, + "l1_fees": { + "blob_fee": 1127, + "base_fee": 19212580019 + }, + "parent_header": { + "excess_mana": 1315053825, + "mana_used": 104770501, + "proving_cost_per_mana_numerator": 67807403, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1319824326, + "mana_used": 97876951, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -111587454, + "fee_asset_price_modifier": -215251746 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 63641671, + "proving_cost": 5419031213, + "congestion_cost": 20199245969, + "congestion_multiplier": 4684196811 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 40, + "gas_cost": 636416710, + "proving_cost": 54190312130, + "congestion_cost": 201992459690, + "congestion_multiplier": 4684196811 + } + } + }, + { + "l1_block_number": 20973332, + "l1_fees": { + "blob_fee": 1172, + "base_fee": 20277424411 + }, + "parent_header": { + "excess_mana": 1319824326, + "mana_used": 97876951, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1317701277, + "mana_used": 46254371, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -99796762, + "fee_asset_price_modifier": -683803507 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 67168968, + "proving_cost": 5415357955, + "congestion_cost": 20134996032, + "congestion_multiplier": 4672575858 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 40, + "gas_cost": 671689680, + "proving_cost": 54153579550, + "congestion_cost": 201349960320, + "congestion_multiplier": 4672575858 + } + } + }, + { + "l1_block_number": 20973335, + "l1_fees": { + "blob_fee": 1268, + "base_fee": 19528446485 + }, + "parent_header": { + "excess_mana": 1317701277, + "mana_used": 46254371, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1263955648, + "mana_used": 134292665, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 63367084 + }, + "oracle_input": { + "proving_cost_modifier": -100537926, + "fee_asset_price_modifier": 63367084 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 64687978, + "proving_cost": 5415357955, + "congestion_cost": 18565303154, + "congestion_multiplier": 4387800644 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 40, + "gas_cost": 646879780, + "proving_cost": 54153579550, + "congestion_cost": 185653031540, + "congestion_multiplier": 4387800644 + } + } + }, + { + "l1_block_number": 20973338, + "l1_fees": { + "blob_fee": 1372, + "base_fee": 19587243385 + }, + "parent_header": { + "excess_mana": 1263955648, + "mana_used": 134292665, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 63367084 + }, + "header": { + "excess_mana": 1298248313, + "mana_used": 120510766, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -209476542, + "fee_asset_price_modifier": -928399810 + }, + "outputs": { + "fee_asset_price_at_execution": 10006338716, + "mana_base_fee_components_in_wei": { + "data_cost": 5, + "gas_cost": 64882743, + "proving_cost": 5415357955, + "congestion_cost": 19550371183, + "congestion_multiplier": 4567429287 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 50, + "gas_cost": 649238703, + "proving_cost": 54187905966, + "congestion_cost": 195627636080, + "congestion_multiplier": 4567429287 + } + } + }, + { + "l1_block_number": 20973341, + "l1_fees": { + "blob_fee": 1736, + "base_fee": 18965878234 + }, + "parent_header": { + "excess_mana": 1298248313, + "mana_used": 120510766, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1318759079, + "mana_used": 108139250, + "proving_cost_per_mana_numerator": 96857364, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 96857364, + "fee_asset_price_modifier": -933894862 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 62824471, + "proving_cost": 5415357955, + "congestion_cost": 20150740009, + "congestion_multiplier": 4678362351 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 60, + "gas_cost": 628244710, + "proving_cost": 54153579550, + "congestion_cost": 201507400090, + "congestion_multiplier": 4678362351 + } + } + }, + { + "l1_block_number": 20973344, + "l1_fees": { + "blob_fee": 1543, + "base_fee": 18373599419 + }, + "parent_header": { + "excess_mana": 1318759079, + "mana_used": 108139250, + "proving_cost_per_mana_numerator": 96857364, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1326898329, + "mana_used": 98216650, + "proving_cost_per_mana_numerator": 222484067, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 125626703, + "fee_asset_price_modifier": -619139751 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 60862548, + "proving_cost": 5420605668, + "congestion_cost": 20408201454, + "congestion_multiplier": 4723126839 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 60, + "gas_cost": 608625480, + "proving_cost": 54206056680, + "congestion_cost": 204082014540, + "congestion_multiplier": 4723126839 + } + } + }, + { + "l1_block_number": 20973347, + "l1_fees": { + "blob_fee": 1669, + "base_fee": 18117964296 + }, + "parent_header": { + "excess_mana": 1326898329, + "mana_used": 98216650, + "proving_cost_per_mana_numerator": 222484067, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1325114979, + "mana_used": 99643547, + "proving_cost_per_mana_numerator": 268172405, + "fee_asset_price_numerator": 562767444 + }, + "oracle_input": { + "proving_cost_modifier": 45688338, + "fee_asset_price_modifier": 562767444 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 60015756, + "proving_cost": 5427419676, + "congestion_cost": 20376396428, + "congestion_multiplier": 4713282217 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 60, + "gas_cost": 600157560, + "proving_cost": 54274196760, + "congestion_cost": 203763964280, + "congestion_multiplier": 4713282217 + } + } + }, + { + "l1_block_number": 20973350, + "l1_fees": { + "blob_fee": 1484, + "base_fee": 18635391729 + }, + "parent_header": { + "excess_mana": 1325114979, + "mana_used": 99643547, + "proving_cost_per_mana_numerator": 268172405, + "fee_asset_price_numerator": 562767444 + }, + "header": { + "excess_mana": 1324758526, + "mana_used": 94493495, + "proving_cost_per_mana_numerator": 275475534, + "fee_asset_price_numerator": 55546249 + }, + "oracle_input": { + "proving_cost_modifier": 7303129, + "fee_asset_price_modifier": -507221195 + }, + "outputs": { + "fee_asset_price_at_execution": 10056435395, + "mana_base_fee_components_in_wei": { + "data_cost": 5, + "gas_cost": 61729735, + "proving_cost": 5429899940, + "congestion_cost": 20381178325, + "congestion_multiplier": 4711316952 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 50, + "gas_cost": 620781091, + "proving_cost": 54605437947, + "congestion_cost": 204962003099, + "congestion_multiplier": 4711316952 + } + } + }, + { + "l1_block_number": 20973353, + "l1_fees": { + "blob_fee": 1669, + "base_fee": 17699124203 + }, + "parent_header": { + "excess_mana": 1324758526, + "mana_used": 94493495, + "proving_cost_per_mana_numerator": 275475534, + "fee_asset_price_numerator": 55546249 + }, + "header": { + "excess_mana": 1319252021, + "mana_used": 40141150, + "proving_cost_per_mana_numerator": 60908371, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -214567163, + "fee_asset_price_modifier": -205759070 + }, + "outputs": { + "fee_asset_price_at_execution": 10005556167, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 58628348, + "proving_cost": 5430296507, + "congestion_cost": 20205069087, + "congestion_multiplier": 4681061337 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 60, + "gas_cost": 586609228, + "proving_cost": 54333136704, + "congestion_cost": 202162953608, + "congestion_multiplier": 4681061337 + } + } + }, + { + "l1_block_number": 20973356, + "l1_fees": { + "blob_fee": 1878, + "base_fee": 19049659164 + }, + "parent_header": { + "excess_mana": 1319252021, + "mana_used": 40141150, + "proving_cost_per_mana_numerator": 60908371, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1259393171, + "mana_used": 139643833, + "proving_cost_per_mana_numerator": 23579480, + "fee_asset_price_numerator": 554264977 + }, + "oracle_input": { + "proving_cost_modifier": -37328891, + "fee_asset_price_modifier": 554264977 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 7, + "gas_cost": 63101995, + "proving_cost": 5418657366, + "congestion_cost": 18443053437, + "congestion_multiplier": 4364440538 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 70, + "gas_cost": 631019950, + "proving_cost": 54186573660, + "congestion_cost": 184430534370, + "congestion_multiplier": 4364440538 + } + } + }, + { + "l1_block_number": 20973359, + "l1_fees": { + "blob_fee": 2113, + "base_fee": 17952935112 + }, + "parent_header": { + "excess_mana": 1259393171, + "mana_used": 139643833, + "proving_cost_per_mana_numerator": 23579480, + "fee_asset_price_numerator": 554264977 + }, + "header": { + "excess_mana": 1299037004, + "mana_used": 107564368, + "proving_cost_per_mana_numerator": 83622719, + "fee_asset_price_numerator": 563075097 + }, + "oracle_input": { + "proving_cost_modifier": 60043239, + "fee_asset_price_modifier": 8810120 + }, + "outputs": { + "fee_asset_price_at_execution": 10055580386, + "mana_base_fee_components_in_wei": { + "data_cost": 8, + "gas_cost": 59469097, + "proving_cost": 5416635018, + "congestion_cost": 19558704904, + "congestion_multiplier": 4571645912 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 80, + "gas_cost": 597996285, + "proving_cost": 54467408845, + "congestion_cost": 196674129408, + "congestion_multiplier": 4571645912 + } + } + }, + { + "l1_block_number": 20973362, + "l1_fees": { + "blob_fee": 2377, + "base_fee": 17889199584 + }, + "parent_header": { + "excess_mana": 1299037004, + "mana_used": 107564368, + "proving_cost_per_mana_numerator": 83622719, + "fee_asset_price_numerator": 563075097 + }, + "header": { + "excess_mana": 1306601372, + "mana_used": 101620485, + "proving_cost_per_mana_numerator": 229458629, + "fee_asset_price_numerator": 494396072 + }, + "oracle_input": { + "proving_cost_modifier": 145835910, + "fee_asset_price_modifier": -68679025 + }, + "outputs": { + "fee_asset_price_at_execution": 10056466334, + "mana_base_fee_components_in_wei": { + "data_cost": 9, + "gas_cost": 59257973, + "proving_cost": 5419888318, + "congestion_cost": 19792243312, + "congestion_multiplier": 4612285971 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 90, + "gas_cost": 595925810, + "proving_cost": 54504924404, + "congestion_cost": 199040028541, + "congestion_multiplier": 4612285971 + } + } + }, + { + "l1_block_number": 20973365, + "l1_fees": { + "blob_fee": 2571, + "base_fee": 19972641950 + }, + "parent_header": { + "excess_mana": 1306601372, + "mana_used": 101620485, + "proving_cost_per_mana_numerator": 229458629, + "fee_asset_price_numerator": 494396072 + }, + "header": { + "excess_mana": 1308221857, + "mana_used": 94418152, + "proving_cost_per_mana_numerator": 141959240, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -87499389, + "fee_asset_price_modifier": -885807858 + }, + "outputs": { + "fee_asset_price_at_execution": 10049562022, + "mana_base_fee_components_in_wei": { + "data_cost": 10, + "gas_cost": 66159376, + "proving_cost": 5427798228, + "congestion_cost": 19893834839, + "congestion_multiplier": 4621039010 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 100, + "gas_cost": 664872752, + "proving_cost": 54546994935, + "congestion_cost": 199924327069, + "congestion_multiplier": 4621039010 + } + } + }, + { + "l1_block_number": 20973368, + "l1_fees": { + "blob_fee": 3661, + "base_fee": 19697758125 + }, + "parent_header": { + "excess_mana": 1308221857, + "mana_used": 94418152, + "proving_cost_per_mana_numerator": 141959240, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1302640009, + "mana_used": 101926798, + "proving_cost_per_mana_numerator": 156388847, + "fee_asset_price_numerator": 697009676 + }, + "oracle_input": { + "proving_cost_modifier": 14429607, + "fee_asset_price_modifier": 697009676 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 14, + "gas_cost": 65248823, + "proving_cost": 5423051015, + "congestion_cost": 19708256647, + "congestion_multiplier": 4590958435 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 140, + "gas_cost": 652488230, + "proving_cost": 54230510150, + "congestion_cost": 197082566470, + "congestion_multiplier": 4590958435 + } + } + }, + { + "l1_block_number": 20973371, + "l1_fees": { + "blob_fee": 4118, + "base_fee": 18752355505 + }, + "parent_header": { + "excess_mana": 1302640009, + "mana_used": 101926798, + "proving_cost_per_mana_numerator": 156388847, + "fee_asset_price_numerator": 697009676 + }, + "header": { + "excess_mana": 1304566807, + "mana_used": 115778581, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1399718159 + }, + "oracle_input": { + "proving_cost_modifier": -161415172, + "fee_asset_price_modifier": 702708483 + }, + "outputs": { + "fee_asset_price_at_execution": 10069944444, + "mana_base_fee_components_in_wei": { + "data_cost": 16, + "gas_cost": 62117177, + "proving_cost": 5423833596, + "congestion_cost": 19756662945, + "congestion_multiplier": 4601319754 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 161, + "gas_cost": 625516521, + "proving_cost": 54617702985, + "congestion_cost": 198948498254, + "congestion_multiplier": 4601319754 + } + } + }, + { + "l1_block_number": 20973374, + "l1_fees": { + "blob_fee": 5864, + "base_fee": 18133633771 + }, + "parent_header": { + "excess_mana": 1304566807, + "mana_used": 115778581, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1399718159 + }, + "header": { + "excess_mana": 1320345388, + "mana_used": 101438272, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 592952138 + }, + "oracle_input": { + "proving_cost_modifier": -154381148, + "fee_asset_price_modifier": -806766021 + }, + "outputs": { + "fee_asset_price_at_execution": 10140956007, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 60067661, + "proving_cost": 5415357955, + "congestion_cost": 20188186538, + "congestion_multiplier": 4687053367 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 233, + "gas_cost": 609143507, + "proving_cost": 54916906783, + "congestion_cost": 204727511542, + "congestion_multiplier": 4687053367 + } + } + }, + { + "l1_block_number": 20973377, + "l1_fees": { + "blob_fee": 6099, + "base_fee": 18370080806 + }, + "parent_header": { + "excess_mana": 1320345388, + "mana_used": 101438272, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 592952138 + }, + "header": { + "excess_mana": 1321783660, + "mana_used": 97073818, + "proving_cost_per_mana_numerator": 32850276, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 32850276, + "fee_asset_price_modifier": -629066323 + }, + "outputs": { + "fee_asset_price_at_execution": 10059471357, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 60850892, + "proving_cost": 5415357955, + "congestion_cost": 20234303063, + "congestion_multiplier": 4694947279 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 231, + "gas_cost": 612127805, + "proving_cost": 54475638236, + "congestion_cost": 203546392091, + "congestion_multiplier": 4694947279 + } + } + }, + { + "l1_block_number": 20973380, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 18504594480 + }, + "parent_header": { + "excess_mana": 1321783660, + "mana_used": 97073818, + "proving_cost_per_mana_numerator": 32850276, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1318857478, + "mana_used": 100868624, + "proving_cost_per_mana_numerator": 99918728, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 67068452, + "fee_asset_price_modifier": -125217171 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 61296469, + "proving_cost": 5417137207, + "congestion_cost": 20154615135, + "congestion_multiplier": 4678900987 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 210, + "gas_cost": 612964690, + "proving_cost": 54171372070, + "congestion_cost": 201546151350, + "congestion_multiplier": 4678900987 + } + } + }, + { + "l1_block_number": 20973383, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 17141190330 + }, + "parent_header": { + "excess_mana": 1318857478, + "mana_used": 100868624, + "proving_cost_per_mana_numerator": 99918728, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1319726102, + "mana_used": 99789829, + "proving_cost_per_mana_numerator": 72115258, + "fee_asset_price_numerator": 318131719 + }, + "oracle_input": { + "proving_cost_modifier": -27803470, + "fee_asset_price_modifier": 318131719 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 56780192, + "proving_cost": 5420771615, + "congestion_cost": 20177430492, + "congestion_multiplier": 4683658524 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 240, + "gas_cost": 567801920, + "proving_cost": 54207716150, + "congestion_cost": 201774304920, + "congestion_multiplier": 4683658524 + } + } + }, + { + "l1_block_number": 20973386, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 15977836153 + }, + "parent_header": { + "excess_mana": 1319726102, + "mana_used": 99789829, + "proving_cost_per_mana_numerator": 72115258, + "fee_asset_price_numerator": 318131719 + }, + "header": { + "excess_mana": 1319515931, + "mana_used": 109710155, + "proving_cost_per_mana_numerator": 89852123, + "fee_asset_price_numerator": 331643801 + }, + "oracle_input": { + "proving_cost_modifier": 17736865, + "fee_asset_price_modifier": 13512082 + }, + "outputs": { + "fee_asset_price_at_execution": 10031863829, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 52926582, + "proving_cost": 5419264662, + "congestion_cost": 20151382412, + "congestion_multiplier": 4682506954 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 280, + "gas_cost": 530952263, + "proving_cost": 54365325142, + "congestion_cost": 202155924323, + "congestion_multiplier": 4682506954 + } + } + }, + { + "l1_block_number": 20973389, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 18525791343 + }, + "parent_header": { + "excess_mana": 1319515931, + "mana_used": 109710155, + "proving_cost_per_mana_numerator": 89852123, + "fee_asset_price_numerator": 331643801 + }, + "header": { + "excess_mana": 1329226086, + "mana_used": 112920909, + "proving_cost_per_mana_numerator": 220131378, + "fee_asset_price_numerator": 572844933 + }, + "oracle_input": { + "proving_cost_modifier": 130279255, + "fee_asset_price_modifier": 241201132 + }, + "outputs": { + "fee_asset_price_at_execution": 10033219434, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 61366683, + "proving_cost": 5420225955, + "congestion_cost": 20479272349, + "congestion_multiplier": 4736007692 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 240, + "gas_cost": 615705396, + "proving_cost": 54382316388, + "congestion_cost": 205473033326, + "congestion_multiplier": 4736007692 + } + } + }, + { + "l1_block_number": 20973392, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 19690491466 + }, + "parent_header": { + "excess_mana": 1329226086, + "mana_used": 112920909, + "proving_cost_per_mana_numerator": 220131378, + "fee_asset_price_numerator": 572844933 + }, + "header": { + "excess_mana": 1342146995, + "mana_used": 97817168, + "proving_cost_per_mana_numerator": 191036242, + "fee_asset_price_numerator": 616910498 + }, + "oracle_input": { + "proving_cost_modifier": -29095136, + "fee_asset_price_modifier": 44065565 + }, + "outputs": { + "fee_asset_price_at_execution": 10057448882, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 65224752, + "proving_cost": 5427291987, + "congestion_cost": 20916316888, + "congestion_multiplier": 4808148031 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 221, + "gas_cost": 655994609, + "proving_cost": 54584711726, + "congestion_cost": 210364787900, + "congestion_multiplier": 4808148031 + } + } + }, + { + "l1_block_number": 20973395, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 20475655040 + }, + "parent_header": { + "excess_mana": 1342146995, + "mana_used": 97817168, + "proving_cost_per_mana_numerator": 191036242, + "fee_asset_price_numerator": 616910498 + }, + "header": { + "excess_mana": 1339964163, + "mana_used": 90562122, + "proving_cost_per_mana_numerator": 184355731, + "fee_asset_price_numerator": 493961965 + }, + "oracle_input": { + "proving_cost_modifier": -6680511, + "fee_asset_price_modifier": -122948533 + }, + "outputs": { + "fee_asset_price_at_execution": 10061881730, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 67825607, + "proving_cost": 5425713139, + "congestion_cost": 20852836497, + "congestion_multiplier": 4795884105 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 241, + "gas_cost": 682453235, + "proving_cost": 54592883905, + "congestion_cost": 209818774567, + "congestion_multiplier": 4795884105 + } + } + }, + { + "l1_block_number": 20973398, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 18119718386 + }, + "parent_header": { + "excess_mana": 1339964163, + "mana_used": 90562122, + "proving_cost_per_mana_numerator": 184355731, + "fee_asset_price_numerator": 493961965 + }, + "header": { + "excess_mana": 1330526285, + "mana_used": 96393394, + "proving_cost_per_mana_numerator": 47505824, + "fee_asset_price_numerator": 152096606 + }, + "oracle_input": { + "proving_cost_modifier": -136849907, + "fee_asset_price_modifier": -341865359 + }, + "outputs": { + "fee_asset_price_at_execution": 10049518396, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 60021567, + "proving_cost": 5425350686, + "congestion_cost": 20532942860, + "congestion_multiplier": 4743217745 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 281, + "gas_cost": 603187841, + "proving_cost": 54522161523, + "congestion_cost": 206346186995, + "congestion_multiplier": 4743217745 + } + } + }, + { + "l1_block_number": 20973401, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 18420060434 + }, + "parent_header": { + "excess_mana": 1330526285, + "mana_used": 96393394, + "proving_cost_per_mana_numerator": 47505824, + "fee_asset_price_numerator": 152096606 + }, + "header": { + "excess_mana": 1326919679, + "mana_used": 80950635, + "proving_cost_per_mana_numerator": 158293696, + "fee_asset_price_numerator": 254761933 + }, + "oracle_input": { + "proving_cost_modifier": 110787872, + "fee_asset_price_modifier": 102665327 + }, + "outputs": { + "fee_asset_price_at_execution": 10015221233, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 61016450, + "proving_cost": 5417931176, + "congestion_cost": 20399463512, + "congestion_multiplier": 4723244822 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 360, + "gas_cost": 611093245, + "proving_cost": 54261779352, + "congestion_cost": 204305140107, + "congestion_multiplier": 4723244822 + } + } + }, + { + "l1_block_number": 20973404, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 18056451924 + }, + "parent_header": { + "excess_mana": 1326919679, + "mana_used": 80950635, + "proving_cost_per_mana_numerator": 158293696, + "fee_asset_price_numerator": 254761933 + }, + "header": { + "excess_mana": 1307870314, + "mana_used": 104359267, + "proving_cost_per_mana_numerator": 3583324, + "fee_asset_price_numerator": 32654620 + }, + "oracle_input": { + "proving_cost_modifier": -154710372, + "fee_asset_price_modifier": -222107313 + }, + "outputs": { + "fee_asset_price_at_execution": 10025508672, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 59811996, + "proving_cost": 5423936913, + "congestion_cost": 19846448260, + "congestion_multiplier": 4619138743 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 350, + "gas_cost": 599645684, + "proving_cost": 54377726557, + "congestion_cost": 198970739139, + "congestion_multiplier": 4619138743 + } + } + }, + { + "l1_block_number": 20973407, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 18137301254 + }, + "parent_header": { + "excess_mana": 1307870314, + "mana_used": 104359267, + "proving_cost_per_mana_numerator": 3583324, + "fee_asset_price_numerator": 32654620 + }, + "header": { + "excess_mana": 1312229581, + "mana_used": 104159990, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 629122643 + }, + "oracle_input": { + "proving_cost_modifier": -24449045, + "fee_asset_price_modifier": 596468023 + }, + "outputs": { + "fee_asset_price_at_execution": 10003265995, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 60079810, + "proving_cost": 5415552008, + "congestion_cost": 19946402356, + "congestion_multiplier": 4642758115 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 320, + "gas_cost": 600994320, + "proving_cost": 54173207245, + "congestion_cost": 199529168410, + "congestion_multiplier": 4642758115 + } + } + }, + { + "l1_block_number": 20973410, + "l1_fees": { + "blob_fee": 7719, + "base_fee": 17694593322 + }, + "parent_header": { + "excess_mana": 1312229581, + "mana_used": 104159990, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 629122643 + }, + "header": { + "excess_mana": 1316389571, + "mana_used": 100721544, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -1988703, + "fee_asset_price_modifier": -660845787 + }, + "outputs": { + "fee_asset_price_at_execution": 10063110577, + "mana_base_fee_components_in_wei": { + "data_cost": 30, + "gas_cost": 58613340, + "proving_cost": 5415357955, + "congestion_cost": 20064351281, + "congestion_multiplier": 4665410374 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 301, + "gas_cost": 589832521, + "proving_cost": 54495345915, + "congestion_cost": 201909785596, + "congestion_multiplier": 4665410374 + } + } + }, + { + "l1_block_number": 20973413, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 17130338099 + }, + "parent_header": { + "excess_mana": 1316389571, + "mana_used": 100721544, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1317111115, + "mana_used": 98622363, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -70656247, + "fee_asset_price_modifier": -322344917 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 56744244, + "proving_cost": 5415357955, + "congestion_cost": 20079061631, + "congestion_multiplier": 4669350607 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 290, + "gas_cost": 567442440, + "proving_cost": 54153579550, + "congestion_cost": 200790616310, + "congestion_multiplier": 4669350607 + } + } + }, + { + "l1_block_number": 20973416, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 16184100257 + }, + "parent_header": { + "excess_mana": 1317111115, + "mana_used": 98622363, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1315733478, + "mana_used": 100888431, + "proving_cost_per_mana_numerator": 3503723, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 3503723, + "fee_asset_price_modifier": -870786204 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 53609832, + "proving_cost": 5415357955, + "congestion_cost": 20026432851, + "congestion_multiplier": 4661830445 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 290, + "gas_cost": 536098320, + "proving_cost": 54153579550, + "congestion_cost": 200264328510, + "congestion_multiplier": 4661830445 + } + } + }, + { + "l1_block_number": 20973419, + "l1_fees": { + "blob_fee": 5864, + "base_fee": 15185448051 + }, + "parent_header": { + "excess_mana": 1315733478, + "mana_used": 100888431, + "proving_cost_per_mana_numerator": 3503723, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1316621909, + "mana_used": 94491057, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -61497457, + "fee_asset_price_modifier": -550404902 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 50301796, + "proving_cost": 5415547697, + "congestion_cost": 20041514385, + "congestion_multiplier": 4666678771 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 230, + "gas_cost": 503017960, + "proving_cost": 54155476970, + "congestion_cost": 200415143850, + "congestion_multiplier": 4666678771 + } + } + }, + { + "l1_block_number": 20973422, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 15575959350 + }, + "parent_header": { + "excess_mana": 1316621909, + "mana_used": 94491057, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1311112966, + "mana_used": 107964581, + "proving_cost_per_mana_numerator": 81072380, + "fee_asset_price_numerator": 56425732 + }, + "oracle_input": { + "proving_cost_modifier": 81072380, + "fee_asset_price_modifier": 56425732 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 51595365, + "proving_cost": 5415357955, + "congestion_cost": 19881650612, + "congestion_multiplier": 4636696592 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 290, + "gas_cost": 515953650, + "proving_cost": 54153579550, + "congestion_cost": 198816506120, + "congestion_multiplier": 4636696592 + } + } + }, + { + "l1_block_number": 20973425, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 16430884636 + }, + "parent_header": { + "excess_mana": 1311112966, + "mana_used": 107964581, + "proving_cost_per_mana_numerator": 81072380, + "fee_asset_price_numerator": 56425732 + }, + "header": { + "excess_mana": 1319077547, + "mana_used": 100806765, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -218500226, + "fee_asset_price_modifier": -122148504 + }, + "outputs": { + "fee_asset_price_at_execution": 10005644165, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 54427305, + "proving_cost": 5419750094, + "congestion_cost": 20145552480, + "congestion_multiplier": 4680105869 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 290, + "gas_cost": 544580246, + "proving_cost": 54228090903, + "congestion_cost": 201569229622, + "congestion_multiplier": 4680105869 + } + } + }, + { + "l1_block_number": 20973428, + "l1_fees": { + "blob_fee": 8028, + "base_fee": 16321037138 + }, + "parent_header": { + "excess_mana": 1319077547, + "mana_used": 100806765, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1319884312, + "mana_used": 101075675, + "proving_cost_per_mana_numerator": 196535371, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 196535371, + "fee_asset_price_modifier": -861438231 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 31, + "gas_cost": 54063435, + "proving_cost": 5415357955, + "congestion_cost": 20152223111, + "congestion_multiplier": 4684525576 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 310, + "gas_cost": 540634350, + "proving_cost": 54153579550, + "congestion_cost": 201522231110, + "congestion_multiplier": 4684525576 + } + } + }, + { + "l1_block_number": 20973431, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 16122514868 + }, + "parent_header": { + "excess_mana": 1319884312, + "mana_used": 101075675, + "proving_cost_per_mana_numerator": 196535371, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1320959987, + "mana_used": 100604576, + "proving_cost_per_mana_numerator": 210400315, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 13864944, + "fee_asset_price_modifier": -310116113 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 53405830, + "proving_cost": 5426011514, + "congestion_cost": 20221378610, + "congestion_multiplier": 4690424950 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 360, + "gas_cost": 534058300, + "proving_cost": 54260115140, + "congestion_cost": 202213786100, + "congestion_multiplier": 4690424950 + } + } + }, + { + "l1_block_number": 20973434, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 16014219091 + }, + "parent_header": { + "excess_mana": 1320959987, + "mana_used": 100604576, + "proving_cost_per_mana_numerator": 210400315, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1321564563, + "mana_used": 103203146, + "proving_cost_per_mana_numerator": 270784851, + "fee_asset_price_numerator": 184588769 + }, + "oracle_input": { + "proving_cost_modifier": 60384536, + "fee_asset_price_modifier": 184588769 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 53047100, + "proving_cost": 5426763880, + "congestion_cost": 20241018634, + "congestion_multiplier": 4693743914 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 480, + "gas_cost": 530471000, + "proving_cost": 54267638800, + "congestion_cost": 202410186340, + "congestion_multiplier": 4693743914 + } + } + }, + { + "l1_block_number": 20973437, + "l1_fees": { + "blob_fee": 10568, + "base_fee": 15999039375 + }, + "parent_header": { + "excess_mana": 1321564563, + "mana_used": 103203146, + "proving_cost_per_mana_numerator": 270784851, + "fee_asset_price_numerator": 184588769 + }, + "header": { + "excess_mana": 1324767709, + "mana_used": 103564808, + "proving_cost_per_mana_numerator": 148275372, + "fee_asset_price_numerator": 706703095 + }, + "oracle_input": { + "proving_cost_modifier": -122509479, + "fee_asset_price_modifier": 522114326 + }, + "outputs": { + "fee_asset_price_at_execution": 10018475923, + "mana_base_fee_components_in_wei": { + "data_cost": 41, + "gas_cost": 52996817, + "proving_cost": 5430041795, + "congestion_cost": 20349571847, + "congestion_multiplier": 4711367571 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 410, + "gas_cost": 530947335, + "proving_cost": 54400742984, + "congestion_cost": 203871695592, + "congestion_multiplier": 4711367571 + } + } + }, + { + "l1_block_number": 20973440, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 15287943997 + }, + "parent_header": { + "excess_mana": 1324767709, + "mana_used": 103564808, + "proving_cost_per_mana_numerator": 148275372, + "fee_asset_price_numerator": 706703095 + }, + "header": { + "excess_mana": 1328332517, + "mana_used": 83509824, + "proving_cost_per_mana_numerator": 210001776, + "fee_asset_price_numerator": 1706703095 + }, + "oracle_input": { + "proving_cost_modifier": 61726404, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10070920613, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 50641314, + "proving_cost": 5423393553, + "congestion_cost": 20423946683, + "congestion_multiplier": 4731058899 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 483, + "gas_cost": 510004653, + "proving_cost": 54618565925, + "congestion_cost": 205687945648, + "congestion_multiplier": 4731058899 + } + } + }, + { + "l1_block_number": 20973443, + "l1_fees": { + "blob_fee": 11889, + "base_fee": 16054573592 + }, + "parent_header": { + "excess_mana": 1328332517, + "mana_used": 83509824, + "proving_cost_per_mana_numerator": 210001776, + "fee_asset_price_numerator": 1706703095 + }, + "header": { + "excess_mana": 1311842341, + "mana_used": 102290817, + "proving_cost_per_mana_numerator": 251023939, + "fee_asset_price_numerator": 931130184 + }, + "oracle_input": { + "proving_cost_modifier": 41022163, + "fee_asset_price_modifier": -775572911 + }, + "outputs": { + "fee_asset_price_at_execution": 10172135048, + "mana_base_fee_components_in_wei": { + "data_cost": 46, + "gas_cost": 53180775, + "proving_cost": 5426742252, + "congestion_cost": 19950509844, + "congestion_multiplier": 4640655093 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 467, + "gas_cost": 540962025, + "proving_cost": 55201555058, + "congestion_cost": 202939280409, + "congestion_multiplier": 4640655093 + } + } + }, + { + "l1_block_number": 20973446, + "l1_fees": { + "blob_fee": 13910, + "base_fee": 15218141837 + }, + "parent_header": { + "excess_mana": 1311842341, + "mana_used": 102290817, + "proving_cost_per_mana_numerator": 251023939, + "fee_asset_price_numerator": 931130184 + }, + "header": { + "excess_mana": 1314133158, + "mana_used": 65360376, + "proving_cost_per_mana_numerator": 398208983, + "fee_asset_price_numerator": 981642141 + }, + "oracle_input": { + "proving_cost_modifier": 147185044, + "fee_asset_price_modifier": 50511957 + }, + "outputs": { + "fee_asset_price_at_execution": 10093547868, + "mana_base_fee_components_in_wei": { + "data_cost": 54, + "gas_cost": 50410094, + "proving_cost": 5428968876, + "congestion_cost": 20016773868, + "congestion_multiplier": 4653109920 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 545, + "gas_cost": 508816696, + "proving_cost": 54797557223, + "congestion_cost": 202040265199, + "congestion_multiplier": 4653109920 + } + } + }, + { + "l1_block_number": 20973449, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 13615000865 + }, + "parent_header": { + "excess_mana": 1314133158, + "mana_used": 65360376, + "proving_cost_per_mana_numerator": 398208983, + "fee_asset_price_numerator": 981642141 + }, + "header": { + "excess_mana": 1279493534, + "mana_used": 139029355, + "proving_cost_per_mana_numerator": 374671734, + "fee_asset_price_numerator": 931807111 + }, + "oracle_input": { + "proving_cost_modifier": -23537249, + "fee_asset_price_modifier": -49835030 + }, + "outputs": { + "fee_asset_price_at_execution": 10098647605, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 45099690, + "proving_cost": 5436965389, + "congestion_cost": 19013432147, + "congestion_multiplier": 4468297376 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 636, + "gas_cost": 455445876, + "proving_cost": 54905997504, + "congestion_cost": 192009951014, + "congestion_multiplier": 4468297376 + } + } + }, + { + "l1_block_number": 20973452, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 15419645270 + }, + "parent_header": { + "excess_mana": 1279493534, + "mana_used": 139029355, + "proving_cost_per_mana_numerator": 374671734, + "fee_asset_price_numerator": 931807111 + }, + "header": { + "excess_mana": 1318522889, + "mana_used": 111326678, + "proving_cost_per_mana_numerator": 418751286, + "fee_asset_price_numerator": 1920185324 + }, + "oracle_input": { + "proving_cost_modifier": 44079552, + "fee_asset_price_modifier": 988378213 + }, + "outputs": { + "fee_asset_price_at_execution": 10093616194, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 51077574, + "proving_cost": 5435685828, + "congestion_cost": 20175211633, + "congestion_multiplier": 4677069700 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 484, + "gas_cost": 515557428, + "proving_cost": 54865726498, + "congestion_cost": 203640842856, + "congestion_multiplier": 4677069700 + } + } + }, + { + "l1_block_number": 20973455, + "l1_fees": { + "blob_fee": 11889, + "base_fee": 14609143504 + }, + "parent_header": { + "excess_mana": 1318522889, + "mana_used": 111326678, + "proving_cost_per_mana_numerator": 418751286, + "fee_asset_price_numerator": 1920185324 + }, + "header": { + "excess_mana": 1329849567, + "mana_used": 88606966, + "proving_cost_per_mana_numerator": 415078001, + "fee_asset_price_numerator": 1682521585 + }, + "oracle_input": { + "proving_cost_modifier": -3673285, + "fee_asset_price_modifier": -237663739 + }, + "outputs": { + "fee_asset_price_at_execution": 10193873944, + "mana_base_fee_components_in_wei": { + "data_cost": 46, + "gas_cost": 48392787, + "proving_cost": 5438082382, + "congestion_cost": 20516475132, + "congestion_multiplier": 4739463741 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 468, + "gas_cost": 493309970, + "proving_cost": 55435126299, + "congestion_cost": 209142361270, + "congestion_multiplier": 4739463741 + } + } + }, + { + "l1_block_number": 20973458, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 15085608411 + }, + "parent_header": { + "excess_mana": 1329849567, + "mana_used": 88606966, + "proving_cost_per_mana_numerator": 415078001, + "fee_asset_price_numerator": 1682521585 + }, + "header": { + "excess_mana": 1318456533, + "mana_used": 102801105, + "proving_cost_per_mana_numerator": 429004476, + "fee_asset_price_numerator": 2444732238 + }, + "oracle_input": { + "proving_cost_modifier": 13926475, + "fee_asset_price_modifier": 762210653 + }, + "outputs": { + "fee_asset_price_at_execution": 10169675569, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 49971077, + "proving_cost": 5437882629, + "congestion_cost": 20177228091, + "congestion_multiplier": 4676706602 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 386, + "gas_cost": 508189640, + "proving_cost": 55301502119, + "congestion_cost": 205195863567, + "congestion_multiplier": 4676706602 + } + } + }, + { + "l1_block_number": 20973461, + "l1_fees": { + "blob_fee": 11431, + "base_fee": 14312834898 + }, + "parent_header": { + "excess_mana": 1318456533, + "mana_used": 102801105, + "proving_cost_per_mana_numerator": 429004476, + "fee_asset_price_numerator": 2444732238 + }, + "header": { + "excess_mana": 1321257638, + "mana_used": 98200479, + "proving_cost_per_mana_numerator": 378149572, + "fee_asset_price_numerator": 2307269582 + }, + "oracle_input": { + "proving_cost_modifier": -50854904, + "fee_asset_price_modifier": -137462656 + }, + "outputs": { + "fee_asset_price_at_execution": 10247486083, + "mana_base_fee_components_in_wei": { + "data_cost": 44, + "gas_cost": 47411265, + "proving_cost": 5438639987, + "congestion_cost": 20254823317, + "congestion_multiplier": 4692058682 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 450, + "gas_cost": 485846278, + "proving_cost": 55732387577, + "congestion_cost": 207561020054, + "congestion_multiplier": 4692058682 + } + } + }, + { + "l1_block_number": 20973464, + "l1_fees": { + "blob_fee": 13375, + "base_fee": 14648933305 + }, + "parent_header": { + "excess_mana": 1321257638, + "mana_used": 98200479, + "proving_cost_per_mana_numerator": 378149572, + "fee_asset_price_numerator": 2307269582 + }, + "header": { + "excess_mana": 1319458117, + "mana_used": 111026869, + "proving_cost_per_mana_numerator": 466968694, + "fee_asset_price_numerator": 3297800050 + }, + "oracle_input": { + "proving_cost_modifier": 88819122, + "fee_asset_price_modifier": 990530468 + }, + "outputs": { + "fee_asset_price_at_execution": 10233409294, + "mana_base_fee_components_in_wei": { + "data_cost": 52, + "gas_cost": 48524591, + "proving_cost": 5435874875, + "congestion_cost": 20194602317, + "congestion_multiplier": 4682190229 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 532, + "gas_cost": 496572000, + "proving_cost": 55627532466, + "congestion_cost": 206659631039, + "congestion_multiplier": 4682190229 + } + } + }, + { + "l1_block_number": 20973467, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 14460098285 + }, + "parent_header": { + "excess_mana": 1319458117, + "mana_used": 111026869, + "proving_cost_per_mana_numerator": 466968694, + "fee_asset_price_numerator": 3297800050 + }, + "header": { + "excess_mana": 1330484986, + "mana_used": 89014895, + "proving_cost_per_mana_numerator": 569856216, + "fee_asset_price_numerator": 3100410811 + }, + "oracle_input": { + "proving_cost_modifier": 102887522, + "fee_asset_price_modifier": -197389239 + }, + "outputs": { + "fee_asset_price_at_execution": 10335278018, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 47899075, + "proving_cost": 5440705116, + "congestion_cost": 20543782871, + "congestion_multiplier": 4742988559 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 496, + "gas_cost": 495050256, + "proving_cost": 56231199987, + "congestion_cost": 212325707513, + "congestion_multiplier": 4742988559 + } + } + }, + { + "l1_block_number": 20973470, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 13977736089 + }, + "parent_header": { + "excess_mana": 1330484986, + "mana_used": 89014895, + "proving_cost_per_mana_numerator": 569856216, + "fee_asset_price_numerator": 3100410811 + }, + "header": { + "excess_mana": 1319499881, + "mana_used": 86837462, + "proving_cost_per_mana_numerator": 400019914, + "fee_asset_price_numerator": 2376944353 + }, + "oracle_input": { + "proving_cost_modifier": -169836302, + "fee_asset_price_modifier": -723466458 + }, + "outputs": { + "fee_asset_price_at_execution": 10314897413, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 46301250, + "proving_cost": 5446305804, + "congestion_cost": 20226080839, + "congestion_multiplier": 4682419024 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 371, + "gas_cost": 477592643, + "proving_cost": 56178085648, + "congestion_cost": 208629948921, + "congestion_multiplier": 4682419024 + } + } + }, + { + "l1_block_number": 20973473, + "l1_fees": { + "blob_fee": 10161, + "base_fee": 13453174678 + }, + "parent_header": { + "excess_mana": 1319499881, + "mana_used": 86837462, + "proving_cost_per_mana_numerator": 400019914, + "fee_asset_price_numerator": 2376944353 + }, + "header": { + "excess_mana": 1306337343, + "mana_used": 110299037, + "proving_cost_per_mana_numerator": 433582759, + "fee_asset_price_numerator": 2738803177 + }, + "oracle_input": { + "proving_cost_modifier": 33562845, + "fee_asset_price_modifier": 361858824 + }, + "outputs": { + "fee_asset_price_at_execution": 10240541883, + "mana_base_fee_components_in_wei": { + "data_cost": 39, + "gas_cost": 44563641, + "proving_cost": 5437063850, + "congestion_cost": 19793397213, + "congestion_multiplier": 4610861392 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 399, + "gas_cost": 456355832, + "proving_cost": 55678480076, + "congestion_cost": 202695113166, + "congestion_multiplier": 4610861392 + } + } + }, + { + "l1_block_number": 20973476, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 13408774809 + }, + "parent_header": { + "excess_mana": 1306337343, + "mana_used": 110299037, + "proving_cost_per_mana_numerator": 433582759, + "fee_asset_price_numerator": 2738803177 + }, + "header": { + "excess_mana": 1316636380, + "mana_used": 103749155, + "proving_cost_per_mana_numerator": 508162696, + "fee_asset_price_numerator": 1738803177 + }, + "oracle_input": { + "proving_cost_modifier": 74579937, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10277665314, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 44416566, + "proving_cost": 5438888989, + "congestion_cost": 20105953448, + "congestion_multiplier": 4666757783 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 359, + "gas_cost": 456498599, + "proving_cost": 55899080708, + "congestion_cost": 206642260357, + "congestion_multiplier": 4666757783 + } + } + }, + { + "l1_block_number": 20973479, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 12441369415 + }, + "parent_header": { + "excess_mana": 1316636380, + "mana_used": 103749155, + "proving_cost_per_mana_numerator": 508162696, + "fee_asset_price_numerator": 1738803177 + }, + "header": { + "excess_mana": 1320385535, + "mana_used": 95638144, + "proving_cost_per_mana_numerator": 427579520, + "fee_asset_price_numerator": 1939889114 + }, + "oracle_input": { + "proving_cost_modifier": -80583176, + "fee_asset_price_modifier": 201085937 + }, + "outputs": { + "fee_asset_price_at_execution": 10175400836, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 41212036, + "proving_cost": 5442946822, + "congestion_cost": 20221593936, + "congestion_multiplier": 4687273533 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 356, + "gas_cost": 419348985, + "proving_cost": 55384165642, + "congestion_cost": 205762823841, + "congestion_multiplier": 4687273533 + } + } + }, + { + "l1_block_number": 20973482, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 13666269945 + }, + "parent_header": { + "excess_mana": 1320385535, + "mana_used": 95638144, + "proving_cost_per_mana_numerator": 427579520, + "fee_asset_price_numerator": 1939889114 + }, + "header": { + "excess_mana": 1316023679, + "mana_used": 90637725, + "proving_cost_per_mana_numerator": 357292279, + "fee_asset_price_numerator": 1840626366 + }, + "oracle_input": { + "proving_cost_modifier": -70287241, + "fee_asset_price_modifier": -99262748 + }, + "outputs": { + "fee_asset_price_at_execution": 10195882722, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 45269519, + "proving_cost": 5438562490, + "congestion_cost": 20089544709, + "congestion_multiplier": 4663413569 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 326, + "gas_cost": 461562706, + "proving_cost": 55450945324, + "congestion_cost": 204830641791, + "congestion_multiplier": 4663413569 + } + } + }, + { + "l1_block_number": 20973485, + "l1_fees": { + "blob_fee": 10991, + "base_fee": 14378775361 + }, + "parent_header": { + "excess_mana": 1316023679, + "mana_used": 90637725, + "proving_cost_per_mana_numerator": 357292279, + "fee_asset_price_numerator": 1840626366 + }, + "header": { + "excess_mana": 1306661404, + "mana_used": 122727699, + "proving_cost_per_mana_numerator": 551873296, + "fee_asset_price_numerator": 2609752577 + }, + "oracle_input": { + "proving_cost_modifier": 194581017, + "fee_asset_price_modifier": 769126211 + }, + "outputs": { + "fee_asset_price_at_execution": 10185767030, + "mana_base_fee_components_in_wei": { + "data_cost": 43, + "gas_cost": 47629693, + "proving_cost": 5434741217, + "congestion_cost": 19805667788, + "congestion_multiplier": 4612609938 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 437, + "gas_cost": 485144956, + "proving_cost": 55357007904, + "congestion_cost": 201735917962, + "congestion_multiplier": 4612609938 + } + } + }, + { + "l1_block_number": 20973488, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 14272987887 + }, + "parent_header": { + "excess_mana": 1306661404, + "mana_used": 122727699, + "proving_cost_per_mana_numerator": 551873296, + "fee_asset_price_numerator": 2609752577 + }, + "header": { + "excess_mana": 1329389103, + "mana_used": 99727233, + "proving_cost_per_mana_numerator": 285835544, + "fee_asset_price_numerator": 3084375033 + }, + "oracle_input": { + "proving_cost_modifier": -266037752, + "fee_asset_price_modifier": 474622456 + }, + "outputs": { + "fee_asset_price_at_execution": 10264410480, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 47279272, + "proving_cost": 5445326487, + "congestion_cost": 20525379444, + "congestion_multiplier": 4736911077 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 390, + "gas_cost": 485293855, + "proving_cost": 55893066260, + "congestion_cost": 210680919870, + "congestion_multiplier": 4736911077 + } + } + }, + { + "l1_block_number": 20973491, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 14695176958 + }, + "parent_header": { + "excess_mana": 1329389103, + "mana_used": 99727233, + "proving_cost_per_mana_numerator": 285835544, + "fee_asset_price_numerator": 3084375033 + }, + "header": { + "excess_mana": 1329116336, + "mana_used": 82105056, + "proving_cost_per_mana_numerator": 412888248, + "fee_asset_price_numerator": 3116627095 + }, + "oracle_input": { + "proving_cost_modifier": 127052704, + "fee_asset_price_modifier": 32252062 + }, + "outputs": { + "fee_asset_price_at_execution": 10313243472, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 48677773, + "proving_cost": 5430859116, + "congestion_cost": 20468259993, + "congestion_multiplier": 4735399592 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 371, + "gas_cost": 502025724, + "proving_cost": 56009772325, + "congestion_cost": 211094148756, + "congestion_multiplier": 4735399592 + } + } + }, + { + "l1_block_number": 20973494, + "l1_fees": { + "blob_fee": 12860, + "base_fee": 14320169685 + }, + "parent_header": { + "excess_mana": 1329116336, + "mana_used": 82105056, + "proving_cost_per_mana_numerator": 412888248, + "fee_asset_price_numerator": 3116627095 + }, + "header": { + "excess_mana": 1311221392, + "mana_used": 93681672, + "proving_cost_per_mana_numerator": 304560378, + "fee_asset_price_numerator": 3756345736 + }, + "oracle_input": { + "proving_cost_modifier": -108327870, + "fee_asset_price_modifier": 639718641 + }, + "outputs": { + "fee_asset_price_at_execution": 10316570242, + "mana_base_fee_components_in_wei": { + "data_cost": 50, + "gas_cost": 47435562, + "proving_cost": 5437763554, + "congestion_cost": 19951231737, + "congestion_multiplier": 4637284834 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 515, + "gas_cost": 489372307, + "proving_cost": 56099069664, + "congestion_cost": 205828283629, + "congestion_multiplier": 4637284834 + } + } + }, + { + "l1_block_number": 20973497, + "l1_fees": { + "blob_fee": 14467, + "base_fee": 14624476597 + }, + "parent_header": { + "excess_mana": 1311221392, + "mana_used": 93681672, + "proving_cost_per_mana_numerator": 304560378, + "fee_asset_price_numerator": 3756345736 + }, + "header": { + "excess_mana": 1304903064, + "mana_used": 109568285, + "proving_cost_per_mana_numerator": 292493513, + "fee_asset_price_numerator": 4217767568 + }, + "oracle_input": { + "proving_cost_modifier": -12066865, + "fee_asset_price_modifier": 461421832 + }, + "outputs": { + "fee_asset_price_at_execution": 10382778813, + "mana_base_fee_components_in_wei": { + "data_cost": 56, + "gas_cost": 48443578, + "proving_cost": 5431876130, + "congestion_cost": 19746306546, + "congestion_multiplier": 4603130364 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 581, + "gas_cost": 502978955, + "proving_cost": 56397968397, + "congestion_cost": 205021533240, + "congestion_multiplier": 4603130364 + } + } + }, + { + "l1_block_number": 20973500, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 15231641377 + }, + "parent_header": { + "excess_mana": 1304903064, + "mana_used": 109568285, + "proving_cost_per_mana_numerator": 292493513, + "fee_asset_price_numerator": 4217767568 + }, + "header": { + "excess_mana": 1314471349, + "mana_used": 102110913, + "proving_cost_per_mana_numerator": 267362944, + "fee_asset_price_numerator": 4455082919 + }, + "oracle_input": { + "proving_cost_modifier": -25130569, + "fee_asset_price_modifier": 237315351 + }, + "outputs": { + "fee_asset_price_at_execution": 10430797921, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 50454812, + "proving_cost": 5431220713, + "congestion_cost": 20035258100, + "congestion_multiplier": 4654951443 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 657, + "gas_cost": 526283948, + "proving_cost": 56651965721, + "congestion_cost": 208983728536, + "congestion_multiplier": 4654951443 + } + } + }, + { + "l1_block_number": 20973503, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 13996481627 + }, + "parent_header": { + "excess_mana": 1314471349, + "mana_used": 102110913, + "proving_cost_per_mana_numerator": 267362944, + "fee_asset_price_numerator": 4455082919 + }, + "header": { + "excess_mana": 1316582262, + "mana_used": 110421352, + "proving_cost_per_mana_numerator": 453360181, + "fee_asset_price_numerator": 4592575600 + }, + "oracle_input": { + "proving_cost_modifier": 185997237, + "fee_asset_price_modifier": 137492681 + }, + "outputs": { + "fee_asset_price_at_execution": 10455581202, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 46363345, + "proving_cost": 5429855988, + "congestion_cost": 20078351978, + "congestion_multiplier": 4666462303 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 658, + "gas_cost": 484755718, + "proving_cost": 56772300197, + "congestion_cost": 209930839508, + "congestion_multiplier": 4666462303 + } + } + }, + { + "l1_block_number": 20973506, + "l1_fees": { + "blob_fee": 13375, + "base_fee": 13706103465 + }, + "parent_header": { + "excess_mana": 1316582262, + "mana_used": 110421352, + "proving_cost_per_mana_numerator": 453360181, + "fee_asset_price_numerator": 4592575600 + }, + "header": { + "excess_mana": 1327003614, + "mana_used": 108194469, + "proving_cost_per_mana_numerator": 374375618, + "fee_asset_price_numerator": 5151371732 + }, + "oracle_input": { + "proving_cost_modifier": -78984563, + "fee_asset_price_modifier": 558796132 + }, + "outputs": { + "fee_asset_price_at_execution": 10469966748, + "mana_base_fee_components_in_wei": { + "data_cost": 52, + "gas_cost": 45401467, + "proving_cost": 5439964768, + "congestion_cost": 20425906088, + "congestion_multiplier": 4723708686 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 544, + "gas_cost": 475351849, + "proving_cost": 56956250231, + "congestion_cost": 213858557539, + "congestion_multiplier": 4723708686 + } + } + }, + { + "l1_block_number": 20973509, + "l1_fees": { + "blob_fee": 16928, + "base_fee": 15294708227 + }, + "parent_header": { + "excess_mana": 1327003614, + "mana_used": 108194469, + "proving_cost_per_mana_numerator": 374375618, + "fee_asset_price_numerator": 5151371732 + }, + "header": { + "excess_mana": 1335198083, + "mana_used": 92861766, + "proving_cost_per_mana_numerator": 195541519, + "fee_asset_price_numerator": 5340082778 + }, + "oracle_input": { + "proving_cost_modifier": -178834099, + "fee_asset_price_modifier": 188711046 + }, + "outputs": { + "fee_asset_price_at_execution": 10528636286, + "mana_base_fee_components_in_wei": { + "data_cost": 66, + "gas_cost": 50663721, + "proving_cost": 5435669732, + "congestion_cost": 20679171565, + "congestion_multiplier": 4769215177 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 694, + "gas_cost": 533419891, + "proving_cost": 57230189579, + "congestion_cost": 217723476103, + "congestion_multiplier": 4769215177 + } + } + }, + { + "l1_block_number": 20973512, + "l1_fees": { + "blob_fee": 11889, + "base_fee": 16431846806 + }, + "parent_header": { + "excess_mana": 1335198083, + "mana_used": 92861766, + "proving_cost_per_mana_numerator": 195541519, + "fee_asset_price_numerator": 5340082778 + }, + "header": { + "excess_mana": 1328059849, + "mana_used": 88389595, + "proving_cost_per_mana_numerator": 283776529, + "fee_asset_price_numerator": 6340082778 + }, + "oracle_input": { + "proving_cost_modifier": 88235010, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10548523745, + "mana_base_fee_components_in_wei": { + "data_cost": 46, + "gas_cost": 54430492, + "proving_cost": 5425957588, + "congestion_cost": 20439380598, + "congestion_multiplier": 4729549829 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 485, + "gas_cost": 574161337, + "proving_cost": 57235842456, + "congestion_cost": 215605291571, + "congestion_multiplier": 4729549829 + } + } + }, + { + "l1_block_number": 20973515, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 17477541478 + }, + "parent_header": { + "excess_mana": 1328059849, + "mana_used": 88389595, + "proving_cost_per_mana_numerator": 283776529, + "fee_asset_price_numerator": 6340082778 + }, + "header": { + "excess_mana": 1316449444, + "mana_used": 97332202, + "proving_cost_per_mana_numerator": 259044148, + "fee_asset_price_numerator": 7340082778 + }, + "oracle_input": { + "proving_cost_modifier": -24732381, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10654538171, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 57894356, + "proving_cost": 5430747295, + "congestion_cost": 20119918075, + "congestion_multiplier": 4665737204 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 511, + "gas_cost": 616837625, + "proving_cost": 57862104351, + "congestion_cost": 214368435127, + "congestion_multiplier": 4665737204 + } + } + }, + { + "l1_block_number": 20973518, + "l1_fees": { + "blob_fee": 13375, + "base_fee": 15978208780 + }, + "parent_header": { + "excess_mana": 1316449444, + "mana_used": 97332202, + "proving_cost_per_mana_numerator": 259044148, + "fee_asset_price_numerator": 7340082778 + }, + "header": { + "excess_mana": 1313781646, + "mana_used": 107383104, + "proving_cost_per_mana_numerator": 285050814, + "fee_asset_price_numerator": 6978325524 + }, + "oracle_input": { + "proving_cost_modifier": 26006666, + "fee_asset_price_modifier": -361757254 + }, + "outputs": { + "fee_asset_price_at_execution": 10761618060, + "mana_base_fee_components_in_wei": { + "data_cost": 52, + "gas_cost": 52927816, + "proving_cost": 5429404308, + "congestion_cost": 20017072781, + "congestion_multiplier": 4651196633 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 559, + "gas_cost": 569588940, + "proving_cost": 58429175456, + "congestion_cost": 215416091948, + "congestion_multiplier": 4651196633 + } + } + }, + { + "l1_block_number": 20973521, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 15694997319 + }, + "parent_header": { + "excess_mana": 1313781646, + "mana_used": 107383104, + "proving_cost_per_mana_numerator": 285050814, + "fee_asset_price_numerator": 6978325524 + }, + "header": { + "excess_mana": 1321164750, + "mana_used": 99195845, + "proving_cost_per_mana_numerator": 356671899, + "fee_asset_price_numerator": 6942005273 + }, + "oracle_input": { + "proving_cost_modifier": 71621085, + "fee_asset_price_modifier": -36320251 + }, + "outputs": { + "fee_asset_price_at_execution": 10722757459, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 51989678, + "proving_cost": 5430816498, + "congestion_cost": 20240046593, + "congestion_multiplier": 4691548782 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 386, + "gas_cost": 557472707, + "proving_cost": 58233328112, + "congestion_cost": 217029110575, + "congestion_multiplier": 4691548782 + } + } + }, + { + "l1_block_number": 20973524, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 16114710895 + }, + "parent_header": { + "excess_mana": 1321164750, + "mana_used": 99195845, + "proving_cost_per_mana_numerator": 356671899, + "fee_asset_price_numerator": 6942005273 + }, + "header": { + "excess_mana": 1320360595, + "mana_used": 75773539, + "proving_cost_per_mana_numerator": 236578589, + "fee_asset_price_numerator": 7295623463 + }, + "oracle_input": { + "proving_cost_modifier": -120093310, + "fee_asset_price_modifier": 353618190 + }, + "outputs": { + "fee_asset_price_at_execution": 10718863633, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 53379979, + "proving_cost": 5434707501, + "congestion_cost": 20235329235, + "congestion_multiplier": 4687136761 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 407, + "gas_cost": 572172715, + "proving_cost": 58253888588, + "congestion_cost": 216899734638, + "congestion_multiplier": 4687136761 + } + } + }, + { + "l1_block_number": 20973527, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 15193310536 + }, + "parent_header": { + "excess_mana": 1320360595, + "mana_used": 75773539, + "proving_cost_per_mana_numerator": 236578589, + "fee_asset_price_numerator": 7295623463 + }, + "header": { + "excess_mana": 1296134134, + "mana_used": 118152636, + "proving_cost_per_mana_numerator": 155286419, + "fee_asset_price_numerator": 7974068845 + }, + "oracle_input": { + "proving_cost_modifier": -81292170, + "fee_asset_price_modifier": 678445382 + }, + "outputs": { + "fee_asset_price_at_execution": 10756834581, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 50327841, + "proving_cost": 5428184699, + "congestion_cost": 19482386766, + "congestion_multiplier": 4556145304 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 376, + "gas_cost": 541368260, + "proving_cost": 58390084882, + "congestion_cost": 209568811684, + "congestion_multiplier": 4556145304 + } + } + }, + { + "l1_block_number": 20973530, + "l1_fees": { + "blob_fee": 8028, + "base_fee": 15696924869 + }, + "parent_header": { + "excess_mana": 1296134134, + "mana_used": 118152636, + "proving_cost_per_mana_numerator": 155286419, + "fee_asset_price_numerator": 7974068845 + }, + "header": { + "excess_mana": 1314286770, + "mana_used": 112950187, + "proving_cost_per_mana_numerator": 121267759, + "fee_asset_price_numerator": 8775829688 + }, + "oracle_input": { + "proving_cost_modifier": -34018660, + "fee_asset_price_modifier": 801760843 + }, + "outputs": { + "fee_asset_price_at_execution": 10830061952, + "mana_base_fee_components_in_wei": { + "data_cost": 31, + "gas_cost": 51996063, + "proving_cost": 5423773803, + "congestion_cost": 20008169045, + "congestion_multiplier": 4653946280 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 335, + "gas_cost": 563120583, + "proving_cost": 58739806300, + "congestion_cost": 216689710303, + "congestion_multiplier": 4653946280 + } + } + }, + { + "l1_block_number": 20973533, + "l1_fees": { + "blob_fee": 6861, + "base_fee": 17589348647 + }, + "parent_header": { + "excess_mana": 1314286770, + "mana_used": 112950187, + "proving_cost_per_mana_numerator": 121267759, + "fee_asset_price_numerator": 8775829688 + }, + "header": { + "excess_mana": 1327236957, + "mana_used": 86247445, + "proving_cost_per_mana_numerator": 156972445, + "fee_asset_price_numerator": 9300867729 + }, + "oracle_input": { + "proving_cost_modifier": 35704686, + "fee_asset_price_modifier": 525038041 + }, + "outputs": { + "fee_asset_price_at_execution": 10917242169, + "mana_base_fee_components_in_wei": { + "data_cost": 26, + "gas_cost": 58264717, + "proving_cost": 5421929021, + "congestion_cost": 20413713484, + "congestion_multiplier": 4724998488 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 283, + "gas_cost": 636090025, + "proving_cost": 59192512145, + "congestion_cost": 222861453673, + "congestion_multiplier": 4724998488 + } + } + }, + { + "l1_block_number": 20973536, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 21124868019 + }, + "parent_header": { + "excess_mana": 1327236957, + "mana_used": 86247445, + "proving_cost_per_mana_numerator": 156972445, + "fee_asset_price_numerator": 9300867729 + }, + "header": { + "excess_mana": 1313484402, + "mana_used": 93046450, + "proving_cost_per_mana_numerator": 67913921, + "fee_asset_price_numerator": 9836646214 + }, + "oracle_input": { + "proving_cost_modifier": -89058524, + "fee_asset_price_modifier": 535778485 + }, + "outputs": { + "fee_asset_price_at_execution": 10974712583, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 69976125, + "proving_cost": 5423865250, + "congestion_cost": 20050210096, + "congestion_multiplier": 4649579342 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 318, + "gas_cost": 767967859, + "proving_cost": 59525362207, + "congestion_cost": 220045293032, + "congestion_multiplier": 4649579342 + } + } + }, + { + "l1_block_number": 20973539, + "l1_fees": { + "blob_fee": 6597, + "base_fee": 20799423931 + }, + "parent_header": { + "excess_mana": 1313484402, + "mana_used": 93046450, + "proving_cost_per_mana_numerator": 67913921, + "fee_asset_price_numerator": 9836646214 + }, + "header": { + "excess_mana": 1306530852, + "mana_used": 111312010, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10091294188 + }, + "oracle_input": { + "proving_cost_modifier": -226866819, + "fee_asset_price_modifier": 254647974 + }, + "outputs": { + "fee_asset_price_at_execution": 11033670532, + "mana_base_fee_components_in_wei": { + "data_cost": 25, + "gas_cost": 68898091, + "proving_cost": 5419036986, + "congestion_cost": 19821902621, + "congestion_multiplier": 4611905435 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 275, + "gas_cost": 760198836, + "proving_cost": 59791868704, + "congestion_cost": 218708342837, + "congestion_multiplier": 4611905435 + } + } + }, + { + "l1_block_number": 20973542, + "l1_fees": { + "blob_fee": 5864, + "base_fee": 19793695587 + }, + "parent_header": { + "excess_mana": 1306530852, + "mana_used": 111312010, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10091294188 + }, + "header": { + "excess_mana": 1317842862, + "mana_used": 104587798, + "proving_cost_per_mana_numerator": 19892327, + "fee_asset_price_numerator": 10346274506 + }, + "oracle_input": { + "proving_cost_modifier": 19892327, + "fee_asset_price_modifier": 254980318 + }, + "outputs": { + "fee_asset_price_at_execution": 11061803355, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 65566616, + "proving_cost": 5415357955, + "congestion_cost": 20133354110, + "congestion_multiplier": 4673349955 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 254, + "gas_cost": 725285012, + "proving_cost": 59903624795, + "congestion_cost": 222711204041, + "congestion_multiplier": 4673349955 + } + } + }, + { + "l1_block_number": 20973545, + "l1_fees": { + "blob_fee": 6597, + "base_fee": 20094986128 + }, + "parent_header": { + "excess_mana": 1317842862, + "mana_used": 104587798, + "proving_cost_per_mana_numerator": 19892327, + "fee_asset_price_numerator": 10346274506 + }, + "header": { + "excess_mana": 1322430660, + "mana_used": 104970014, + "proving_cost_per_mana_numerator": 32749244, + "fee_asset_price_numerator": 9864976938 + }, + "oracle_input": { + "proving_cost_modifier": 12856917, + "fee_asset_price_modifier": -481297568 + }, + "outputs": { + "fee_asset_price_at_execution": 11090044767, + "mana_base_fee_components_in_wei": { + "data_cost": 25, + "gas_cost": 66564641, + "proving_cost": 5416435302, + "congestion_cost": 20278889922, + "congestion_multiplier": 4698502652 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 277, + "gas_cost": 738204848, + "proving_cost": 60068509976, + "congestion_cost": 224893797060, + "congestion_multiplier": 4698502652 + } + } + }, + { + "l1_block_number": 20973548, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 18609737244 + }, + "parent_header": { + "excess_mana": 1322430660, + "mana_used": 104970014, + "proving_cost_per_mana_numerator": 32749244, + "fee_asset_price_numerator": 9864976938 + }, + "header": { + "excess_mana": 1327400674, + "mana_used": 52607414, + "proving_cost_per_mana_numerator": 81068013, + "fee_asset_price_numerator": 9361738499 + }, + "oracle_input": { + "proving_cost_modifier": 48318769, + "fee_asset_price_modifier": -503238439 + }, + "outputs": { + "fee_asset_price_at_execution": 11036796894, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 61644754, + "proving_cost": 5417131734, + "congestion_cost": 20413393404, + "congestion_multiplier": 4725903642 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 397, + "gas_cost": 680360629, + "proving_cost": 59787782696, + "congestion_cost": 225298476917, + "congestion_multiplier": 4725903642 + } + } + }, + { + "l1_block_number": 20973551, + "l1_fees": { + "blob_fee": 11889, + "base_fee": 18614276755 + }, + "parent_header": { + "excess_mana": 1327400674, + "mana_used": 52607414, + "proving_cost_per_mana_numerator": 81068013, + "fee_asset_price_numerator": 9361738499 + }, + "header": { + "excess_mana": 1280008088, + "mana_used": 127805778, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8901487473 + }, + "oracle_input": { + "proving_cost_modifier": -141528716, + "fee_asset_price_modifier": -460251026 + }, + "outputs": { + "fee_asset_price_at_execution": 10981395008, + "mana_base_fee_components_in_wei": { + "data_cost": 46, + "gas_cost": 61659791, + "proving_cost": 5419749858, + "congestion_cost": 19025908518, + "congestion_multiplier": 4470988227 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 505, + "gas_cost": 677110521, + "proving_cost": 59516414035, + "congestion_cost": 208931016822, + "congestion_multiplier": 4470988227 + } + } + }, + { + "l1_block_number": 20973554, + "l1_fees": { + "blob_fee": 10991, + "base_fee": 18020600851 + }, + "parent_header": { + "excess_mana": 1280008088, + "mana_used": 127805778, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8901487473 + }, + "header": { + "excess_mana": 1307813866, + "mana_used": 94149668, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8724451260 + }, + "oracle_input": { + "proving_cost_modifier": -63645948, + "fee_asset_price_modifier": -177036213 + }, + "outputs": { + "fee_asset_price_at_execution": 10930969157, + "mana_base_fee_components_in_wei": { + "data_cost": 43, + "gas_cost": 59693240, + "proving_cost": 5415357955, + "congestion_cost": 19813299852, + "congestion_multiplier": 4618833686 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 470, + "gas_cost": 652504965, + "proving_cost": 59195110780, + "congestion_cost": 216578569580, + "congestion_multiplier": 4618833686 + } + } + }, + { + "l1_block_number": 20973557, + "l1_fees": { + "blob_fee": 12365, + "base_fee": 18277826651 + }, + "parent_header": { + "excess_mana": 1307813866, + "mana_used": 94149668, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8724451260 + }, + "header": { + "excess_mana": 1301963534, + "mana_used": 99444246, + "proving_cost_per_mana_numerator": 60729549, + "fee_asset_price_numerator": 8166861291 + }, + "oracle_input": { + "proving_cost_modifier": 60729549, + "fee_asset_price_modifier": -557589969 + }, + "outputs": { + "fee_asset_price_at_execution": 10911634503, + "mana_base_fee_components_in_wei": { + "data_cost": 48, + "gas_cost": 60545300, + "proving_cost": 5415357955, + "congestion_cost": 19643851606, + "congestion_multiplier": 4587326240 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 523, + "gas_cost": 660648184, + "proving_cost": 59090406707, + "congestion_cost": 214346528955, + "congestion_multiplier": 4587326240 + } + } + }, + { + "l1_block_number": 20973560, + "l1_fees": { + "blob_fee": 17605, + "base_fee": 17939510902 + }, + "parent_header": { + "excess_mana": 1301963534, + "mana_used": 99444246, + "proving_cost_per_mana_numerator": 60729549, + "fee_asset_price_numerator": 8166861291 + }, + "header": { + "excess_mana": 1301407780, + "mana_used": 116843419, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8056731716 + }, + "oracle_input": { + "proving_cost_modifier": -133462995, + "fee_asset_price_modifier": -110129575 + }, + "outputs": { + "fee_asset_price_at_execution": 10850961633, + "mana_base_fee_components_in_wei": { + "data_cost": 69, + "gas_cost": 59424629, + "proving_cost": 5418647676, + "congestion_cost": 19635297943, + "congestion_multiplier": 4584344383 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 748, + "gas_cost": 644814369, + "proving_cost": 58797538035, + "congestion_cost": 213061864632, + "congestion_multiplier": 4584344383 + } + } + }, + { + "l1_block_number": 20973563, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 17915455837 + }, + "parent_header": { + "excess_mana": 1301407780, + "mana_used": 116843419, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 8056731716 + }, + "header": { + "excess_mana": 1318251199, + "mana_used": 106156025, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7883590148 + }, + "oracle_input": { + "proving_cost_modifier": -98037428, + "fee_asset_price_modifier": -173141568 + }, + "outputs": { + "fee_asset_price_at_execution": 10839018093, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 59344947, + "proving_cost": 5415357955, + "congestion_cost": 20122726305, + "congestion_multiplier": 4675583202 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 834, + "gas_cost": 643240954, + "proving_cost": 58697162854, + "congestion_cost": 218110594500, + "congestion_multiplier": 4675583202 + } + } + }, + { + "l1_block_number": 20973566, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 17059822050 + }, + "parent_header": { + "excess_mana": 1318251199, + "mana_used": 106156025, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7883590148 + }, + "header": { + "excess_mana": 1324407224, + "mana_used": 91163155, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7801958587 + }, + "oracle_input": { + "proving_cost_modifier": -13958851, + "fee_asset_price_modifier": -81631561 + }, + "outputs": { + "fee_asset_price_at_execution": 10820267485, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 56510660, + "proving_cost": 5415357955, + "congestion_cost": 20297245101, + "congestion_multiplier": 4709380889 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 681, + "gas_cost": 611460456, + "proving_cost": 58595621600, + "congestion_cost": 219621621201, + "congestion_multiplier": 4709380889 + } + } + }, + { + "l1_block_number": 20973569, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 16555278446 + }, + "parent_header": { + "excess_mana": 1324407224, + "mana_used": 91163155, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7801958587 + }, + "header": { + "excess_mana": 1315570379, + "mana_used": 110308203, + "proving_cost_per_mana_numerator": 77408002, + "fee_asset_price_numerator": 7466434184 + }, + "oracle_input": { + "proving_cost_modifier": 77408002, + "fee_asset_price_modifier": -335524403 + }, + "outputs": { + "fee_asset_price_at_execution": 10811438336, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 54839359, + "proving_cost": 5415357955, + "congestion_cost": 20026069534, + "congestion_multiplier": 4660940932 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 832, + "gas_cost": 592892348, + "proving_cost": 58547808597, + "congestion_cost": 216510615879, + "congestion_multiplier": 4660940932 + } + } + }, + { + "l1_block_number": 20973572, + "l1_fees": { + "blob_fee": 20599, + "base_fee": 16295282001 + }, + "parent_header": { + "excess_mana": 1315570379, + "mana_used": 110308203, + "proving_cost_per_mana_numerator": 77408002, + "fee_asset_price_numerator": 7466434184 + }, + "header": { + "excess_mana": 1325878582, + "mana_used": 110082615, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7232729626 + }, + "oracle_input": { + "proving_cost_modifier": -205859688, + "fee_asset_price_modifier": -233704558 + }, + "outputs": { + "fee_asset_price_at_execution": 10775224109, + "mana_base_fee_components_in_wei": { + "data_cost": 80, + "gas_cost": 53978121, + "proving_cost": 5419551498, + "congestion_cost": 20347819386, + "congestion_multiplier": 4717495018 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 862, + "gas_cost": 581626350, + "proving_cost": 58396881961, + "congestion_cost": 219252314013, + "congestion_multiplier": 4717495018 + } + } + }, + { + "l1_block_number": 20973575, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 15308679642 + }, + "parent_header": { + "excess_mana": 1325878582, + "mana_used": 110082615, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7232729626 + }, + "header": { + "excess_mana": 1335961197, + "mana_used": 105815738, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6254996440 + }, + "oracle_input": { + "proving_cost_modifier": -84442481, + "fee_asset_price_modifier": -977733186 + }, + "outputs": { + "fee_asset_price_at_execution": 10750071323, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 50710001, + "proving_cost": 5415357955, + "congestion_cost": 20626072440, + "congestion_multiplier": 4773475241 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 978, + "gas_cost": 545136127, + "proving_cost": 58215484255, + "congestion_cost": 221731749843, + "congestion_multiplier": 4773475241 + } + } + }, + { + "l1_block_number": 20973578, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 15069272311 + }, + "parent_header": { + "excess_mana": 1335961197, + "mana_used": 105815738, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6254996440 + }, + "header": { + "excess_mana": 1341776935, + "mana_used": 95248719, + "proving_cost_per_mana_numerator": 40498148, + "fee_asset_price_numerator": 6365721613 + }, + "oracle_input": { + "proving_cost_modifier": 40498148, + "fee_asset_price_modifier": 110725173 + }, + "outputs": { + "fee_asset_price_at_execution": 10645476470, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 49916964, + "proving_cost": 5415357955, + "congestion_cost": 20801201205, + "congestion_multiplier": 4806066697 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 968, + "gas_cost": 531389865, + "proving_cost": 57649065686, + "congestion_cost": 221438697975, + "congestion_multiplier": 4806066697 + } + } + }, + { + "l1_block_number": 20973581, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 15303102977 + }, + "parent_header": { + "excess_mana": 1341776935, + "mana_used": 95248719, + "proving_cost_per_mana_numerator": 40498148, + "fee_asset_price_numerator": 6365721613 + }, + "header": { + "excess_mana": 1337025654, + "mana_used": 90408891, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6906882271 + }, + "oracle_input": { + "proving_cost_modifier": -69662332, + "fee_asset_price_modifier": 541160658 + }, + "outputs": { + "fee_asset_price_at_execution": 10657270221, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 50691528, + "proving_cost": 5417551518, + "congestion_cost": 20666808808, + "congestion_multiplier": 4779423901 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 969, + "gas_cost": 540233311, + "proving_cost": 57736310463, + "congestion_cost": 220251766072, + "congestion_multiplier": 4779423901 + } + } + }, + { + "l1_block_number": 20973584, + "l1_fees": { + "blob_fee": 20599, + "base_fee": 15137821864 + }, + "parent_header": { + "excess_mana": 1337025654, + "mana_used": 90408891, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6906882271 + }, + "header": { + "excess_mana": 1327434545, + "mana_used": 95066489, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6335884269 + }, + "oracle_input": { + "proving_cost_modifier": -141635049, + "fee_asset_price_modifier": -570998002 + }, + "outputs": { + "fee_asset_price_at_execution": 10715099508, + "mana_base_fee_components_in_wei": { + "data_cost": 80, + "gas_cost": 50144034, + "proving_cost": 5415357955, + "congestion_cost": 20364957681, + "congestion_multiplier": 4726090929 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 857, + "gas_cost": 537298314, + "proving_cost": 58026099359, + "congestion_cost": 218212548028, + "congestion_multiplier": 4726090929 + } + } + }, + { + "l1_block_number": 20973587, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 15472115815 + }, + "parent_header": { + "excess_mana": 1327434545, + "mana_used": 95066489, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6335884269 + }, + "header": { + "excess_mana": 1322501034, + "mana_used": 106900881, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5626654198 + }, + "oracle_input": { + "proving_cost_modifier": -38760060, + "fee_asset_price_modifier": -709230071 + }, + "outputs": { + "fee_asset_price_at_execution": 10654090849, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 51251383, + "proving_cost": 5415357955, + "congestion_cost": 20220384392, + "congestion_multiplier": 4698889532 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 969, + "gas_cost": 546036890, + "proving_cost": 57695715632, + "congestion_cost": 215429812314, + "congestion_multiplier": 4698889532 + } + } + }, + { + "l1_block_number": 20973590, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 16177942905 + }, + "parent_header": { + "excess_mana": 1322501034, + "mana_used": 106900881, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5626654198 + }, + "header": { + "excess_mana": 1329401915, + "mana_used": 100313077, + "proving_cost_per_mana_numerator": 57773876, + "fee_asset_price_numerator": 5720592720 + }, + "oracle_input": { + "proving_cost_modifier": 57773876, + "fee_asset_price_modifier": 93938522 + }, + "outputs": { + "fee_asset_price_at_execution": 10578796154, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 53589435, + "proving_cost": 5415357955, + "congestion_cost": 20437358702, + "congestion_multiplier": 4736982084 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 814, + "gas_cost": 566911708, + "proving_cost": 57287967906, + "congestion_cost": 216202651634, + "congestion_multiplier": 4736982084 + } + } + }, + { + "l1_block_number": 20973593, + "l1_fees": { + "blob_fee": 17605, + "base_fee": 15631978451 + }, + "parent_header": { + "excess_mana": 1329401915, + "mana_used": 100313077, + "proving_cost_per_mana_numerator": 57773876, + "fee_asset_price_numerator": 5720592720 + }, + "header": { + "excess_mana": 1329714992, + "mana_used": 84502427, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5666336427 + }, + "oracle_input": { + "proving_cost_modifier": -101826303, + "fee_asset_price_modifier": -54256293 + }, + "outputs": { + "fee_asset_price_at_execution": 10588738388, + "mana_base_fee_components_in_wei": { + "data_cost": 69, + "gas_cost": 51780928, + "proving_cost": 5418487521, + "congestion_cost": 20451788955, + "congestion_multiplier": 4738717558 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 730, + "gas_cost": 548294700, + "proving_cost": 57374946818, + "congestion_cost": 216558642811, + "congestion_multiplier": 4738717558 + } + } + }, + { + "l1_block_number": 20973596, + "l1_fees": { + "blob_fee": 14467, + "base_fee": 14200105654 + }, + "parent_header": { + "excess_mana": 1329714992, + "mana_used": 84502427, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5666336427 + }, + "header": { + "excess_mana": 1314217419, + "mana_used": 111946924, + "proving_cost_per_mana_numerator": 92058319, + "fee_asset_price_numerator": 5034697877 + }, + "oracle_input": { + "proving_cost_modifier": 92058319, + "fee_asset_price_modifier": -631638550 + }, + "outputs": { + "fee_asset_price_at_execution": 10582994890, + "mana_base_fee_components_in_wei": { + "data_cost": 56, + "gas_cost": 47037849, + "proving_cost": 5415357955, + "congestion_cost": 19957238382, + "congestion_multiplier": 4653568671 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 592, + "gas_cost": 497801315, + "proving_cost": 57310705565, + "congestion_cost": 211207351815, + "congestion_multiplier": 4653568671 + } + } + }, + { + "l1_block_number": 20973599, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 13624273988 + }, + "parent_header": { + "excess_mana": 1314217419, + "mana_used": 111946924, + "proving_cost_per_mana_numerator": 92058319, + "fee_asset_price_numerator": 5034697877 + }, + "header": { + "excess_mana": 1326164343, + "mana_used": 90155196, + "proving_cost_per_mana_numerator": 95464087, + "fee_asset_price_numerator": 5794889457 + }, + "oracle_input": { + "proving_cost_modifier": 3405768, + "fee_asset_price_modifier": 760191580 + }, + "outputs": { + "fee_asset_price_at_execution": 10516359284, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 45130407, + "proving_cost": 5420345537, + "congestion_cost": 20326501733, + "congestion_multiplier": 4719072530 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 809, + "gas_cost": 474607574, + "proving_cost": 57002301110, + "congestion_cost": 213760795211, + "congestion_multiplier": 4719072530 + } + } + }, + { + "l1_block_number": 20973602, + "l1_fees": { + "blob_fee": 21424, + "base_fee": 14061825642 + }, + "parent_header": { + "excess_mana": 1326164343, + "mana_used": 90155196, + "proving_cost_per_mana_numerator": 95464087, + "fee_asset_price_numerator": 5794889457 + }, + "header": { + "excess_mana": 1316319539, + "mana_used": 101203237, + "proving_cost_per_mana_numerator": 65367598, + "fee_asset_price_numerator": 6106040447 + }, + "oracle_input": { + "proving_cost_modifier": -30096489, + "fee_asset_price_modifier": 311150990 + }, + "outputs": { + "fee_asset_price_at_execution": 10596608399, + "mana_base_fee_components_in_wei": { + "data_cost": 84, + "gas_cost": 46579797, + "proving_cost": 5420530145, + "congestion_cost": 20037111969, + "congestion_multiplier": 4665028118 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 890, + "gas_cost": 493587868, + "proving_cost": 57439235261, + "congestion_cost": 212325428982, + "congestion_multiplier": 4665028118 + } + } + }, + { + "l1_block_number": 20973605, + "l1_fees": { + "blob_fee": 16928, + "base_fee": 14532060269 + }, + "parent_header": { + "excess_mana": 1316319539, + "mana_used": 101203237, + "proving_cost_per_mana_numerator": 65367598, + "fee_asset_price_numerator": 6106040447 + }, + "header": { + "excess_mana": 1317522776, + "mana_used": 91749672, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6443912293 + }, + "oracle_input": { + "proving_cost_modifier": -82937069, + "fee_asset_price_modifier": 337871846 + }, + "outputs": { + "fee_asset_price_at_execution": 10629631199, + "mana_base_fee_components_in_wei": { + "data_cost": 66, + "gas_cost": 48137449, + "proving_cost": 5418899001, + "congestion_cost": 20072771878, + "congestion_multiplier": 4671600111 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 701, + "gas_cost": 511683329, + "proving_cost": 57600897885, + "congestion_cost": 213366162204, + "congestion_multiplier": 4671600111 + } + } + }, + { + "l1_block_number": 20973608, + "l1_fees": { + "blob_fee": 17605, + "base_fee": 14271585742 + }, + "parent_header": { + "excess_mana": 1317522776, + "mana_used": 91749672, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6443912293 + }, + "header": { + "excess_mana": 1309272448, + "mana_used": 112543125, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6440084946 + }, + "oracle_input": { + "proving_cost_modifier": -150216996, + "fee_asset_price_modifier": -3827347 + }, + "outputs": { + "fee_asset_price_at_execution": 10665606471, + "mana_base_fee_components_in_wei": { + "data_cost": 69, + "gas_cost": 47274627, + "proving_cost": 5415357955, + "congestion_cost": 19811453536, + "congestion_multiplier": 4626722645 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 735, + "gas_cost": 504212567, + "proving_cost": 57758076847, + "congestion_cost": 211301167033, + "congestion_multiplier": 4626722645 + } + } + }, + { + "l1_block_number": 20973611, + "l1_fees": { + "blob_fee": 20599, + "base_fee": 14166674563 + }, + "parent_header": { + "excess_mana": 1309272448, + "mana_used": 112543125, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6440084946 + }, + "header": { + "excess_mana": 1321815573, + "mana_used": 99544210, + "proving_cost_per_mana_numerator": 34927497, + "fee_asset_price_numerator": 5702092437 + }, + "oracle_input": { + "proving_cost_modifier": 34927497, + "fee_asset_price_modifier": -737992509 + }, + "outputs": { + "fee_asset_price_at_execution": 10665198269, + "mana_base_fee_components_in_wei": { + "data_cost": 80, + "gas_cost": 46927109, + "proving_cost": 5415357955, + "congestion_cost": 20183813190, + "congestion_multiplier": 4695122583 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 853, + "gas_cost": 500486921, + "proving_cost": 57755866287, + "congestion_cost": 215264369495, + "congestion_multiplier": 4695122583 + } + } + }, + { + "l1_block_number": 20973614, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 13909087252 + }, + "parent_header": { + "excess_mana": 1321815573, + "mana_used": 99544210, + "proving_cost_per_mana_numerator": 34927497, + "fee_asset_price_numerator": 5702092437 + }, + "header": { + "excess_mana": 1321359783, + "mana_used": 83475620, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4840039687 + }, + "oracle_input": { + "proving_cost_modifier": -179338485, + "fee_asset_price_modifier": -862052750 + }, + "outputs": { + "fee_asset_price_at_execution": 10586779623, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 46073851, + "proving_cost": 5417249734, + "congestion_cost": 20173975333, + "congestion_multiplier": 4692619462 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 963, + "gas_cost": 487773706, + "proving_cost": 57351229096, + "congestion_cost": 213577430970, + "congestion_multiplier": 4692619462 + } + } + }, + { + "l1_block_number": 20973617, + "l1_fees": { + "blob_fee": 29330, + "base_fee": 12839237179 + }, + "parent_header": { + "excess_mana": 1321359783, + "mana_used": 83475620, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4840039687 + }, + "header": { + "excess_mana": 1304835403, + "mana_used": 117833942, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4567935259 + }, + "oracle_input": { + "proving_cost_modifier": -93855121, + "fee_asset_price_modifier": -272104428 + }, + "outputs": { + "fee_asset_price_at_execution": 10495908240, + "mana_base_fee_components_in_wei": { + "data_cost": 115, + "gas_cost": 42529973, + "proving_cost": 5415357955, + "congestion_cost": 19663493358, + "congestion_multiplier": 4602765979 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1207, + "gas_cost": 446390694, + "proving_cost": 56839100182, + "congestion_cost": 206386221963, + "congestion_multiplier": 4602765979 + } + } + }, + { + "l1_block_number": 20973620, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 11710398600 + }, + "parent_header": { + "excess_mana": 1304835403, + "mana_used": 117833942, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4567935259 + }, + "header": { + "excess_mana": 1322669345, + "mana_used": 107648739, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4485569068 + }, + "oracle_input": { + "proving_cost_modifier": -57253967, + "fee_asset_price_modifier": -82366191 + }, + "outputs": { + "fee_asset_price_at_execution": 10467387230, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 38790695, + "proving_cost": 5415357955, + "congestion_cost": 20179341210, + "congestion_multiplier": 4699814946 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1465, + "gas_cost": 406037225, + "proving_cost": 56684648704, + "congestion_cost": 211224978491, + "congestion_multiplier": 4699814946 + } + } + }, + { + "l1_block_number": 20973623, + "l1_fees": { + "blob_fee": 34318, + "base_fee": 11226899085 + }, + "parent_header": { + "excess_mana": 1322669345, + "mana_used": 107648739, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4485569068 + }, + "header": { + "excess_mana": 1330318084, + "mana_used": 107126075, + "proving_cost_per_mana_numerator": 73369673, + "fee_asset_price_numerator": 3485569068 + }, + "oracle_input": { + "proving_cost_modifier": 73369673, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10458769192, + "mana_base_fee_components_in_wei": { + "data_cost": 134, + "gas_cost": 37189103, + "proving_cost": 5415357955, + "congestion_cost": 20403772164, + "congestion_multiplier": 4742062461 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1401, + "gas_cost": 388952244, + "proving_cost": 56637978943, + "congestion_cost": 213398343709, + "congestion_multiplier": 4742062461 + } + } + }, + { + "l1_block_number": 20973626, + "l1_fees": { + "blob_fee": 30505, + "base_fee": 11990879691 + }, + "parent_header": { + "excess_mana": 1330318084, + "mana_used": 107126075, + "proving_cost_per_mana_numerator": 73369673, + "fee_asset_price_numerator": 3485569068 + }, + "header": { + "excess_mana": 1337444159, + "mana_used": 103590464, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2648632075 + }, + "oracle_input": { + "proving_cost_modifier": -178086909, + "fee_asset_price_modifier": -836936993 + }, + "outputs": { + "fee_asset_price_at_execution": 10354702700, + "mana_base_fee_components_in_wei": { + "data_cost": 119, + "gas_cost": 39719788, + "proving_cost": 5419332643, + "congestion_cost": 20644852354, + "congestion_multiplier": 4781764723 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1232, + "gas_cost": 411286596, + "proving_cost": 56115578350, + "congestion_cost": 213771308411, + "congestion_multiplier": 4781764723 + } + } + }, + { + "l1_block_number": 20973629, + "l1_fees": { + "blob_fee": 30505, + "base_fee": 12389925316 + }, + "parent_header": { + "excess_mana": 1337444159, + "mana_used": 103590464, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2648632075 + }, + "header": { + "excess_mana": 1341034623, + "mana_used": 75455999, + "proving_cost_per_mana_numerator": 154461127, + "fee_asset_price_numerator": 2282803058 + }, + "oracle_input": { + "proving_cost_modifier": 154461127, + "fee_asset_price_modifier": -365829017 + }, + "outputs": { + "fee_asset_price_at_execution": 10268402007, + "mana_base_fee_components_in_wei": { + "data_cost": 119, + "gas_cost": 41041627, + "proving_cost": 5415357955, + "congestion_cost": 20744655554, + "congestion_multiplier": 4801894416 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1221, + "gas_cost": 421431925, + "proving_cost": 55607072493, + "congestion_cost": 213014462725, + "congestion_multiplier": 4801894416 + } + } + }, + { + "l1_block_number": 20973632, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 13053650178 + }, + "parent_header": { + "excess_mana": 1341034623, + "mana_used": 75455999, + "proving_cost_per_mana_numerator": 154461127, + "fee_asset_price_numerator": 2282803058 + }, + "header": { + "excess_mana": 1316490622, + "mana_used": 37243071, + "proving_cost_per_mana_numerator": 237298150, + "fee_asset_price_numerator": 2606097745 + }, + "oracle_input": { + "proving_cost_modifier": 82837023, + "fee_asset_price_modifier": 323294687 + }, + "outputs": { + "fee_asset_price_at_execution": 10230905841, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 43240216, + "proving_cost": 5423729041, + "congestion_cost": 20041702048, + "congestion_multiplier": 4665961997 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1432, + "gas_cost": 442386578, + "proving_cost": 55489661125, + "congestion_cost": 205044766546, + "congestion_multiplier": 4665961997 + } + } + }, + { + "l1_block_number": 20973635, + "l1_fees": { + "blob_fee": 37121, + "base_fee": 12793394041 + }, + "parent_header": { + "excess_mana": 1316490622, + "mana_used": 37243071, + "proving_cost_per_mana_numerator": 237298150, + "fee_asset_price_numerator": 2606097745 + }, + "header": { + "excess_mana": 1253733693, + "mana_used": 148558024, + "proving_cost_per_mana_numerator": 262704790, + "fee_asset_price_numerator": 2753929735 + }, + "oracle_input": { + "proving_cost_modifier": 25406640, + "fee_asset_price_modifier": 147831990 + }, + "outputs": { + "fee_asset_price_at_execution": 10264035340, + "mana_base_fee_components_in_wei": { + "data_cost": 145, + "gas_cost": 42378117, + "proving_cost": 5428223758, + "congestion_cost": 18247939638, + "congestion_multiplier": 4335636475 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1488, + "gas_cost": 434970490, + "proving_cost": 55715480485, + "congestion_cost": 187297497326, + "congestion_multiplier": 4335636475 + } + } + }, + { + "l1_block_number": 20973638, + "l1_fees": { + "blob_fee": 40153, + "base_fee": 12536317780 + }, + "parent_header": { + "excess_mana": 1253733693, + "mana_used": 148558024, + "proving_cost_per_mana_numerator": 262704790, + "fee_asset_price_numerator": 2753929735 + }, + "header": { + "excess_mana": 1302291717, + "mana_used": 113034877, + "proving_cost_per_mana_numerator": 189011056, + "fee_asset_price_numerator": 3394892634 + }, + "oracle_input": { + "proving_cost_modifier": -73693734, + "fee_asset_price_modifier": 640962899 + }, + "outputs": { + "fee_asset_price_at_execution": 10279220089, + "mana_base_fee_components_in_wei": { + "data_cost": 157, + "gas_cost": 41526552, + "proving_cost": 5429603062, + "congestion_cost": 19636366169, + "congestion_multiplier": 4589087993 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1613, + "gas_cost": 426860567, + "proving_cost": 55812084870, + "congestion_cost": 201846529599, + "congestion_multiplier": 4589087993 + } + } + }, + { + "l1_block_number": 20973641, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 13073165878 + }, + "parent_header": { + "excess_mana": 1302291717, + "mana_used": 113034877, + "proving_cost_per_mana_numerator": 189011056, + "fee_asset_price_numerator": 3394892634 + }, + "header": { + "excess_mana": 1315326594, + "mana_used": 103158900, + "proving_cost_per_mana_numerator": 234196404, + "fee_asset_price_numerator": 4210671750 + }, + "oracle_input": { + "proving_cost_modifier": 45185348, + "fee_asset_price_modifier": 815779116 + }, + "outputs": { + "fee_asset_price_at_execution": 10345317680, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 43304861, + "proving_cost": 5425603259, + "congestion_cost": 20014080594, + "congestion_multiplier": 4659611689 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1448, + "gas_cost": 448002544, + "proving_cost": 56129589319, + "congestion_cost": 207052021818, + "congestion_multiplier": 4659611689 + } + } + }, + { + "l1_block_number": 20973644, + "l1_fees": { + "blob_fee": 31726, + "base_fee": 13867324942 + }, + "parent_header": { + "excess_mana": 1315326594, + "mana_used": 103158900, + "proving_cost_per_mana_numerator": 234196404, + "fee_asset_price_numerator": 4210671750 + }, + "header": { + "excess_mana": 1318485494, + "mana_used": 104972183, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3935539809 + }, + "oracle_input": { + "proving_cost_modifier": -353785666, + "fee_asset_price_modifier": -275131941 + }, + "outputs": { + "fee_asset_price_at_execution": 10430057797, + "mana_base_fee_components_in_wei": { + "data_cost": 124, + "gas_cost": 45935513, + "proving_cost": 5428055391, + "congestion_cost": 20127126415, + "congestion_multiplier": 4676865072 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1293, + "gas_cost": 479110055, + "proving_cost": 56614931453, + "congestion_cost": 209927091795, + "congestion_multiplier": 4676865072 + } + } + }, + { + "l1_block_number": 20973647, + "l1_fees": { + "blob_fee": 22282, + "base_fee": 13249689068 + }, + "parent_header": { + "excess_mana": 1318485494, + "mana_used": 104972183, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3935539809 + }, + "header": { + "excess_mana": 1323457677, + "mana_used": 96706411, + "proving_cost_per_mana_numerator": 36679632, + "fee_asset_price_numerator": 3198003093 + }, + "oracle_input": { + "proving_cost_modifier": 36679632, + "fee_asset_price_modifier": -737536716 + }, + "outputs": { + "fee_asset_price_at_execution": 10401400817, + "mana_base_fee_components_in_wei": { + "data_cost": 87, + "gas_cost": 43889595, + "proving_cost": 5415357955, + "congestion_cost": 20221882032, + "congestion_multiplier": 4704151813 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 904, + "gas_cost": 456513269, + "proving_cost": 56327308657, + "congestion_cost": 210335900288, + "congestion_multiplier": 4704151813 + } + } + }, + { + "l1_block_number": 20973650, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 12734890786 + }, + "parent_header": { + "excess_mana": 1323457677, + "mana_used": 96706411, + "proving_cost_per_mana_numerator": 36679632, + "fee_asset_price_numerator": 3198003093 + }, + "header": { + "excess_mana": 1320164088, + "mana_used": 95903793, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3461054523 + }, + "oracle_input": { + "proving_cost_modifier": -88632265, + "fee_asset_price_modifier": 263051430 + }, + "outputs": { + "fee_asset_price_at_execution": 10324968870, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 42184325, + "proving_cost": 5417344652, + "congestion_cost": 20124147647, + "congestion_multiplier": 4686059250 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1011, + "gas_cost": 435551842, + "proving_cost": 55933914889, + "congestion_cost": 207781197990, + "congestion_multiplier": 4686059250 + } + } + }, + { + "l1_block_number": 20973653, + "l1_fees": { + "blob_fee": 22282, + "base_fee": 13407760302 + }, + "parent_header": { + "excess_mana": 1320164088, + "mana_used": 95903793, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3461054523 + }, + "header": { + "excess_mana": 1316067881, + "mana_used": 81430584, + "proving_cost_per_mana_numerator": 58298087, + "fee_asset_price_numerator": 3252958372 + }, + "oracle_input": { + "proving_cost_modifier": 58298087, + "fee_asset_price_modifier": -208096151 + }, + "outputs": { + "fee_asset_price_at_execution": 10352164602, + "mana_base_fee_components_in_wei": { + "data_cost": 87, + "gas_cost": 44413206, + "proving_cost": 5415357955, + "congestion_cost": 20002716866, + "congestion_multiplier": 4663654750 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 900, + "gas_cost": 459772819, + "proving_cost": 56060676928, + "congestion_cost": 207071417484, + "congestion_multiplier": 4663654750 + } + } + }, + { + "l1_block_number": 20973656, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 13114282564 + }, + "parent_header": { + "excess_mana": 1316067881, + "mana_used": 81430584, + "proving_cost_per_mana_numerator": 58298087, + "fee_asset_price_numerator": 3252958372 + }, + "header": { + "excess_mana": 1297498465, + "mana_used": 116095544, + "proving_cost_per_mana_numerator": 177160749, + "fee_asset_price_numerator": 2252958372 + }, + "oracle_input": { + "proving_cost_modifier": 118862662, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10330644545, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 43441060, + "proving_cost": 5418515925, + "congestion_cost": 19463268612, + "congestion_multiplier": 4563423937 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1012, + "gas_cost": 448774149, + "proving_cost": 55976761982, + "congestion_cost": 201068109714, + "congestion_multiplier": 4563423937 + } + } + }, + { + "l1_block_number": 20973659, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 12944326949 + }, + "parent_header": { + "excess_mana": 1297498465, + "mana_used": 116095544, + "proving_cost_per_mana_numerator": 177160749, + "fee_asset_price_numerator": 2252958372 + }, + "header": { + "excess_mana": 1313594009, + "mana_used": 109242161, + "proving_cost_per_mana_numerator": 28596982, + "fee_asset_price_numerator": 1397045405 + }, + "oracle_input": { + "proving_cost_modifier": -148563767, + "fee_asset_price_modifier": -855912967 + }, + "outputs": { + "fee_asset_price_at_execution": 10227852915, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 42878083, + "proving_cost": 5424960347, + "congestion_cost": 19958571173, + "congestion_multiplier": 4650175644 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1431, + "gas_cost": 438550726, + "proving_cost": 55485696498, + "congestion_cost": 204133330351, + "congestion_multiplier": 4650175644 + } + } + }, + { + "l1_block_number": 20973662, + "l1_fees": { + "blob_fee": 40153, + "base_fee": 13369037262 + }, + "parent_header": { + "excess_mana": 1313594009, + "mana_used": 109242161, + "proving_cost_per_mana_numerator": 28596982, + "fee_asset_price_numerator": 1397045405 + }, + "header": { + "excess_mana": 1322836170, + "mana_used": 108183872, + "proving_cost_per_mana_numerator": 304511687, + "fee_asset_price_numerator": 1620690980 + }, + "oracle_input": { + "proving_cost_modifier": 275914705, + "fee_asset_price_modifier": 223645575 + }, + "outputs": { + "fee_asset_price_at_execution": 10140684968, + "mana_base_fee_components_in_wei": { + "data_cost": 157, + "gas_cost": 44284935, + "proving_cost": 5416906805, + "congestion_cost": 20210409632, + "congestion_multiplier": 4700732370 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1592, + "gas_cost": 449079574, + "proving_cost": 54931145410, + "congestion_cost": 204947397152, + "congestion_multiplier": 4700732370 + } + } + }, + { + "l1_block_number": 20973665, + "l1_fees": { + "blob_fee": 52854, + "base_fee": 13746614736 + }, + "parent_header": { + "excess_mana": 1322836170, + "mana_used": 108183872, + "proving_cost_per_mana_numerator": 304511687, + "fee_asset_price_numerator": 1620690980 + }, + "header": { + "excess_mana": 1331020042, + "mana_used": 100370566, + "proving_cost_per_mana_numerator": 216866276, + "fee_asset_price_numerator": 1091240296 + }, + "oracle_input": { + "proving_cost_modifier": -87645411, + "fee_asset_price_modifier": -529450684 + }, + "outputs": { + "fee_asset_price_at_execution": 10163389541, + "mana_base_fee_components_in_wei": { + "data_cost": 207, + "gas_cost": 45535661, + "proving_cost": 5431873485, + "congestion_cost": 20518149071, + "congestion_multiplier": 4745958673 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2103, + "gas_cost": 462796660, + "proving_cost": 55206246165, + "congestion_cost": 208533941668, + "congestion_multiplier": 4745958673 + } + } + }, + { + "l1_block_number": 20973668, + "l1_fees": { + "blob_fee": 43433, + "base_fee": 12637057600 + }, + "parent_header": { + "excess_mana": 1331020042, + "mana_used": 100370566, + "proving_cost_per_mana_numerator": 216866276, + "fee_asset_price_numerator": 1091240296 + }, + "header": { + "excess_mana": 1331390608, + "mana_used": 89670939, + "proving_cost_per_mana_numerator": 192384436, + "fee_asset_price_numerator": 91240296 + }, + "oracle_input": { + "proving_cost_modifier": -24481840, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10109721603, + "mana_base_fee_components_in_wei": { + "data_cost": 170, + "gas_cost": 41860253, + "proving_cost": 5427114783, + "congestion_cost": 20497810885, + "congestion_multiplier": 4748016788 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1718, + "gas_cost": 423195504, + "proving_cost": 54866619563, + "congestion_cost": 207227161518, + "congestion_multiplier": 4748016788 + } + } + }, + { + "l1_block_number": 20973671, + "l1_fees": { + "blob_fee": 37121, + "base_fee": 14261690469 + }, + "parent_header": { + "excess_mana": 1331390608, + "mana_used": 89670939, + "proving_cost_per_mana_numerator": 192384436, + "fee_asset_price_numerator": 91240296 + }, + "header": { + "excess_mana": 1321061547, + "mana_used": 91748908, + "proving_cost_per_mana_numerator": 252885275, + "fee_asset_price_numerator": 125382631 + }, + "oracle_input": { + "proving_cost_modifier": 60500839, + "fee_asset_price_modifier": 34142335 + }, + "outputs": { + "fee_asset_price_at_execution": 10009128193, + "mana_base_fee_components_in_wei": { + "data_cost": 145, + "gas_cost": 47241849, + "proving_cost": 5425786288, + "congestion_cost": 20200850642, + "congestion_multiplier": 4690982323 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1451, + "gas_cost": 472849722, + "proving_cost": 54307390504, + "congestion_cost": 202192903683, + "congestion_multiplier": 4690982323 + } + } + }, + { + "l1_block_number": 20973674, + "l1_fees": { + "blob_fee": 40153, + "base_fee": 14838773563 + }, + "parent_header": { + "excess_mana": 1321061547, + "mana_used": 91748908, + "proving_cost_per_mana_numerator": 252885275, + "fee_asset_price_numerator": 125382631 + }, + "header": { + "excess_mana": 1312810455, + "mana_used": 108557927, + "proving_cost_per_mana_numerator": 223094872, + "fee_asset_price_numerator": 512679736 + }, + "oracle_input": { + "proving_cost_modifier": -29790403, + "fee_asset_price_modifier": 387297105 + }, + "outputs": { + "fee_asset_price_at_execution": 10012546126, + "mana_base_fee_components_in_wei": { + "data_cost": 157, + "gas_cost": 49153437, + "proving_cost": 5429069928, + "congestion_cost": 19973134627, + "congestion_multiplier": 4645914510 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1571, + "gas_cost": 492151055, + "proving_cost": 54358813075, + "congestion_cost": 199981931733, + "congestion_multiplier": 4645914510 + } + } + }, + { + "l1_block_number": 20973677, + "l1_fees": { + "blob_fee": 37121, + "base_fee": 14896911474 + }, + "parent_header": { + "excess_mana": 1312810455, + "mana_used": 108557927, + "proving_cost_per_mana_numerator": 223094872, + "fee_asset_price_numerator": 512679736 + }, + "header": { + "excess_mana": 1321368382, + "mana_used": 110851131, + "proving_cost_per_mana_numerator": 85700300, + "fee_asset_price_numerator": 443662552 + }, + "oracle_input": { + "proving_cost_modifier": -137394572, + "fee_asset_price_modifier": -69017184 + }, + "outputs": { + "fee_asset_price_at_execution": 10051399618, + "mana_base_fee_components_in_wei": { + "data_cost": 145, + "gas_cost": 49346019, + "proving_cost": 5427452827, + "congestion_cost": 20223993114, + "congestion_multiplier": 4692666674 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1457, + "gas_cost": 495996556, + "proving_cost": 54553497272, + "congestion_cost": 203279436660, + "congestion_multiplier": 4692666674 + } + } + }, + { + "l1_block_number": 20973680, + "l1_fees": { + "blob_fee": 27115, + "base_fee": 17507207114 + }, + "parent_header": { + "excess_mana": 1321368382, + "mana_used": 110851131, + "proving_cost_per_mana_numerator": 85700300, + "fee_asset_price_numerator": 443662552 + }, + "header": { + "excess_mana": 1332219513, + "mana_used": 100945171, + "proving_cost_per_mana_numerator": 158359051, + "fee_asset_price_numerator": 1140511040 + }, + "oracle_input": { + "proving_cost_modifier": 72658751, + "fee_asset_price_modifier": 696848488 + }, + "outputs": { + "fee_asset_price_at_execution": 10044464819, + "mana_base_fee_components_in_wei": { + "data_cost": 106, + "gas_cost": 57992623, + "proving_cost": 5420000922, + "congestion_cost": 20556849011, + "congestion_multiplier": 4752623738 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1064, + "gas_cost": 582504861, + "proving_cost": 54441008579, + "congestion_cost": 206482546680, + "congestion_multiplier": 4752623738 + } + } + }, + { + "l1_block_number": 20973683, + "l1_fees": { + "blob_fee": 27115, + "base_fee": 17359812143 + }, + "parent_header": { + "excess_mana": 1332219513, + "mana_used": 100945171, + "proving_cost_per_mana_numerator": 158359051, + "fee_asset_price_numerator": 1140511040 + }, + "header": { + "excess_mana": 1333164684, + "mana_used": 95398013, + "proving_cost_per_mana_numerator": 233651354, + "fee_asset_price_numerator": 1146490236 + }, + "oracle_input": { + "proving_cost_modifier": 75292303, + "fee_asset_price_modifier": 5979196 + }, + "outputs": { + "fee_asset_price_at_execution": 10114703966, + "mana_base_fee_components_in_wei": { + "data_cost": 106, + "gas_cost": 57504377, + "proving_cost": 5423940458, + "congestion_cost": 20598625108, + "congestion_multiplier": 4757882334 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1072, + "gas_cost": 581639750, + "proving_cost": 54861552061, + "congestion_cost": 208348995074, + "congestion_multiplier": 4757882334 + } + } + }, + { + "l1_block_number": 20973686, + "l1_fees": { + "blob_fee": 29330, + "base_fee": 16774258941 + }, + "parent_header": { + "excess_mana": 1333164684, + "mana_used": 95398013, + "proving_cost_per_mana_numerator": 233651354, + "fee_asset_price_numerator": 1146490236 + }, + "header": { + "excess_mana": 1328562697, + "mana_used": 104797878, + "proving_cost_per_mana_numerator": 350116580, + "fee_asset_price_numerator": 1091371198 + }, + "oracle_input": { + "proving_cost_modifier": 116465226, + "fee_asset_price_modifier": -55119038 + }, + "outputs": { + "fee_asset_price_at_execution": 10115308762, + "mana_base_fee_components_in_wei": { + "data_cost": 115, + "gas_cost": 55564732, + "proving_cost": 5428025805, + "congestion_cost": 20466587412, + "congestion_multiplier": 4732333194 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1163, + "gas_cost": 562054420, + "proving_cost": 54906156985, + "congestion_cost": 207025850976, + "congestion_multiplier": 4732333194 + } + } + }, + { + "l1_block_number": 20973689, + "l1_fees": { + "blob_fee": 40153, + "base_fee": 16436884687 + }, + "parent_header": { + "excess_mana": 1328562697, + "mana_used": 104797878, + "proving_cost_per_mana_numerator": 350116580, + "fee_asset_price_numerator": 1091371198 + }, + "header": { + "excess_mana": 1333360575, + "mana_used": 94135126, + "proving_cost_per_mana_numerator": 487258535, + "fee_asset_price_numerator": 1295374975 + }, + "oracle_input": { + "proving_cost_modifier": 137141955, + "fee_asset_price_modifier": 204003777 + }, + "outputs": { + "fee_asset_price_at_execution": 10109734837, + "mana_base_fee_components_in_wei": { + "data_cost": 157, + "gas_cost": 54447180, + "proving_cost": 5434351251, + "congestion_cost": 20632245310, + "congestion_multiplier": 4758972930 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1587, + "gas_cost": 550446552, + "proving_cost": 54939850158, + "congestion_cost": 208586529176, + "congestion_multiplier": 4758972930 + } + } + }, + { + "l1_block_number": 20973692, + "l1_fees": { + "blob_fee": 50819, + "base_fee": 15897028148 + }, + "parent_header": { + "excess_mana": 1333360575, + "mana_used": 94135126, + "proving_cost_per_mana_numerator": 487258535, + "fee_asset_price_numerator": 1295374975 + }, + "header": { + "excess_mana": 1327495701, + "mana_used": 88175023, + "proving_cost_per_mana_numerator": 692563901, + "fee_asset_price_numerator": 614727199 + }, + "oracle_input": { + "proving_cost_modifier": 205305366, + "fee_asset_price_modifier": -680647776 + }, + "outputs": { + "fee_asset_price_at_execution": 10130380130, + "mana_base_fee_components_in_wei": { + "data_cost": 199, + "gas_cost": 52658905, + "proving_cost": 5441809139, + "congestion_cost": 20474746377, + "congestion_multiplier": 4726429105 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2015, + "gas_cost": 533454724, + "proving_cost": 55127595172, + "congestion_cost": 207416963864, + "congestion_multiplier": 4726429105 + } + } + }, + { + "l1_block_number": 20973695, + "l1_fees": { + "blob_fee": 41761, + "base_fee": 14721886802 + }, + "parent_header": { + "excess_mana": 1327495701, + "mana_used": 88175023, + "proving_cost_per_mana_numerator": 692563901, + "fee_asset_price_numerator": 614727199 + }, + "header": { + "excess_mana": 1315670724, + "mana_used": 95588997, + "proving_cost_per_mana_numerator": 693229477, + "fee_asset_price_numerator": 1107651260 + }, + "oracle_input": { + "proving_cost_modifier": 665576, + "fee_asset_price_modifier": 492924061 + }, + "outputs": { + "fee_asset_price_at_execution": 10061662052, + "mana_base_fee_components_in_wei": { + "data_cost": 164, + "gas_cost": 48766250, + "proving_cost": 5452992942, + "congestion_cost": 20144626829, + "congestion_multiplier": 4661488176 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1650, + "gas_cost": 490669527, + "proving_cost": 54866172154, + "congestion_cost": 202688427317, + "congestion_multiplier": 4661488176 + } + } + }, + { + "l1_block_number": 20973698, + "l1_fees": { + "blob_fee": 32996, + "base_fee": 13847852742 + }, + "parent_header": { + "excess_mana": 1315670724, + "mana_used": 95588997, + "proving_cost_per_mana_numerator": 693229477, + "fee_asset_price_numerator": 1107651260 + }, + "header": { + "excess_mana": 1311259721, + "mana_used": 98042679, + "proving_cost_per_mana_numerator": 627079751, + "fee_asset_price_numerator": 1021247990 + }, + "oracle_input": { + "proving_cost_modifier": -66149726, + "fee_asset_price_modifier": -86403270 + }, + "outputs": { + "fee_asset_price_at_execution": 10111380842, + "mana_base_fee_components_in_wei": { + "data_cost": 129, + "gas_cost": 45871012, + "proving_cost": 5453029235, + "congestion_cost": 20002210509, + "congestion_multiplier": 4637492797 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1304, + "gas_cost": 463819271, + "proving_cost": 55137655337, + "congestion_cost": 202249968138, + "congestion_multiplier": 4637492797 + } + } + }, + { + "l1_block_number": 20973701, + "l1_fees": { + "blob_fee": 37121, + "base_fee": 12795525944 + }, + "parent_header": { + "excess_mana": 1311259721, + "mana_used": 98042679, + "proving_cost_per_mana_numerator": 627079751, + "fee_asset_price_numerator": 1021247990 + }, + "header": { + "excess_mana": 1309302400, + "mana_used": 116369229, + "proving_cost_per_mana_numerator": 355053462, + "fee_asset_price_numerator": 400314957 + }, + "oracle_input": { + "proving_cost_modifier": -272026289, + "fee_asset_price_modifier": -620933033 + }, + "outputs": { + "fee_asset_price_at_execution": 10102648052, + "mana_base_fee_components_in_wei": { + "data_cost": 145, + "gas_cost": 42385179, + "proving_cost": 5449423264, + "congestion_cost": 19918157015, + "congestion_multiplier": 4626884786 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1464, + "gas_cost": 428202546, + "proving_cost": 55053605322, + "congestion_cost": 201226130167, + "congestion_multiplier": 4626884786 + } + } + }, + { + "l1_block_number": 20973704, + "l1_fees": { + "blob_fee": 32996, + "base_fee": 12974547741 + }, + "parent_header": { + "excess_mana": 1309302400, + "mana_used": 116369229, + "proving_cost_per_mana_numerator": 355053462, + "fee_asset_price_numerator": 400314957 + }, + "header": { + "excess_mana": 1325671629, + "mana_used": 96645177, + "proving_cost_per_mana_numerator": 400248833, + "fee_asset_price_numerator": 497696853 + }, + "oracle_input": { + "proving_cost_modifier": 45195371, + "fee_asset_price_modifier": 97381896 + }, + "outputs": { + "fee_asset_price_at_execution": 10040111728, + "mana_base_fee_components_in_wei": { + "data_cost": 129, + "gas_cost": 42978189, + "proving_cost": 5434619545, + "congestion_cost": 20356686621, + "congestion_multiplier": 4716352885 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1295, + "gas_cost": 431505819, + "proving_cost": 54564187430, + "congestion_cost": 204383408086, + "congestion_multiplier": 4716352885 + } + } + }, + { + "l1_block_number": 20973707, + "l1_fees": { + "blob_fee": 31726, + "base_fee": 12024548672 + }, + "parent_header": { + "excess_mana": 1325671629, + "mana_used": 96645177, + "proving_cost_per_mana_numerator": 400248833, + "fee_asset_price_numerator": 497696853 + }, + "header": { + "excess_mana": 1322316806, + "mana_used": 117502004, + "proving_cost_per_mana_numerator": 365016066, + "fee_asset_price_numerator": 360522242 + }, + "oracle_input": { + "proving_cost_modifier": -35232767, + "fee_asset_price_modifier": -137174611 + }, + "outputs": { + "fee_asset_price_at_execution": 10049893742, + "mana_base_fee_components_in_wei": { + "data_cost": 124, + "gas_cost": 39831317, + "proving_cost": 5437076296, + "congestion_cost": 20252930111, + "congestion_multiplier": 4697876810 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1246, + "gas_cost": 400300503, + "proving_cost": 54642039041, + "congestion_cost": 203539795579, + "congestion_multiplier": 4697876810 + } + } + }, + { + "l1_block_number": 20973710, + "l1_fees": { + "blob_fee": 28201, + "base_fee": 12463433465 + }, + "parent_header": { + "excess_mana": 1322316806, + "mana_used": 117502004, + "proving_cost_per_mana_numerator": 365016066, + "fee_asset_price_numerator": 360522242 + }, + "header": { + "excess_mana": 1339818810, + "mana_used": 80370368, + "proving_cost_per_mana_numerator": 207515968, + "fee_asset_price_numerator": 587790795 + }, + "oracle_input": { + "proving_cost_modifier": -157500098, + "fee_asset_price_modifier": 227268553 + }, + "outputs": { + "fee_asset_price_at_execution": 10036117290, + "mana_base_fee_components_in_wei": { + "data_cost": 110, + "gas_cost": 41285123, + "proving_cost": 5435161001, + "congestion_cost": 20783488988, + "congestion_multiplier": 4795068572 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1103, + "gas_cost": 414342336, + "proving_cost": 54547913296, + "congestion_cost": 208585533178, + "congestion_multiplier": 4795068572 + } + } + }, + { + "l1_block_number": 20973713, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 11667927282 + }, + "parent_header": { + "excess_mana": 1339818810, + "mana_used": 80370368, + "proving_cost_per_mana_numerator": 207515968, + "fee_asset_price_numerator": 587790795 + }, + "header": { + "excess_mana": 1320189178, + "mana_used": 122543064, + "proving_cost_per_mana_numerator": 255539944, + "fee_asset_price_numerator": 888025172 + }, + "oracle_input": { + "proving_cost_modifier": 48023976, + "fee_asset_price_modifier": 300234377 + }, + "outputs": { + "fee_asset_price_at_execution": 10058952167, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 38650009, + "proving_cost": 5426607355, + "congestion_cost": 20146014638, + "congestion_multiplier": 4686196813 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 985, + "gas_cost": 388778591, + "proving_cost": 54585983813, + "congestion_cost": 202647797599, + "congestion_multiplier": 4686196813 + } + } + }, + { + "l1_block_number": 20973716, + "l1_fees": { + "blob_fee": 17605, + "base_fee": 12588865223 + }, + "parent_header": { + "excess_mana": 1320189178, + "mana_used": 122543064, + "proving_cost_per_mana_numerator": 255539944, + "fee_asset_price_numerator": 888025172 + }, + "header": { + "excess_mana": 1342732242, + "mana_used": 100615032, + "proving_cost_per_mana_numerator": 286957295, + "fee_asset_price_numerator": 981528734 + }, + "oracle_input": { + "proving_cost_modifier": 31417351, + "fee_asset_price_modifier": 93503562 + }, + "outputs": { + "fee_asset_price_at_execution": 10089197981, + "mana_base_fee_components_in_wei": { + "data_cost": 69, + "gas_cost": 41700616, + "proving_cost": 5429214054, + "congestion_cost": 20852071397, + "congestion_multiplier": 4811441485 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 696, + "gas_cost": 420725770, + "proving_cost": 54776415472, + "congestion_cost": 210380676638, + "congestion_multiplier": 4811441485 + } + } + }, + { + "l1_block_number": 20973719, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 12041731239 + }, + "parent_header": { + "excess_mana": 1342732242, + "mana_used": 100615032, + "proving_cost_per_mana_numerator": 286957295, + "fee_asset_price_numerator": 981528734 + }, + "header": { + "excess_mana": 1343347274, + "mana_used": 77006488, + "proving_cost_per_mana_numerator": 143731815, + "fee_asset_price_numerator": 1796621780 + }, + "oracle_input": { + "proving_cost_modifier": -143225480, + "fee_asset_price_modifier": 815093046 + }, + "outputs": { + "fee_asset_price_at_execution": 10098636152, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 39888234, + "proving_cost": 5430920037, + "congestion_cost": 20870614033, + "congestion_multiplier": 4814904984 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 777, + "gas_cost": 402816761, + "proving_cost": 54844885424, + "congestion_cost": 210764737388, + "congestion_multiplier": 4814904984 + } + } + }, + { + "l1_block_number": 20973722, + "l1_fees": { + "blob_fee": 22282, + "base_fee": 11999031875 + }, + "parent_header": { + "excess_mana": 1343347274, + "mana_used": 77006488, + "proving_cost_per_mana_numerator": 143731815, + "fee_asset_price_numerator": 1796621780 + }, + "header": { + "excess_mana": 1320353762, + "mana_used": 106572663, + "proving_cost_per_mana_numerator": 204284475, + "fee_asset_price_numerator": 1339655635 + }, + "oracle_input": { + "proving_cost_modifier": 60552660, + "fee_asset_price_modifier": -456966145 + }, + "outputs": { + "fee_asset_price_at_execution": 10181285811, + "mana_base_fee_components_in_wei": { + "data_cost": 87, + "gas_cost": 39746793, + "proving_cost": 5423147143, + "congestion_cost": 20142232668, + "congestion_multiplier": 4687099289 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 885, + "gas_cost": 404673459, + "proving_cost": 55214611057, + "congestion_cost": 205073827664, + "congestion_multiplier": 4687099289 + } + } + }, + { + "l1_block_number": 20973725, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 11451155317 + }, + "parent_header": { + "excess_mana": 1320353762, + "mana_used": 106572663, + "proving_cost_per_mana_numerator": 204284475, + "fee_asset_price_numerator": 1339655635 + }, + "header": { + "excess_mana": 1326926425, + "mana_used": 107682586, + "proving_cost_per_mana_numerator": 22685411, + "fee_asset_price_numerator": 1288771117 + }, + "oracle_input": { + "proving_cost_modifier": -181599064, + "fee_asset_price_modifier": -50884518 + }, + "outputs": { + "fee_asset_price_at_execution": 10134866922, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 37931951, + "proving_cost": 5426431997, + "congestion_cost": 20345368845, + "congestion_multiplier": 4723282101 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 993, + "gas_cost": 384435275, + "proving_cost": 54996166150, + "congestion_cost": 206197605723, + "congestion_multiplier": 4723282101 + } + } + }, + { + "l1_block_number": 20973728, + "l1_fees": { + "blob_fee": 30505, + "base_fee": 11303347796 + }, + "parent_header": { + "excess_mana": 1326926425, + "mana_used": 107682586, + "proving_cost_per_mana_numerator": 22685411, + "fee_asset_price_numerator": 1288771117 + }, + "header": { + "excess_mana": 1334609011, + "mana_used": 99341302, + "proving_cost_per_mana_numerator": 39587039, + "fee_asset_price_numerator": 2288771117 + }, + "oracle_input": { + "proving_cost_modifier": 16901628, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10129711156, + "mana_base_fee_components_in_wei": { + "data_cost": 119, + "gas_cost": 37442339, + "proving_cost": 5416586590, + "congestion_cost": 20539487789, + "congestion_multiplier": 4765929299 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1205, + "gas_cost": 379280079, + "proving_cost": 54868457608, + "congestion_cost": 208059078594, + "congestion_multiplier": 4765929299 + } + } + }, + { + "l1_block_number": 20973731, + "l1_fees": { + "blob_fee": 27115, + "base_fee": 11131576212 + }, + "parent_header": { + "excess_mana": 1334609011, + "mana_used": 99341302, + "proving_cost_per_mana_numerator": 39587039, + "fee_asset_price_numerator": 2288771117 + }, + "header": { + "excess_mana": 1333950313, + "mana_used": 98924508, + "proving_cost_per_mana_numerator": 102816084, + "fee_asset_price_numerator": 2351903422 + }, + "oracle_input": { + "proving_cost_modifier": 63229045, + "fee_asset_price_modifier": 63132305 + }, + "outputs": { + "fee_asset_price_at_execution": 10231516445, + "mana_base_fee_components_in_wei": { + "data_cost": 106, + "gas_cost": 36873346, + "proving_cost": 5417502159, + "congestion_cost": 20520766766, + "congestion_multiplier": 4762257723 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1084, + "gas_cost": 377270245, + "proving_cost": 55429262430, + "congestion_cost": 209958562630, + "congestion_multiplier": 4762257723 + } + } + }, + { + "l1_block_number": 20973734, + "l1_fees": { + "blob_fee": 27115, + "base_fee": 11324057276 + }, + "parent_header": { + "excess_mana": 1333950313, + "mana_used": 98924508, + "proving_cost_per_mana_numerator": 102816084, + "fee_asset_price_numerator": 2351903422 + }, + "header": { + "excess_mana": 1332874821, + "mana_used": 92189342, + "proving_cost_per_mana_numerator": 236788546, + "fee_asset_price_numerator": 1804191747 + }, + "oracle_input": { + "proving_cost_modifier": 133972462, + "fee_asset_price_modifier": -547711675 + }, + "outputs": { + "fee_asset_price_at_execution": 10237977877, + "mana_base_fee_components_in_wei": { + "data_cost": 106, + "gas_cost": 37510939, + "proving_cost": 5420928677, + "congestion_cost": 20503368030, + "congestion_multiplier": 4756269021 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1085, + "gas_cost": 384036163, + "proving_cost": 55499347867, + "congestion_cost": 209913028295, + "congestion_multiplier": 4756269021 + } + } + }, + { + "l1_block_number": 20973737, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 12400836887 + }, + "parent_header": { + "excess_mana": 1332874821, + "mana_used": 92189342, + "proving_cost_per_mana_numerator": 236788546, + "fee_asset_price_numerator": 1804191747 + }, + "header": { + "excess_mana": 1325064163, + "mana_used": 95916080, + "proving_cost_per_mana_numerator": 141587906, + "fee_asset_price_numerator": 2358872831 + }, + "oracle_input": { + "proving_cost_modifier": -95200640, + "fee_asset_price_modifier": 554681084 + }, + "outputs": { + "fee_asset_price_at_execution": 10182056561, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 41077772, + "proving_cost": 5428196095, + "congestion_cost": 20307425133, + "congestion_multiplier": 4713001998 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 926, + "gas_cost": 418256197, + "proving_cost": 55270199663, + "congestion_cost": 206771351312, + "congestion_multiplier": 4713001998 + } + } + }, + { + "l1_block_number": 20973740, + "l1_fees": { + "blob_fee": 28201, + "base_fee": 12009113331 + }, + "parent_header": { + "excess_mana": 1325064163, + "mana_used": 95916080, + "proving_cost_per_mana_numerator": 141587906, + "fee_asset_price_numerator": 2358872831 + }, + "header": { + "excess_mana": 1320980243, + "mana_used": 82886232, + "proving_cost_per_mana_numerator": 228305694, + "fee_asset_price_numerator": 2538942324 + }, + "oracle_input": { + "proving_cost_modifier": 86717788, + "fee_asset_price_modifier": 180069493 + }, + "outputs": { + "fee_asset_price_at_execution": 10238691428, + "mana_base_fee_components_in_wei": { + "data_cost": 110, + "gas_cost": 39780187, + "proving_cost": 5423030877, + "congestion_cost": 20160701910, + "congestion_multiplier": 4690536112 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1126, + "gas_cost": 407297059, + "proving_cost": 55524739754, + "congestion_cost": 206419205828, + "congestion_multiplier": 4690536112 + } + } + }, + { + "l1_block_number": 20973743, + "l1_fees": { + "blob_fee": 29330, + "base_fee": 11347704848 + }, + "parent_header": { + "excess_mana": 1320980243, + "mana_used": 82886232, + "proving_cost_per_mana_numerator": 228305694, + "fee_asset_price_numerator": 2538942324 + }, + "header": { + "excess_mana": 1303866475, + "mana_used": 99575548, + "proving_cost_per_mana_numerator": 191313213, + "fee_asset_price_numerator": 2276176576 + }, + "oracle_input": { + "proving_cost_modifier": -36992481, + "fee_asset_price_modifier": -262765748 + }, + "outputs": { + "fee_asset_price_at_execution": 10257144798, + "mana_base_fee_components_in_wei": { + "data_cost": 115, + "gas_cost": 37589272, + "proving_cost": 5427735649, + "congestion_cost": 19661785712, + "congestion_multiplier": 4597551030 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1179, + "gas_cost": 385558605, + "proving_cost": 55673070477, + "congestion_cost": 201673783035, + "congestion_multiplier": 4597551030 + } + } + }, + { + "l1_block_number": 20973746, + "l1_fees": { + "blob_fee": 32996, + "base_fee": 11581848907 + }, + "parent_header": { + "excess_mana": 1303866475, + "mana_used": 99575548, + "proving_cost_per_mana_numerator": 191313213, + "fee_asset_price_numerator": 2276176576 + }, + "header": { + "excess_mana": 1303442023, + "mana_used": 112024559, + "proving_cost_per_mana_numerator": 80126553, + "fee_asset_price_numerator": 2827578672 + }, + "oracle_input": { + "proving_cost_modifier": -111186660, + "fee_asset_price_modifier": 551402096 + }, + "outputs": { + "fee_asset_price_at_execution": 10230227914, + "mana_base_fee_components_in_wei": { + "data_cost": 129, + "gas_cost": 38364874, + "proving_cost": 5425728166, + "congestion_cost": 19644881570, + "congestion_multiplier": 4595268412 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1319, + "gas_cost": 392481404, + "proving_cost": 55506435737, + "congestion_cost": 200971615804, + "congestion_multiplier": 4595268412 + } + } + }, + { + "l1_block_number": 20973749, + "l1_fees": { + "blob_fee": 29330, + "base_fee": 11435533437 + }, + "parent_header": { + "excess_mana": 1303442023, + "mana_used": 112024559, + "proving_cost_per_mana_numerator": 80126553, + "fee_asset_price_numerator": 2827578672 + }, + "header": { + "excess_mana": 1315466582, + "mana_used": 120164071, + "proving_cost_per_mana_numerator": 56045946, + "fee_asset_price_numerator": 3348463536 + }, + "oracle_input": { + "proving_cost_modifier": -24080607, + "fee_asset_price_modifier": 520884864 + }, + "outputs": { + "fee_asset_price_at_execution": 10286793414, + "mana_base_fee_components_in_wei": { + "data_cost": 115, + "gas_cost": 37880204, + "proving_cost": 5419698833, + "congestion_cost": 19976785911, + "congestion_multiplier": 4660374931 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1182, + "gas_cost": 389665833, + "proving_cost": 55751322261, + "congestion_cost": 205497069742, + "congestion_multiplier": 4660374931 + } + } + }, + { + "l1_block_number": 20973752, + "l1_fees": { + "blob_fee": 41761, + "base_fee": 11193020248 + }, + "parent_header": { + "excess_mana": 1315466582, + "mana_used": 120164071, + "proving_cost_per_mana_numerator": 56045946, + "fee_asset_price_numerator": 3348463536 + }, + "header": { + "excess_mana": 1335630653, + "mana_used": 94218981, + "proving_cost_per_mana_numerator": 26648853, + "fee_asset_price_numerator": 3252411517 + }, + "oracle_input": { + "proving_cost_modifier": -29397093, + "fee_asset_price_modifier": -96052019 + }, + "outputs": { + "fee_asset_price_at_execution": 10340515557, + "mana_base_fee_components_in_wei": { + "data_cost": 164, + "gas_cost": 37076879, + "proving_cost": 5418393894, + "congestion_cost": 20576015236, + "congestion_multiplier": 4771629521 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1695, + "gas_cost": 383394044, + "proving_cost": 56028986354, + "congestion_cost": 212766605648, + "congestion_multiplier": 4771629521 + } + } + }, + { + "l1_block_number": 20973755, + "l1_fees": { + "blob_fee": 30505, + "base_fee": 10757053816 + }, + "parent_header": { + "excess_mana": 1335630653, + "mana_used": 94218981, + "proving_cost_per_mana_numerator": 26648853, + "fee_asset_price_numerator": 3252411517 + }, + "header": { + "excess_mana": 1329849634, + "mana_used": 105066595, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3510685066 + }, + "oracle_input": { + "proving_cost_modifier": -199703229, + "fee_asset_price_modifier": 258273549 + }, + "outputs": { + "fee_asset_price_at_execution": 10330588052, + "mana_base_fee_components_in_wei": { + "data_cost": 119, + "gas_cost": 35632740, + "proving_cost": 5416801278, + "congestion_cost": 20389181783, + "congestion_multiplier": 4739464113 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1229, + "gas_cost": 368107158, + "proving_cost": 55958742562, + "congestion_cost": 210632237717, + "congestion_multiplier": 4739464113 + } + } + }, + { + "l1_block_number": 20973758, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 10381187963 + }, + "parent_header": { + "excess_mana": 1329849634, + "mana_used": 105066595, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3510685066 + }, + "header": { + "excess_mana": 1334916229, + "mana_used": 89931642, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3335505808 + }, + "oracle_input": { + "proving_cost_modifier": -49792707, + "fee_asset_price_modifier": -175179258 + }, + "outputs": { + "fee_asset_price_at_execution": 10357303713, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 34387685, + "proving_cost": 5415357955, + "congestion_cost": 20532694724, + "congestion_multiplier": 4767642696 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1015, + "gas_cost": 356163697, + "proving_cost": 56088507054, + "congestion_cost": 212663355302, + "congestion_multiplier": 4767642696 + } + } + }, + { + "l1_block_number": 20973761, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 12244616598 + }, + "parent_header": { + "excess_mana": 1334916229, + "mana_used": 89931642, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3335505808 + }, + "header": { + "excess_mana": 1324847871, + "mana_used": 101874759, + "proving_cost_per_mana_numerator": 90251834, + "fee_asset_price_numerator": 3015527291 + }, + "oracle_input": { + "proving_cost_modifier": 90251834, + "fee_asset_price_modifier": -319978517 + }, + "outputs": { + "fee_asset_price_at_execution": 10339175748, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 40560292, + "proving_cost": 5415357955, + "congestion_cost": 20251329375, + "congestion_multiplier": 4711809469 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1013, + "gas_cost": 419359987, + "proving_cost": 55990337635, + "congestion_cost": 209382053538, + "congestion_multiplier": 4711809469 + } + } + }, + { + "l1_block_number": 20973764, + "l1_fees": { + "blob_fee": 20599, + "base_fee": 11587680957 + }, + "parent_header": { + "excess_mana": 1324847871, + "mana_used": 101874759, + "proving_cost_per_mana_numerator": 90251834, + "fee_asset_price_numerator": 3015527291 + }, + "header": { + "excess_mana": 1326722630, + "mana_used": 94633541, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2948017643 + }, + "oracle_input": { + "proving_cost_modifier": -202786759, + "fee_asset_price_modifier": -67509648 + }, + "outputs": { + "fee_asset_price_at_execution": 10306145480, + "mana_base_fee_components_in_wei": { + "data_cost": 80, + "gas_cost": 38384193, + "proving_cost": 5420247621, + "congestion_cost": 20317879543, + "congestion_multiplier": 4722156016 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 824, + "gas_cost": 395593077, + "proving_cost": 55861860519, + "congestion_cost": 209399022415, + "congestion_multiplier": 4722156016 + } + } + }, + { + "l1_block_number": 20973767, + "l1_fees": { + "blob_fee": 23174, + "base_fee": 11392419394 + }, + "parent_header": { + "excess_mana": 1326722630, + "mana_used": 94633541, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2948017643 + }, + "header": { + "excess_mana": 1321356171, + "mana_used": 107027137, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2964670861 + }, + "oracle_input": { + "proving_cost_modifier": -569992, + "fee_asset_price_modifier": 16653218 + }, + "outputs": { + "fee_asset_price_at_execution": 10299190185, + "mana_base_fee_components_in_wei": { + "data_cost": 91, + "gas_cost": 37737389, + "proving_cost": 5415357955, + "congestion_cost": 20136098191, + "congestion_multiplier": 4692599631 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 937, + "gas_cost": 388664546, + "proving_cost": 55773801498, + "congestion_cost": 207385504852, + "congestion_multiplier": 4692599631 + } + } + }, + { + "l1_block_number": 20973770, + "l1_fees": { + "blob_fee": 26071, + "base_fee": 11075431045 + }, + "parent_header": { + "excess_mana": 1321356171, + "mana_used": 107027137, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2964670861 + }, + "header": { + "excess_mana": 1328383308, + "mana_used": 98027217, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2914036442 + }, + "oracle_input": { + "proving_cost_modifier": -8209932, + "fee_asset_price_modifier": -50634419 + }, + "outputs": { + "fee_asset_price_at_execution": 10300905475, + "mana_base_fee_components_in_wei": { + "data_cost": 102, + "gas_cost": 36687365, + "proving_cost": 5415357955, + "congestion_cost": 20343435448, + "congestion_multiplier": 4731340052 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1050, + "gas_cost": 377913078, + "proving_cost": 55783090407, + "congestion_cost": 209555805586, + "congestion_multiplier": 4731340052 + } + } + }, + { + "l1_block_number": 20973773, + "l1_fees": { + "blob_fee": 20599, + "base_fee": 11109198013 + }, + "parent_header": { + "excess_mana": 1328383308, + "mana_used": 98027217, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 2914036442 + }, + "header": { + "excess_mana": 1326410525, + "mana_used": 95385211, + "proving_cost_per_mana_numerator": 85267716, + "fee_asset_price_numerator": 3385377647 + }, + "oracle_input": { + "proving_cost_modifier": 85267716, + "fee_asset_price_modifier": 471341205 + }, + "outputs": { + "fee_asset_price_at_execution": 10295690992, + "mana_base_fee_components_in_wei": { + "data_cost": 80, + "gas_cost": 36799218, + "proving_cost": 5415357955, + "congestion_cost": 20284380171, + "congestion_multiplier": 4720431974 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 823, + "gas_cost": 378873377, + "proving_cost": 55754852115, + "congestion_cost": 208841710204, + "congestion_multiplier": 4720431974 + } + } + }, + { + "l1_block_number": 20973776, + "l1_fees": { + "blob_fee": 19044, + "base_fee": 10883747585 + }, + "parent_header": { + "excess_mana": 1326410525, + "mana_used": 95385211, + "proving_cost_per_mana_numerator": 85267716, + "fee_asset_price_numerator": 3385377647 + }, + "header": { + "excess_mana": 1321795736, + "mana_used": 108511444, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3548299411 + }, + "oracle_input": { + "proving_cost_modifier": -113972577, + "fee_asset_price_modifier": 162921764 + }, + "outputs": { + "fee_asset_price_at_execution": 10344333371, + "mana_base_fee_components_in_wei": { + "data_cost": 74, + "gas_cost": 36052413, + "proving_cost": 5419977476, + "congestion_cost": 20160104991, + "congestion_multiplier": 4695013614 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 765, + "gas_cost": 372938178, + "proving_cost": 56066053875, + "congestion_cost": 208542846821, + "congestion_multiplier": 4695013614 + } + } + }, + { + "l1_block_number": 20973779, + "l1_fees": { + "blob_fee": 15649, + "base_fee": 10780629747 + }, + "parent_header": { + "excess_mana": 1321795736, + "mana_used": 108511444, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3548299411 + }, + "header": { + "excess_mana": 1330307180, + "mana_used": 93449181, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3189620902 + }, + "oracle_input": { + "proving_cost_modifier": -93357778, + "fee_asset_price_modifier": -358678509 + }, + "outputs": { + "fee_asset_price_at_execution": 10361200278, + "mana_base_fee_components_in_wei": { + "data_cost": 61, + "gas_cost": 35710836, + "proving_cost": 5415357955, + "congestion_cost": 20397910350, + "congestion_multiplier": 4742001964 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 632, + "gas_cost": 370007123, + "proving_cost": 56109608348, + "congestion_cost": 211346834389, + "congestion_multiplier": 4742001964 + } + } + }, + { + "l1_block_number": 20973782, + "l1_fees": { + "blob_fee": 13910, + "base_fee": 11769070727 + }, + "parent_header": { + "excess_mana": 1330307180, + "mana_used": 93449181, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3189620902 + }, + "header": { + "excess_mana": 1323756361, + "mana_used": 102696150, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3501596935 + }, + "oracle_input": { + "proving_cost_modifier": -140392501, + "fee_asset_price_modifier": 311976033 + }, + "outputs": { + "fee_asset_price_at_execution": 10324103448, + "mana_base_fee_components_in_wei": { + "data_cost": 54, + "gas_cost": 38985046, + "proving_cost": 5415357955, + "congestion_cost": 20212682757, + "congestion_multiplier": 4705796015 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 557, + "gas_cost": 402485647, + "proving_cost": 55908715735, + "congestion_cost": 208677827744, + "congestion_multiplier": 4705796015 + } + } + }, + { + "l1_block_number": 20973785, + "l1_fees": { + "blob_fee": 14467, + "base_fee": 11246048481 + }, + "parent_header": { + "excess_mana": 1323756361, + "mana_used": 102696150, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3501596935 + }, + "header": { + "excess_mana": 1326452511, + "mana_used": 114672112, + "proving_cost_per_mana_numerator": 169825398, + "fee_asset_price_numerator": 2803029127 + }, + "oracle_input": { + "proving_cost_modifier": 169825398, + "fee_asset_price_modifier": -698567808 + }, + "outputs": { + "fee_asset_price_at_execution": 10356362471, + "mana_base_fee_components_in_wei": { + "data_cost": 56, + "gas_cost": 37252535, + "proving_cost": 5415357955, + "congestion_cost": 20287331028, + "congestion_multiplier": 4720663865 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 579, + "gas_cost": 385800755, + "proving_cost": 56083409892, + "congestion_cost": 210102953695, + "congestion_multiplier": 4720663865 + } + } + }, + { + "l1_block_number": 20973788, + "l1_fees": { + "blob_fee": 11431, + "base_fee": 11164890840 + }, + "parent_header": { + "excess_mana": 1326452511, + "mana_used": 114672112, + "proving_cost_per_mana_numerator": 169825398, + "fee_asset_price_numerator": 2803029127 + }, + "header": { + "excess_mana": 1341124623, + "mana_used": 91197669, + "proving_cost_per_mana_numerator": 185721686, + "fee_asset_price_numerator": 3523632779 + }, + "oracle_input": { + "proving_cost_modifier": 15896288, + "fee_asset_price_modifier": 720603652 + }, + "outputs": { + "fee_asset_price_at_execution": 10284268363, + "mana_base_fee_components_in_wei": { + "data_cost": 44, + "gas_cost": 36983700, + "proving_cost": 5424562421, + "congestion_cost": 20766983585, + "congestion_multiplier": 4802400082 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 452, + "gas_cost": 380350295, + "proving_cost": 55787655689, + "congestion_cost": 213573232278, + "congestion_multiplier": 4802400082 + } + } + }, + { + "l1_block_number": 20973791, + "l1_fees": { + "blob_fee": 10991, + "base_fee": 10813707297 + }, + "parent_header": { + "excess_mana": 1341124623, + "mana_used": 91197669, + "proving_cost_per_mana_numerator": 185721686, + "fee_asset_price_numerator": 3523632779 + }, + "header": { + "excess_mana": 1332322292, + "mana_used": 106948598, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3627293630 + }, + "oracle_input": { + "proving_cost_modifier": -193404025, + "fee_asset_price_modifier": 103660851 + }, + "outputs": { + "fee_asset_price_at_execution": 10358644834, + "mana_base_fee_components_in_wei": { + "data_cost": 43, + "gas_cost": 35820405, + "proving_cost": 5425424794, + "congestion_cost": 20497119876, + "congestion_multiplier": 4753195282 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 445, + "gas_cost": 371050853, + "proving_cost": 56200048514, + "congestion_cost": 212322384915, + "congestion_multiplier": 4753195282 + } + } + }, + { + "l1_block_number": 20973794, + "l1_fees": { + "blob_fee": 11431, + "base_fee": 11438721490 + }, + "parent_header": { + "excess_mana": 1332322292, + "mana_used": 106948598, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3627293630 + }, + "header": { + "excess_mana": 1339270890, + "mana_used": 98247953, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3405798460 + }, + "oracle_input": { + "proving_cost_modifier": -104227219, + "fee_asset_price_modifier": -221495170 + }, + "outputs": { + "fee_asset_price_at_execution": 10369388261, + "mana_base_fee_components_in_wei": { + "data_cost": 44, + "gas_cost": 37890764, + "proving_cost": 5415357955, + "congestion_cost": 20678695309, + "congestion_multiplier": 4791995599 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 456, + "gas_cost": 392904043, + "proving_cost": 56153949207, + "congestion_cost": 214425420389, + "congestion_multiplier": 4791995599 + } + } + }, + { + "l1_block_number": 20973797, + "l1_fees": { + "blob_fee": 13910, + "base_fee": 10815929413 + }, + "parent_header": { + "excess_mana": 1339270890, + "mana_used": 98247953, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3405798460 + }, + "header": { + "excess_mana": 1337518843, + "mana_used": 93403246, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4405798460 + }, + "oracle_input": { + "proving_cost_modifier": -24507243, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10346445984, + "mana_base_fee_components_in_wei": { + "data_cost": 54, + "gas_cost": 35827766, + "proving_cost": 5415357955, + "congestion_cost": 20617379840, + "congestion_multiplier": 4782182573 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 558, + "gas_cost": 370690045, + "proving_cost": 56029708565, + "congestion_cost": 213316606846, + "congestion_multiplier": 4782182573 + } + } + }, + { + "l1_block_number": 20973800, + "l1_fees": { + "blob_fee": 10991, + "base_fee": 10583530192 + }, + "parent_header": { + "excess_mana": 1337518843, + "mana_used": 93403246, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4405798460 + }, + "header": { + "excess_mana": 1330922089, + "mana_used": 89690723, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4114053528 + }, + "oracle_input": { + "proving_cost_modifier": -22027852, + "fee_asset_price_modifier": -291744932 + }, + "outputs": { + "fee_asset_price_at_execution": 10450429495, + "mana_base_fee_components_in_wei": { + "data_cost": 43, + "gas_cost": 35057943, + "proving_cost": 5415357955, + "congestion_cost": 20414068498, + "congestion_multiplier": 4745414794 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 449, + "gas_cost": 366370561, + "proving_cost": 56592816498, + "congestion_cost": 213335783544, + "congestion_multiplier": 4745414794 + } + } + }, + { + "l1_block_number": 20973803, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 11186336309 + }, + "parent_header": { + "excess_mana": 1330922089, + "mana_used": 89690723, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4114053528 + }, + "header": { + "excess_mana": 1320612812, + "mana_used": 87770657, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4743652738 + }, + "oracle_input": { + "proving_cost_modifier": -11552448, + "fee_asset_price_modifier": 629599210 + }, + "outputs": { + "fee_asset_price_at_execution": 10419985328, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 37054739, + "proving_cost": 5415357955, + "congestion_cost": 20111334004, + "congestion_multiplier": 4688520111 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 364, + "gas_cost": 386109836, + "proving_cost": 56427950436, + "congestion_cost": 209559805248, + "congestion_multiplier": 4688520111 + } + } + }, + { + "l1_block_number": 20973806, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 11129408959 + }, + "parent_header": { + "excess_mana": 1320612812, + "mana_used": 87770657, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4743652738 + }, + "header": { + "excess_mana": 1308383469, + "mana_used": 102859592, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5197759505 + }, + "oracle_input": { + "proving_cost_modifier": -4484625, + "fee_asset_price_modifier": 454106767 + }, + "outputs": { + "fee_asset_price_at_execution": 10485796429, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 36866167, + "proving_cost": 5415357955, + "congestion_cost": 19747480824, + "congestion_multiplier": 4621912867 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 356, + "gas_cost": 386571122, + "proving_cost": 56784341106, + "congestion_cost": 207068063906, + "congestion_multiplier": 4621912867 + } + } + }, + { + "l1_block_number": 20973809, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 11133709414 + }, + "parent_header": { + "excess_mana": 1308383469, + "mana_used": 102859592, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 5197759505 + }, + "header": { + "excess_mana": 1311243061, + "mana_used": 114671108, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6197759505 + }, + "oracle_input": { + "proving_cost_modifier": -117737933, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10533521419, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 36880412, + "proving_cost": 5415357955, + "congestion_cost": 19831985061, + "congestion_multiplier": 4637402403 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 358, + "gas_cost": 388480609, + "proving_cost": 57042789010, + "congestion_cost": 208900639421, + "congestion_multiplier": 4637402403 + } + } + }, + { + "l1_block_number": 20973812, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 10564687507 + }, + "parent_header": { + "excess_mana": 1311243061, + "mana_used": 114671108, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 6197759505 + }, + "header": { + "excess_mana": 1325914169, + "mana_used": 96314421, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7197759505 + }, + "oracle_input": { + "proving_cost_modifier": -61178209, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10639385069, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 34995527, + "proving_cost": 5415357955, + "congestion_cost": 20262732642, + "congestion_multiplier": 4717691443 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 404, + "gas_cost": 372330887, + "proving_cost": 57616078569, + "congestion_cost": 215583015128, + "congestion_multiplier": 4717691443 + } + } + }, + { + "l1_block_number": 20973815, + "l1_fees": { + "blob_fee": 10991, + "base_fee": 9916160334 + }, + "parent_header": { + "excess_mana": 1325914169, + "mana_used": 96314421, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 7197759505 + }, + "header": { + "excess_mana": 1322228590, + "mana_used": 105614317, + "proving_cost_per_mana_numerator": 87880734, + "fee_asset_price_numerator": 7535535998 + }, + "oracle_input": { + "proving_cost_modifier": 87880734, + "fee_asset_price_modifier": 337776493 + }, + "outputs": { + "fee_asset_price_at_execution": 10746312667, + "mana_base_fee_components_in_wei": { + "data_cost": 43, + "gas_cost": 32847281, + "proving_cost": 5415357955, + "congestion_cost": 20144150367, + "congestion_multiplier": 4697391955 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 462, + "gas_cost": 352987151, + "proving_cost": 58195129788, + "congestion_cost": 216475338254, + "congestion_multiplier": 4697391955 + } + } + }, + { + "l1_block_number": 20973818, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 11009914791 + }, + "parent_header": { + "excess_mana": 1322228590, + "mana_used": 105614317, + "proving_cost_per_mana_numerator": 87880734, + "fee_asset_price_numerator": 7535535998 + }, + "header": { + "excess_mana": 1327842907, + "mana_used": 104200639, + "proving_cost_per_mana_numerator": 136531463, + "fee_asset_price_numerator": 6535535998 + }, + "oracle_input": { + "proving_cost_modifier": 48650729, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10782672558, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 36470342, + "proving_cost": 5420119103, + "congestion_cost": 20344072763, + "congestion_multiplier": 4728349517 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 409, + "gas_cost": 393247755, + "proving_cost": 58443369513, + "congestion_cost": 219363475099, + "congestion_multiplier": 4728349517 + } + } + }, + { + "l1_block_number": 20973821, + "l1_fees": { + "blob_fee": 10568, + "base_fee": 11544661257 + }, + "parent_header": { + "excess_mana": 1327842907, + "mana_used": 104200639, + "proving_cost_per_mana_numerator": 136531463, + "fee_asset_price_numerator": 6535535998 + }, + "header": { + "excess_mana": 1332043546, + "mana_used": 95146481, + "proving_cost_per_mana_numerator": 93236650, + "fee_asset_price_numerator": 6189753188 + }, + "oracle_input": { + "proving_cost_modifier": -43294813, + "fee_asset_price_modifier": -345782810 + }, + "outputs": { + "fee_asset_price_at_execution": 10675383173, + "mana_base_fee_components_in_wei": { + "data_cost": 41, + "gas_cost": 38241690, + "proving_cost": 5422756672, + "congestion_cost": 20487729330, + "congestion_multiplier": 4751645362 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 437, + "gas_cost": 408244693, + "proving_cost": 57890005327, + "congestion_cost": 218714360942, + "congestion_multiplier": 4751645362 + } + } + }, + { + "l1_block_number": 20973824, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 11598807653 + }, + "parent_header": { + "excess_mana": 1332043546, + "mana_used": 95146481, + "proving_cost_per_mana_numerator": 93236650, + "fee_asset_price_numerator": 6189753188 + }, + "header": { + "excess_mana": 1327190027, + "mana_used": 85556181, + "proving_cost_per_mana_numerator": 194872565, + "fee_asset_price_numerator": 6205591853 + }, + "oracle_input": { + "proving_cost_modifier": 101635915, + "fee_asset_price_modifier": 15838665 + }, + "outputs": { + "fee_asset_price_at_execution": 10638533280, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 38421050, + "proving_cost": 5420409407, + "congestion_cost": 20332719122, + "congestion_multiplier": 4724739054 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 372, + "gas_cost": 408743619, + "proving_cost": 57665205867, + "congestion_cost": 216310309052, + "congestion_multiplier": 4724739054 + } + } + }, + { + "l1_block_number": 20973827, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 11635181863 + }, + "parent_header": { + "excess_mana": 1327190027, + "mana_used": 85556181, + "proving_cost_per_mana_numerator": 194872565, + "fee_asset_price_numerator": 6205591853 + }, + "header": { + "excess_mana": 1312746208, + "mana_used": 100135907, + "proving_cost_per_mana_numerator": 240667911, + "fee_asset_price_numerator": 6278612236 + }, + "oracle_input": { + "proving_cost_modifier": 45795346, + "fee_asset_price_modifier": 73020383 + }, + "outputs": { + "fee_asset_price_at_execution": 10640218416, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 38541539, + "proving_cost": 5425921291, + "congestion_cost": 19921056176, + "congestion_multiplier": 4645565295 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 372, + "gas_cost": 410090393, + "proving_cost": 57732987644, + "congestion_cost": 211964388790, + "congestion_multiplier": 4645565295 + } + } + }, + { + "l1_block_number": 20973830, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 10954393731 + }, + "parent_header": { + "excess_mana": 1312746208, + "mana_used": 100135907, + "proving_cost_per_mana_numerator": 240667911, + "fee_asset_price_numerator": 6278612236 + }, + "header": { + "excess_mana": 1312882115, + "mana_used": 102142387, + "proving_cost_per_mana_numerator": 301905516, + "fee_asset_price_numerator": 6462410828 + }, + "oracle_input": { + "proving_cost_modifier": 61237605, + "fee_asset_price_modifier": 183798592 + }, + "outputs": { + "fee_asset_price_at_execution": 10647990781, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 36286429, + "proving_cost": 5428406679, + "congestion_cost": 19925932750, + "congestion_multiplier": 4646304050 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 404, + "gas_cost": 386377561, + "proving_cost": 57801624273, + "congestion_cost": 212171148224, + "congestion_multiplier": 4646304050 + } + } + }, + { + "l1_block_number": 20973833, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 12832884693 + }, + "parent_header": { + "excess_mana": 1312882115, + "mana_used": 102142387, + "proving_cost_per_mana_numerator": 301905516, + "fee_asset_price_numerator": 6462410828 + }, + "header": { + "excess_mana": 1315024502, + "mana_used": 108099379, + "proving_cost_per_mana_numerator": 186947548, + "fee_asset_price_numerator": 6196588479 + }, + "oracle_input": { + "proving_cost_modifier": -114957968, + "fee_asset_price_modifier": -265822349 + }, + "outputs": { + "fee_asset_price_at_execution": 10667579635, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 42508930, + "proving_cost": 5431731923, + "congestion_cost": 20024581849, + "congestion_multiplier": 4657965051 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 373, + "gas_cost": 453467395, + "proving_cost": 57943432844, + "congestion_cost": 213613821531, + "congestion_multiplier": 4657965051 + } + } + }, + { + "l1_block_number": 20973836, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 11598902204 + }, + "parent_header": { + "excess_mana": 1315024502, + "mana_used": 108099379, + "proving_cost_per_mana_numerator": 186947548, + "fee_asset_price_numerator": 6196588479 + }, + "header": { + "excess_mana": 1323123881, + "mana_used": 112983367, + "proving_cost_per_mana_numerator": 317869118, + "fee_asset_price_numerator": 5612257785 + }, + "oracle_input": { + "proving_cost_modifier": 130921570, + "fee_asset_price_modifier": -584330694 + }, + "outputs": { + "fee_asset_price_at_execution": 10639260480, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 38421363, + "proving_cost": 5425491302, + "congestion_cost": 20229125958, + "congestion_multiplier": 4702315006 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 308, + "gas_cost": 408774888, + "proving_cost": 57723215193, + "congestion_cost": 215222940349, + "congestion_multiplier": 4702315006 + } + } + }, + { + "l1_block_number": 20973839, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 11475907941 + }, + "parent_header": { + "excess_mana": 1323123881, + "mana_used": 112983367, + "proving_cost_per_mana_numerator": 317869118, + "fee_asset_price_numerator": 5612257785 + }, + "header": { + "excess_mana": 1336107248, + "mana_used": 78716153, + "proving_cost_per_mana_numerator": 324730950, + "fee_asset_price_numerator": 5123208967 + }, + "oracle_input": { + "proving_cost_modifier": 6861832, + "fee_asset_price_modifier": -489048818 + }, + "outputs": { + "fee_asset_price_at_execution": 10577273297, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 38013945, + "proving_cost": 5432599093, + "congestion_cost": 20647685682, + "congestion_multiplier": 4774291000 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 359, + "gas_cost": 402083885, + "proving_cost": 57462085319, + "congestion_cost": 218396214409, + "congestion_multiplier": 4774291000 + } + } + }, + { + "l1_block_number": 20973842, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 11221372712 + }, + "parent_header": { + "excess_mana": 1336107248, + "mana_used": 78716153, + "proving_cost_per_mana_numerator": 324730950, + "fee_asset_price_numerator": 5123208967 + }, + "header": { + "excess_mana": 1314823401, + "mana_used": 100573975, + "proving_cost_per_mana_numerator": 462472768, + "fee_asset_price_numerator": 5461974111 + }, + "oracle_input": { + "proving_cost_modifier": 137741818, + "fee_asset_price_modifier": 338765144 + }, + "outputs": { + "fee_asset_price_at_execution": 10525671549, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 37170797, + "proving_cost": 5432971881, + "congestion_cost": 20003596494, + "congestion_multiplier": 4656869216 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 368, + "gas_cost": 391247600, + "proving_cost": 57185677554, + "congestion_cost": 210551286494, + "congestion_multiplier": 4656869216 + } + } + }, + { + "l1_block_number": 20973845, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 11631406437 + }, + "parent_header": { + "excess_mana": 1314823401, + "mana_used": 100573975, + "proving_cost_per_mana_numerator": 462472768, + "fee_asset_price_numerator": 5461974111 + }, + "header": { + "excess_mana": 1315397376, + "mana_used": 109913708, + "proving_cost_per_mana_numerator": 413470065, + "fee_asset_price_numerator": 5513990530 + }, + "oracle_input": { + "proving_cost_modifier": -49002703, + "fee_asset_price_modifier": 52016419 + }, + "outputs": { + "fee_asset_price_at_execution": 10561389320, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 38529033, + "proving_cost": 5440460512, + "congestion_cost": 20053088632, + "congestion_multiplier": 4659997590 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 295, + "gas_cost": 406920117, + "proving_cost": 57458821547, + "congestion_cost": 211788476111, + "congestion_multiplier": 4659997590 + } + } + }, + { + "l1_block_number": 20973848, + "l1_fees": { + "blob_fee": 9032, + "base_fee": 11248483537 + }, + "parent_header": { + "excess_mana": 1315397376, + "mana_used": 109913708, + "proving_cost_per_mana_numerator": 413470065, + "fee_asset_price_numerator": 5513990530 + }, + "header": { + "excess_mana": 1325311084, + "mana_used": 96372911, + "proving_cost_per_mana_numerator": 224365590, + "fee_asset_price_numerator": 6431399838 + }, + "oracle_input": { + "proving_cost_modifier": -189104475, + "fee_asset_price_modifier": 917409308 + }, + "outputs": { + "fee_asset_price_at_execution": 10566884406, + "mana_base_fee_components_in_wei": { + "data_cost": 35, + "gas_cost": 37260601, + "proving_cost": 5437795192, + "congestion_cost": 20336349006, + "congestion_multiplier": 4714363770 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 369, + "gas_cost": 393728463, + "proving_cost": 57460553217, + "congestion_cost": 214891849186, + "congestion_multiplier": 4714363770 + } + } + }, + { + "l1_block_number": 20973851, + "l1_fees": { + "blob_fee": 9393, + "base_fee": 10907228421 + }, + "parent_header": { + "excess_mana": 1325311084, + "mana_used": 96372911, + "proving_cost_per_mana_numerator": 224365590, + "fee_asset_price_numerator": 6431399838 + }, + "header": { + "excess_mana": 1321683995, + "mana_used": 108674213, + "proving_cost_per_mana_numerator": 293389751, + "fee_asset_price_numerator": 5928393552 + }, + "oracle_input": { + "proving_cost_modifier": 69024161, + "fee_asset_price_modifier": -503006286 + }, + "outputs": { + "fee_asset_price_at_execution": 10664272026, + "mana_base_fee_components_in_wei": { + "data_cost": 36, + "gas_cost": 36130194, + "proving_cost": 5427521795, + "congestion_cost": 20184915177, + "congestion_multiplier": 4694399842 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 383, + "gas_cost": 385302217, + "proving_cost": 57880568848, + "congestion_cost": 215257426269, + "congestion_multiplier": 4694399842 + } + } + }, + { + "l1_block_number": 20973854, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 9545453468 + }, + "parent_header": { + "excess_mana": 1321683995, + "mana_used": 108674213, + "proving_cost_per_mana_numerator": 293389751, + "fee_asset_price_numerator": 5928393552 + }, + "header": { + "excess_mana": 1330358208, + "mana_used": 97567357, + "proving_cost_per_mana_numerator": 358988705, + "fee_asset_price_numerator": 5941926306 + }, + "oracle_input": { + "proving_cost_modifier": 65598954, + "fee_asset_price_modifier": 13532754 + }, + "outputs": { + "fee_asset_price_at_execution": 10610764752, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 31619314, + "proving_cost": 5431269390, + "congestion_cost": 20443687015, + "congestion_multiplier": 4742285083 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 307, + "gas_cost": 335505102, + "proving_cost": 57629921802, + "congestion_cost": 216923153579, + "congestion_multiplier": 4742285083 + } + } + }, + { + "l1_block_number": 20973857, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 10287223911 + }, + "parent_header": { + "excess_mana": 1330358208, + "mana_used": 97567357, + "proving_cost_per_mana_numerator": 358988705, + "fee_asset_price_numerator": 5941926306 + }, + "header": { + "excess_mana": 1327925565, + "mana_used": 94180350, + "proving_cost_per_mana_numerator": 559496247, + "fee_asset_price_numerator": 5925072455 + }, + "oracle_input": { + "proving_cost_modifier": 200507542, + "fee_asset_price_modifier": -16853851 + }, + "outputs": { + "fee_asset_price_at_execution": 10612200778, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 34076429, + "proving_cost": 5434833414, + "congestion_cost": 20392508412, + "congestion_multiplier": 4728806817 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 307, + "gas_cost": 361625906, + "proving_cost": 57675543384, + "congestion_cost": 216409393635, + "congestion_multiplier": 4728806817 + } + } + }, + { + "l1_block_number": 20973860, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 10427086319 + }, + "parent_header": { + "excess_mana": 1327925565, + "mana_used": 94180350, + "proving_cost_per_mana_numerator": 559496247, + "fee_asset_price_numerator": 5925072455 + }, + "header": { + "excess_mana": 1322105915, + "mana_used": 109300669, + "proving_cost_per_mana_numerator": 478003486, + "fee_asset_price_numerator": 5647205267 + }, + "oracle_input": { + "proving_cost_modifier": -81492761, + "fee_asset_price_modifier": -277867188 + }, + "outputs": { + "fee_asset_price_at_execution": 10610412364, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 34539723, + "proving_cost": 5445741597, + "congestion_cost": 20259053557, + "congestion_multiplier": 4696717788 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 339, + "gas_cost": 366480703, + "proving_cost": 57781563971, + "congestion_cost": 214956912344, + "congestion_multiplier": 4696717788 + } + } + }, + { + "l1_block_number": 20973863, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 9924491355 + }, + "parent_header": { + "excess_mana": 1322105915, + "mana_used": 109300669, + "proving_cost_per_mana_numerator": 478003486, + "fee_asset_price_numerator": 5647205267 + }, + "header": { + "excess_mana": 1331406584, + "mana_used": 85994446, + "proving_cost_per_mana_numerator": 530330013, + "fee_asset_price_numerator": 5789146465 + }, + "oracle_input": { + "proving_cost_modifier": 52326527, + "fee_asset_price_modifier": 141941198 + }, + "outputs": { + "fee_asset_price_at_execution": 10580970433, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 32874877, + "proving_cost": 5441305520, + "congestion_cost": 20517805989, + "congestion_multiplier": 4748105538 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 359, + "gas_cost": 347848101, + "proving_cost": 57574292824, + "congestion_cost": 217098298519, + "congestion_multiplier": 4748105538 + } + } + }, + { + "l1_block_number": 20973866, + "l1_fees": { + "blob_fee": 8028, + "base_fee": 9354627250 + }, + "parent_header": { + "excess_mana": 1331406584, + "mana_used": 85994446, + "proving_cost_per_mana_numerator": 530330013, + "fee_asset_price_numerator": 5789146465 + }, + "header": { + "excess_mana": 1317401030, + "mana_used": 115714558, + "proving_cost_per_mana_numerator": 545799712, + "fee_asset_price_numerator": 6088022736 + }, + "oracle_input": { + "proving_cost_modifier": 15469699, + "fee_asset_price_modifier": 298876271 + }, + "outputs": { + "fee_asset_price_at_execution": 10595999854, + "mana_base_fee_components_in_wei": { + "data_cost": 31, + "gas_cost": 30987202, + "proving_cost": 5444153511, + "congestion_cost": 20098884264, + "congestion_multiplier": 4670934722 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 328, + "gas_cost": 328340387, + "proving_cost": 57686249807, + "congestion_cost": 212967774726, + "congestion_multiplier": 4670934722 + } + } + }, + { + "l1_block_number": 20973869, + "l1_fees": { + "blob_fee": 8028, + "base_fee": 9518637418 + }, + "parent_header": { + "excess_mana": 1317401030, + "mana_used": 115714558, + "proving_cost_per_mana_numerator": 545799712, + "fee_asset_price_numerator": 6088022736 + }, + "header": { + "excess_mana": 1333115588, + "mana_used": 80109579, + "proving_cost_per_mana_numerator": 517094254, + "fee_asset_price_numerator": 5088022736 + }, + "oracle_input": { + "proving_cost_modifier": -28705458, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10627716156, + "mana_base_fee_components_in_wei": { + "data_cost": 31, + "gas_cost": 31530486, + "proving_cost": 5444995771, + "congestion_cost": 20578644676, + "congestion_multiplier": 4757609038 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 329, + "gas_cost": 335097055, + "proving_cost": 57867869524, + "congestion_cost": 218703994491, + "congestion_multiplier": 4757609038 + } + } + }, + { + "l1_block_number": 20973872, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 9000307024 + }, + "parent_header": { + "excess_mana": 1333115588, + "mana_used": 80109579, + "proving_cost_per_mana_numerator": 517094254, + "fee_asset_price_numerator": 5088022736 + }, + "header": { + "excess_mana": 1313225167, + "mana_used": 104097263, + "proving_cost_per_mana_numerator": 663259335, + "fee_asset_price_numerator": 5536783075 + }, + "oracle_input": { + "proving_cost_modifier": 146165081, + "fee_asset_price_modifier": 448760339 + }, + "outputs": { + "fee_asset_price_at_execution": 10521968613, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 29813517, + "proving_cost": 5443432984, + "congestion_cost": 19967330046, + "congestion_multiplier": 4648169316 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 294, + "gas_cost": 313696890, + "proving_cost": 57275631004, + "congestion_cost": 210095620029, + "congestion_multiplier": 4648169316 + } + } + }, + { + "l1_block_number": 20973875, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 9715580015 + }, + "parent_header": { + "excess_mana": 1313225167, + "mana_used": 104097263, + "proving_cost_per_mana_numerator": 663259335, + "fee_asset_price_numerator": 5536783075 + }, + "header": { + "excess_mana": 1317322430, + "mana_used": 99293585, + "proving_cost_per_mana_numerator": 616335512, + "fee_asset_price_numerator": 6206207375 + }, + "oracle_input": { + "proving_cost_modifier": -46923823, + "fee_asset_price_modifier": 669424300 + }, + "outputs": { + "fee_asset_price_at_execution": 10569293142, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 32182858, + "proving_cost": 5451395200, + "congestion_cost": 20127501840, + "congestion_multiplier": 4670505193 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 295, + "gas_cost": 340150060, + "proving_cost": 57617393901, + "congestion_cost": 212733467163, + "congestion_multiplier": 4670505193 + } + } + }, + { + "l1_block_number": 20973878, + "l1_fees": { + "blob_fee": 6099, + "base_fee": 8927204530 + }, + "parent_header": { + "excess_mana": 1317322430, + "mana_used": 99293585, + "proving_cost_per_mana_numerator": 616335512, + "fee_asset_price_numerator": 6206207375 + }, + "header": { + "excess_mana": 1316616015, + "mana_used": 101973942, + "proving_cost_per_mana_numerator": 744096576, + "fee_asset_price_numerator": 6298133503 + }, + "oracle_input": { + "proving_cost_modifier": 127761064, + "fee_asset_price_modifier": 91926128 + }, + "outputs": { + "fee_asset_price_at_execution": 10640283909, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 29571365, + "proving_cost": 5448837797, + "congestion_cost": 20087390356, + "congestion_multiplier": 4666646590 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 244, + "gas_cost": 314647719, + "proving_cost": 57977181134, + "congestion_cost": 213735536378, + "congestion_multiplier": 4666646590 + } + } + }, + { + "l1_block_number": 20973881, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 10606716360 + }, + "parent_header": { + "excess_mana": 1316616015, + "mana_used": 101973942, + "proving_cost_per_mana_numerator": 744096576, + "fee_asset_price_numerator": 6298133503 + }, + "header": { + "excess_mana": 1318589957, + "mana_used": 108359431, + "proving_cost_per_mana_numerator": 823483761, + "fee_asset_price_numerator": 7008616691 + }, + "oracle_input": { + "proving_cost_modifier": 79387185, + "fee_asset_price_modifier": 710483188 + }, + "outputs": { + "fee_asset_price_at_execution": 10650069607, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 35134747, + "proving_cost": 5455803739, + "congestion_cost": 20192578903, + "congestion_multiplier": 4677436722 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 223, + "gas_cost": 374187501, + "proving_cost": 58104689582, + "congestion_cost": 215052370861, + "congestion_multiplier": 4677436722 + } + } + }, + { + "l1_block_number": 20973884, + "l1_fees": { + "blob_fee": 6597, + "base_fee": 10633601318 + }, + "parent_header": { + "excess_mana": 1318589957, + "mana_used": 108359431, + "proving_cost_per_mana_numerator": 823483761, + "fee_asset_price_numerator": 7008616691 + }, + "header": { + "excess_mana": 1326949388, + "mana_used": 93769846, + "proving_cost_per_mana_numerator": 804692960, + "fee_asset_price_numerator": 6632734847 + }, + "oracle_input": { + "proving_cost_modifier": -18790801, + "fee_asset_price_modifier": -375881844 + }, + "outputs": { + "fee_asset_price_at_execution": 10726005999, + "mana_base_fee_components_in_wei": { + "data_cost": 25, + "gas_cost": 35223804, + "proving_cost": 5460136668, + "congestion_cost": 20461474743, + "congestion_multiplier": 4723409002 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 268, + "gas_cost": 377810733, + "proving_cost": 58565458656, + "congestion_cost": 219469900841, + "congestion_multiplier": 4723409002 + } + } + }, + { + "l1_block_number": 20973887, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 10484045237 + }, + "parent_header": { + "excess_mana": 1326949388, + "mana_used": 93769846, + "proving_cost_per_mana_numerator": 804692960, + "fee_asset_price_numerator": 6632734847 + }, + "header": { + "excess_mana": 1320719234, + "mana_used": 103746665, + "proving_cost_per_mana_numerator": 679575357, + "fee_asset_price_numerator": 6735831846 + }, + "oracle_input": { + "proving_cost_modifier": -125117603, + "fee_asset_price_modifier": 103096999 + }, + "outputs": { + "fee_asset_price_at_execution": 10685764567, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 34728399, + "proving_cost": 5459110761, + "congestion_cost": 20267343728, + "congestion_multiplier": 4689103932 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 235, + "gas_cost": 371099495, + "proving_cost": 58334772337, + "congestion_cost": 216572063475, + "congestion_multiplier": 4689103932 + } + } + }, + { + "l1_block_number": 20973890, + "l1_fees": { + "blob_fee": 5012, + "base_fee": 10168986743 + }, + "parent_header": { + "excess_mana": 1320719234, + "mana_used": 103746665, + "proving_cost_per_mana_numerator": 679575357, + "fee_asset_price_numerator": 6735831846 + }, + "header": { + "excess_mana": 1324465899, + "mana_used": 90509291, + "proving_cost_per_mana_numerator": 739167168, + "fee_asset_price_numerator": 6908356568 + }, + "oracle_input": { + "proving_cost_modifier": 59591811, + "fee_asset_price_modifier": 172524722 + }, + "outputs": { + "fee_asset_price_at_execution": 10696786951, + "mana_base_fee_components_in_wei": { + "data_cost": 19, + "gas_cost": 33684768, + "proving_cost": 5452284723, + "congestion_cost": 20351324121, + "congestion_multiplier": 4709704198 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 203, + "gas_cost": 360318786, + "proving_cost": 58321928078, + "congestion_cost": 217693778293, + "congestion_multiplier": 4709704198 + } + } + }, + { + "l1_block_number": 20973893, + "l1_fees": { + "blob_fee": 5212, + "base_fee": 10173503699 + }, + "parent_header": { + "excess_mana": 1324465899, + "mana_used": 90509291, + "proving_cost_per_mana_numerator": 739167168, + "fee_asset_price_numerator": 6908356568 + }, + "header": { + "excess_mana": 1314975190, + "mana_used": 95614584, + "proving_cost_per_mana_numerator": 803144628, + "fee_asset_price_numerator": 5992437132 + }, + "oracle_input": { + "proving_cost_modifier": 63977460, + "fee_asset_price_modifier": -915919436 + }, + "outputs": { + "fee_asset_price_at_execution": 10715257481, + "mana_base_fee_components_in_wei": { + "data_cost": 20, + "gas_cost": 33699731, + "proving_cost": 5455534807, + "congestion_cost": 20077953031, + "congestion_multiplier": 4657696318 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 214, + "gas_cost": 361101294, + "proving_cost": 58457460153, + "congestion_cost": 215140436418, + "congestion_multiplier": 4657696318 + } + } + }, + { + "l1_block_number": 20973896, + "l1_fees": { + "blob_fee": 4633, + "base_fee": 9849078319 + }, + "parent_header": { + "excess_mana": 1314975190, + "mana_used": 95614584, + "proving_cost_per_mana_numerator": 803144628, + "fee_asset_price_numerator": 5992437132 + }, + "header": { + "excess_mana": 1310589774, + "mana_used": 118091830, + "proving_cost_per_mana_numerator": 902000402, + "fee_asset_price_numerator": 5439598060 + }, + "oracle_input": { + "proving_cost_modifier": 98855774, + "fee_asset_price_modifier": -552839072 + }, + "outputs": { + "fee_asset_price_at_execution": 10617562442, + "mana_base_fee_components_in_wei": { + "data_cost": 18, + "gas_cost": 32625071, + "proving_cost": 5459026236, + "congestion_cost": 19955887569, + "congestion_multiplier": 4633859178 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 191, + "gas_cost": 346398728, + "proving_cost": 57961551933, + "congestion_cost": 211882882349, + "congestion_multiplier": 4633859178 + } + } + }, + { + "l1_block_number": 20973899, + "l1_fees": { + "blob_fee": 3960, + "base_fee": 9095741753 + }, + "parent_header": { + "excess_mana": 1310589774, + "mana_used": 118091830, + "proving_cost_per_mana_numerator": 902000402, + "fee_asset_price_numerator": 5439598060 + }, + "header": { + "excess_mana": 1328681604, + "mana_used": 98625135, + "proving_cost_per_mana_numerator": 877969508, + "fee_asset_price_numerator": 5844735540 + }, + "oracle_input": { + "proving_cost_modifier": -24030894, + "fee_asset_price_modifier": 405137480 + }, + "outputs": { + "fee_asset_price_at_execution": 10559026363, + "mana_base_fee_components_in_wei": { + "data_cost": 15, + "gas_cost": 30129644, + "proving_cost": 5464425467, + "congestion_cost": 20511128175, + "congestion_multiplier": 4732991608 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 158, + "gas_cost": 318139705, + "proving_cost": 57699012564, + "congestion_cost": 216577543134, + "congestion_multiplier": 4732991608 + } + } + }, + { + "l1_block_number": 20973902, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 10224559786 + }, + "parent_header": { + "excess_mana": 1328681604, + "mana_used": 98625135, + "proving_cost_per_mana_numerator": 877969508, + "fee_asset_price_numerator": 5844735540 + }, + "header": { + "excess_mana": 1327306739, + "mana_used": 106256841, + "proving_cost_per_mana_numerator": 1003946519, + "fee_asset_price_numerator": 6652818122 + }, + "oracle_input": { + "proving_cost_modifier": 125977011, + "fee_asset_price_modifier": 808082582 + }, + "outputs": { + "fee_asset_price_at_execution": 10601891709, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 33868854, + "proving_cost": 5463112474, + "congestion_cost": 20478367886, + "congestion_multiplier": 4725384276 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 233, + "gas_cost": 359073922, + "proving_cost": 57919326843, + "congestion_cost": 217109438704, + "congestion_multiplier": 4725384276 + } + } + }, + { + "l1_block_number": 20973905, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 9839987831 + }, + "parent_header": { + "excess_mana": 1327306739, + "mana_used": 106256841, + "proving_cost_per_mana_numerator": 1003946519, + "fee_asset_price_numerator": 6652818122 + }, + "header": { + "excess_mana": 1333563580, + "mana_used": 80690418, + "proving_cost_per_mana_numerator": 944388983, + "fee_asset_price_numerator": 7269251791 + }, + "oracle_input": { + "proving_cost_modifier": -59557536, + "fee_asset_price_modifier": 616433669 + }, + "outputs": { + "fee_asset_price_at_execution": 10687910834, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 32594959, + "proving_cost": 5469999077, + "congestion_cost": 20690322611, + "congestion_multiplier": 4760103396 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 256, + "gas_cost": 348372015, + "proving_cost": 58462862397, + "congestion_cost": 221136323193, + "congestion_multiplier": 4760103396 + } + } + }, + { + "l1_block_number": 20973908, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 9805616497 + }, + "parent_header": { + "excess_mana": 1333563580, + "mana_used": 80690418, + "proving_cost_per_mana_numerator": 944388983, + "fee_asset_price_numerator": 7269251791 + }, + "header": { + "excess_mana": 1314253998, + "mana_used": 94413917, + "proving_cost_per_mana_numerator": 1122815630, + "fee_asset_price_numerator": 7087350090 + }, + "oracle_input": { + "proving_cost_modifier": 178426647, + "fee_asset_price_modifier": -181901701 + }, + "outputs": { + "fee_asset_price_at_execution": 10753998198, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 32481104, + "proving_cost": 5466742250, + "congestion_cost": 20092885494, + "congestion_multiplier": 4653767836 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 236, + "gas_cost": 349301733, + "proving_cost": 58789336305, + "congestion_cost": 216078854395, + "congestion_multiplier": 4653767836 + } + } + }, + { + "l1_block_number": 20973911, + "l1_fees": { + "blob_fee": 6861, + "base_fee": 10431780206 + }, + "parent_header": { + "excess_mana": 1314253998, + "mana_used": 94413917, + "proving_cost_per_mana_numerator": 1122815630, + "fee_asset_price_numerator": 7087350090 + }, + "header": { + "excess_mana": 1308667915, + "mana_used": 94607795, + "proving_cost_per_mana_numerator": 1062906274, + "fee_asset_price_numerator": 7390849530 + }, + "oracle_input": { + "proving_cost_modifier": -59909356, + "fee_asset_price_modifier": 303499440 + }, + "outputs": { + "fee_asset_price_at_execution": 10734454273, + "mana_base_fee_components_in_wei": { + "data_cost": 26, + "gas_cost": 34555271, + "proving_cost": 5476505082, + "congestion_cost": 19969058916, + "congestion_multiplier": 4623451304 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 279, + "gas_cost": 370931976, + "proving_cost": 58787293378, + "congestion_cost": 214356949808, + "congestion_multiplier": 4623451304 + } + } + }, + { + "l1_block_number": 20973914, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 9780268893 + }, + "parent_header": { + "excess_mana": 1308667915, + "mana_used": 94607795, + "proving_cost_per_mana_numerator": 1062906274, + "fee_asset_price_numerator": 7390849530 + }, + "header": { + "excess_mana": 1303275710, + "mana_used": 102054688, + "proving_cost_per_mana_numerator": 1109743580, + "fee_asset_price_numerator": 7115220745 + }, + "oracle_input": { + "proving_cost_modifier": 46837306, + "fee_asset_price_modifier": -275628785 + }, + "outputs": { + "fee_asset_price_at_execution": 10767082771, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 32397140, + "proving_cost": 5473225126, + "congestion_cost": 19789267384, + "congestion_multiplier": 4594374323 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 236, + "gas_cost": 348822687, + "proving_cost": 58930667955, + "congestion_cost": 213072679900, + "congestion_multiplier": 4594374323 + } + } + }, + { + "l1_block_number": 20973917, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 9759622835 + }, + "parent_header": { + "excess_mana": 1303275710, + "mana_used": 102054688, + "proving_cost_per_mana_numerator": 1109743580, + "fee_asset_price_numerator": 7115220745 + }, + "header": { + "excess_mana": 1305330398, + "mana_used": 111328474, + "proving_cost_per_mana_numerator": 1232702340, + "fee_asset_price_numerator": 6300753413 + }, + "oracle_input": { + "proving_cost_modifier": 122958760, + "fee_asset_price_modifier": -814467332 + }, + "outputs": { + "fee_asset_price_at_execution": 10737446453, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 32328750, + "proving_cost": 5475789238, + "congestion_cost": 19859147220, + "congestion_multiplier": 4605432416 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 225, + "gas_cost": 347128222, + "proving_cost": 58795993730, + "congestion_cost": 213236529876, + "congestion_multiplier": 4605432416 + } + } + }, + { + "l1_block_number": 20973920, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 9073108440 + }, + "parent_header": { + "excess_mana": 1305330398, + "mana_used": 111328474, + "proving_cost_per_mana_numerator": 1232702340, + "fee_asset_price_numerator": 6300753413 + }, + "header": { + "excess_mana": 1316658872, + "mana_used": 100397610, + "proving_cost_per_mana_numerator": 1217180126, + "fee_asset_price_numerator": 6073245524 + }, + "oracle_input": { + "proving_cost_modifier": -15522214, + "fee_asset_price_modifier": -227507889 + }, + "outputs": { + "fee_asset_price_at_execution": 10650348633, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 30054671, + "proving_cost": 5482526341, + "congestion_cost": 20213976412, + "congestion_multiplier": 4666880594 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 223, + "gas_cost": 320092724, + "proving_cost": 58390816921, + "congestion_cost": 215285896047, + "congestion_multiplier": 4666880594 + } + } + }, + { + "l1_block_number": 20973923, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 9354730809 + }, + "parent_header": { + "excess_mana": 1316658872, + "mana_used": 100397610, + "proving_cost_per_mana_numerator": 1217180126, + "fee_asset_price_numerator": 6073245524 + }, + "header": { + "excess_mana": 1317056482, + "mana_used": 124200577, + "proving_cost_per_mana_numerator": 1270767834, + "fee_asset_price_numerator": 6054705245 + }, + "oracle_input": { + "proving_cost_modifier": 53587708, + "fee_asset_price_modifier": -18540279 + }, + "outputs": { + "fee_asset_price_at_execution": 10626145791, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 30987545, + "proving_cost": 5481675398, + "congestion_cost": 20226247898, + "congestion_multiplier": 4669052149 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 233, + "gas_cost": 329278170, + "proving_cost": 58249081958, + "congestion_cost": 214927058969, + "congestion_multiplier": 4669052149 + } + } + }, + { + "l1_block_number": 20973926, + "l1_fees": { + "blob_fee": 4819, + "base_fee": 9798923863 + }, + "parent_header": { + "excess_mana": 1317056482, + "mana_used": 124200577, + "proving_cost_per_mana_numerator": 1270767834, + "fee_asset_price_numerator": 6054705245 + }, + "header": { + "excess_mana": 1341257059, + "mana_used": 90324589, + "proving_cost_per_mana_numerator": 1657418320, + "fee_asset_price_numerator": 5270904101 + }, + "oracle_input": { + "proving_cost_modifier": 386650486, + "fee_asset_price_modifier": -783801144 + }, + "outputs": { + "fee_asset_price_at_execution": 10624175857, + "mana_base_fee_components_in_wei": { + "data_cost": 18, + "gas_cost": 32458935, + "proving_cost": 5484613689, + "congestion_cost": 20982223216, + "congestion_multiplier": 4803144272 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 191, + "gas_cost": 344849433, + "proving_cost": 58269500339, + "congestion_cost": 222918829317, + "congestion_multiplier": 4803144272 + } + } + }, + { + "l1_block_number": 20973929, + "l1_fees": { + "blob_fee": 5012, + "base_fee": 9491280379 + }, + "parent_header": { + "excess_mana": 1341257059, + "mana_used": 90324589, + "proving_cost_per_mana_numerator": 1657418320, + "fee_asset_price_numerator": 5270904101 + }, + "header": { + "excess_mana": 1331581648, + "mana_used": 83908793, + "proving_cost_per_mana_numerator": 1571081596, + "fee_asset_price_numerator": 5007899122 + }, + "oracle_input": { + "proving_cost_modifier": -86336724, + "fee_asset_price_modifier": -263004979 + }, + "outputs": { + "fee_asset_price_at_execution": 10541228939, + "mana_base_fee_components_in_wei": { + "data_cost": 19, + "gas_cost": 31439866, + "proving_cost": 5505861025, + "congestion_cost": 20759773951, + "congestion_multiplier": 4749078168 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 200, + "gas_cost": 331414825, + "proving_cost": 58038541570, + "congestion_cost": 218833529939, + "congestion_multiplier": 4749078168 + } + } + }, + { + "l1_block_number": 20973932, + "l1_fees": { + "blob_fee": 4455, + "base_fee": 9788598711 + }, + "parent_header": { + "excess_mana": 1331581648, + "mana_used": 83908793, + "proving_cost_per_mana_numerator": 1571081596, + "fee_asset_price_numerator": 5007899122 + }, + "header": { + "excess_mana": 1315490441, + "mana_used": 98745137, + "proving_cost_per_mana_numerator": 1657954574, + "fee_asset_price_numerator": 4495793528 + }, + "oracle_input": { + "proving_cost_modifier": 86872978, + "fee_asset_price_modifier": -512105594 + }, + "outputs": { + "fee_asset_price_at_execution": 10513541408, + "mana_base_fee_components_in_wei": { + "data_cost": 17, + "gas_cost": 32424733, + "proving_cost": 5501109496, + "congestion_cost": 20255529924, + "congestion_multiplier": 4660505027 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 178, + "gas_cost": 340898773, + "proving_cost": 57836142476, + "congestion_cost": 212957352596, + "congestion_multiplier": 4660505027 + } + } + }, + { + "l1_block_number": 20973935, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 9503524710 + }, + "parent_header": { + "excess_mana": 1315490441, + "mana_used": 98745137, + "proving_cost_per_mana_numerator": 1657954574, + "fee_asset_price_numerator": 4495793528 + }, + "header": { + "excess_mana": 1314235578, + "mana_used": 115661879, + "proving_cost_per_mana_numerator": 1655074242, + "fee_asset_price_numerator": 4636831107 + }, + "oracle_input": { + "proving_cost_modifier": -2880332, + "fee_asset_price_modifier": 141037579 + }, + "outputs": { + "fee_asset_price_at_execution": 10459838599, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 31480425, + "proving_cost": 5505890550, + "congestion_cost": 20231712676, + "congestion_multiplier": 4653667542 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 219, + "gas_cost": 329280164, + "proving_cost": 57590726496, + "congestion_cost": 211620449172, + "congestion_multiplier": 4653667542 + } + } + }, + { + "l1_block_number": 20973938, + "l1_fees": { + "blob_fee": 4455, + "base_fee": 9905469541 + }, + "parent_header": { + "excess_mana": 1314235578, + "mana_used": 115661879, + "proving_cost_per_mana_numerator": 1655074242, + "fee_asset_price_numerator": 4636831107 + }, + "header": { + "excess_mana": 1329897457, + "mana_used": 99047538, + "proving_cost_per_mana_numerator": 1660322455, + "fee_asset_price_numerator": 3636831107 + }, + "oracle_input": { + "proving_cost_modifier": 5248213, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10474601310, + "mana_base_fee_components_in_wei": { + "data_cost": 17, + "gas_cost": 32811867, + "proving_cost": 5505731965, + "congestion_cost": 20712654750, + "congestion_multiplier": 4739729307 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 178, + "gas_cost": 343691225, + "proving_cost": 57670347253, + "congestion_cost": 216956800577, + "congestion_multiplier": 4739729307 + } + } + }, + { + "l1_block_number": 20973941, + "l1_fees": { + "blob_fee": 5864, + "base_fee": 9492348783 + }, + "parent_header": { + "excess_mana": 1329897457, + "mana_used": 99047538, + "proving_cost_per_mana_numerator": 1660322455, + "fee_asset_price_numerator": 3636831107 + }, + "header": { + "excess_mana": 1328944995, + "mana_used": 94579490, + "proving_cost_per_mana_numerator": 1590454455, + "fee_asset_price_numerator": 3398858887 + }, + "oracle_input": { + "proving_cost_modifier": -69868000, + "fee_asset_price_modifier": -237972220 + }, + "outputs": { + "fee_asset_price_at_execution": 10370377286, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 31443405, + "proving_cost": 5506020925, + "congestion_cost": 20679385896, + "congestion_multiplier": 4734450387 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 238, + "gas_cost": 326079973, + "proving_cost": 57099514336, + "congestion_cost": 214453033784, + "congestion_multiplier": 4734450387 + } + } + }, + { + "l1_block_number": 20973944, + "l1_fees": { + "blob_fee": 5421, + "base_fee": 9491302205 + }, + "parent_header": { + "excess_mana": 1328944995, + "mana_used": 94579490, + "proving_cost_per_mana_numerator": 1590454455, + "fee_asset_price_numerator": 3398858887 + }, + "header": { + "excess_mana": 1323524485, + "mana_used": 99099030, + "proving_cost_per_mana_numerator": 1570502674, + "fee_asset_price_numerator": 2562088416 + }, + "oracle_input": { + "proving_cost_modifier": -19951781, + "fee_asset_price_modifier": -836770471 + }, + "outputs": { + "fee_asset_price_at_execution": 10345728010, + "mana_base_fee_components_in_wei": { + "data_cost": 21, + "gas_cost": 31439938, + "proving_cost": 5502175322, + "congestion_cost": 20499385874, + "congestion_multiplier": 4704519529 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 217, + "gas_cost": 325269047, + "proving_cost": 56924009344, + "congestion_cost": 212081070624, + "congestion_multiplier": 4704519529 + } + } + }, + { + "l1_block_number": 20973947, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 9257844367 + }, + "parent_header": { + "excess_mana": 1323524485, + "mana_used": 99099030, + "proving_cost_per_mana_numerator": 1570502674, + "fee_asset_price_numerator": 2562088416 + }, + "header": { + "excess_mana": 1322623515, + "mana_used": 93079232, + "proving_cost_per_mana_numerator": 1555242058, + "fee_asset_price_numerator": 2926917934 + }, + "oracle_input": { + "proving_cost_modifier": -15260616, + "fee_asset_price_modifier": 364829518 + }, + "outputs": { + "fee_asset_price_at_execution": 10259519201, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 30666609, + "proving_cost": 5501077649, + "congestion_cost": 20465036161, + "congestion_multiplier": 4699562944 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 246, + "gas_cost": 314624663, + "proving_cost": 56438411766, + "congestion_cost": 209961431442, + "congestion_multiplier": 4699562944 + } + } + }, + { + "l1_block_number": 20973950, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 9626673028 + }, + "parent_header": { + "excess_mana": 1322623515, + "mana_used": 93079232, + "proving_cost_per_mana_numerator": 1555242058, + "fee_asset_price_numerator": 2926917934 + }, + "header": { + "excess_mana": 1315702747, + "mana_used": 96637310, + "proving_cost_per_mana_numerator": 1584358417, + "fee_asset_price_numerator": 3926917934 + }, + "oracle_input": { + "proving_cost_modifier": 29116359, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10297017316, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 31888354, + "proving_cost": 5500238215, + "congestion_cost": 20256782314, + "congestion_multiplier": 4661662831 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 226, + "gas_cost": 328354933, + "proving_cost": 56636048141, + "congestion_cost": 208584438253, + "congestion_multiplier": 4661662831 + } + } + }, + { + "l1_block_number": 20973953, + "l1_fees": { + "blob_fee": 6099, + "base_fee": 9541396841 + }, + "parent_header": { + "excess_mana": 1315702747, + "mana_used": 96637310, + "proving_cost_per_mana_numerator": 1584358417, + "fee_asset_price_numerator": 3926917934 + }, + "header": { + "excess_mana": 1312340057, + "mana_used": 125044278, + "proving_cost_per_mana_numerator": 1579456904, + "fee_asset_price_numerator": 3734805086 + }, + "oracle_input": { + "proving_cost_modifier": -4901513, + "fee_asset_price_modifier": -192112848 + }, + "outputs": { + "fee_asset_price_at_execution": 10400504060, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 31605877, + "proving_cost": 5501839917, + "congestion_cost": 20160325534, + "congestion_multiplier": 4643358262 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 239, + "gas_cost": 328717052, + "proving_cost": 57221908394, + "congestion_cost": 209677547567, + "congestion_multiplier": 4643358262 + } + } + }, + { + "l1_block_number": 20973956, + "l1_fees": { + "blob_fee": 6861, + "base_fee": 9340810233 + }, + "parent_header": { + "excess_mana": 1312340057, + "mana_used": 125044278, + "proving_cost_per_mana_numerator": 1579456904, + "fee_asset_price_numerator": 3734805086 + }, + "header": { + "excess_mana": 1337384335, + "mana_used": 92840403, + "proving_cost_per_mana_numerator": 1533184551, + "fee_asset_price_numerator": 4050526531 + }, + "oracle_input": { + "proving_cost_modifier": -46272353, + "fee_asset_price_modifier": 315721445 + }, + "outputs": { + "fee_asset_price_at_execution": 10380542536, + "mana_base_fee_components_in_wei": { + "data_cost": 26, + "gas_cost": 30941433, + "proving_cost": 5501570250, + "congestion_cost": 20920805967, + "congestion_multiplier": 4781430039 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 269, + "gas_cost": 321188861, + "proving_cost": 57109283994, + "congestion_cost": 217169316227, + "congestion_multiplier": 4781430039 + } + } + }, + { + "l1_block_number": 20973959, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 9311121822 + }, + "parent_header": { + "excess_mana": 1337384335, + "mana_used": 92840403, + "proving_cost_per_mana_numerator": 1533184551, + "fee_asset_price_numerator": 4050526531 + }, + "header": { + "excess_mana": 1330224738, + "mana_used": 92611181, + "proving_cost_per_mana_numerator": 1542731920, + "fee_asset_price_numerator": 3926603946 + }, + "oracle_input": { + "proving_cost_modifier": 9547369, + "fee_asset_price_modifier": -123922585 + }, + "outputs": { + "fee_asset_price_at_execution": 10413367926, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 30843091, + "proving_cost": 5499025133, + "congestion_cost": 20690248623, + "congestion_multiplier": 4741544586 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 301, + "gas_cost": 321180454, + "proving_cost": 57263371944, + "congestion_cost": 215455171391, + "congestion_multiplier": 4741544586 + } + } + }, + { + "l1_block_number": 20973962, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 9375527733 + }, + "parent_header": { + "excess_mana": 1330224738, + "mana_used": 92611181, + "proving_cost_per_mana_numerator": 1542731920, + "fee_asset_price_numerator": 3926603946 + }, + "header": { + "excess_mana": 1322835919, + "mana_used": 103198759, + "proving_cost_per_mana_numerator": 1476736516, + "fee_asset_price_numerator": 2927316841 + }, + "oracle_input": { + "proving_cost_modifier": -65995404, + "fee_asset_price_modifier": -999287105 + }, + "outputs": { + "fee_asset_price_at_execution": 10400471404, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 31056435, + "proving_cost": 5499550171, + "congestion_cost": 20467287386, + "congestion_multiplier": 4700730990 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 353, + "gas_cost": 323001564, + "proving_cost": 57197914288, + "congestion_cost": 212869437175, + "congestion_multiplier": 4700730990 + } + } + }, + { + "l1_block_number": 20973965, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 8792547319 + }, + "parent_header": { + "excess_mana": 1322835919, + "mana_used": 103198759, + "proving_cost_per_mana_numerator": 1476736516, + "fee_asset_price_numerator": 2927316841 + }, + "header": { + "excess_mana": 1326034678, + "mana_used": 92233494, + "proving_cost_per_mana_numerator": 1472519754, + "fee_asset_price_numerator": 3313885765 + }, + "oracle_input": { + "proving_cost_modifier": -4216762, + "fee_asset_price_modifier": 386568924 + }, + "outputs": { + "fee_asset_price_at_execution": 10297058391, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 29125312, + "proving_cost": 5495921918, + "congestion_cost": 20544096300, + "congestion_multiplier": 4718356663 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 329, + "gas_cost": 299905038, + "proving_cost": 56591828902, + "congestion_cost": 211543759191, + "congestion_multiplier": 4718356663 + } + } + }, + { + "l1_block_number": 20973968, + "l1_fees": { + "blob_fee": 6099, + "base_fee": 9043161445 + }, + "parent_header": { + "excess_mana": 1326034678, + "mana_used": 92233494, + "proving_cost_per_mana_numerator": 1472519754, + "fee_asset_price_numerator": 3313885765 + }, + "header": { + "excess_mana": 1318268172, + "mana_used": 101693104, + "proving_cost_per_mana_numerator": 1551966076, + "fee_asset_price_numerator": 3766445324 + }, + "oracle_input": { + "proving_cost_modifier": 79446322, + "fee_asset_price_modifier": 452559559 + }, + "outputs": { + "fee_asset_price_at_execution": 10336940656, + "mana_base_fee_components_in_wei": { + "data_cost": 23, + "gas_cost": 29955472, + "proving_cost": 5495690172, + "congestion_cost": 20310483450, + "congestion_multiplier": 4675676052 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 237, + "gas_cost": 309647936, + "proving_cost": 56808623171, + "congestion_cost": 209948262117, + "congestion_multiplier": 4675676052 + } + } + }, + { + "l1_block_number": 20973971, + "l1_fees": { + "blob_fee": 8684, + "base_fee": 8911568646 + }, + "parent_header": { + "excess_mana": 1318268172, + "mana_used": 101693104, + "proving_cost_per_mana_numerator": 1551966076, + "fee_asset_price_numerator": 3766445324 + }, + "header": { + "excess_mana": 1319961276, + "mana_used": 102102019, + "proving_cost_per_mana_numerator": 1468317618, + "fee_asset_price_numerator": 4300917324 + }, + "oracle_input": { + "proving_cost_modifier": -83648458, + "fee_asset_price_modifier": 534472000 + }, + "outputs": { + "fee_asset_price_at_execution": 10383827484, + "mana_base_fee_components_in_wei": { + "data_cost": 34, + "gas_cost": 29519571, + "proving_cost": 5500058031, + "congestion_cost": 20376202882, + "congestion_multiplier": 4684947427 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 353, + "gas_cost": 306526132, + "proving_cost": 57111653745, + "congestion_cost": 211582975505, + "congestion_multiplier": 4684947427 + } + } + }, + { + "l1_block_number": 20973974, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 9868061066 + }, + "parent_header": { + "excess_mana": 1319961276, + "mana_used": 102102019, + "proving_cost_per_mana_numerator": 1468317618, + "fee_asset_price_numerator": 4300917324 + }, + "header": { + "excess_mana": 1322063295, + "mana_used": 102474076, + "proving_cost_per_mana_numerator": 1511499768, + "fee_asset_price_numerator": 4227336050 + }, + "oracle_input": { + "proving_cost_modifier": 43182150, + "fee_asset_price_modifier": -73581274 + }, + "outputs": { + "fee_asset_price_at_execution": 10439474711, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 32687952, + "proving_cost": 5495459241, + "congestion_cost": 20434705522, + "congestion_multiplier": 4696483590 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 396, + "gas_cost": 341245048, + "proving_cost": 57369707771, + "congestion_cost": 213327591523, + "congestion_multiplier": 4696483590 + } + } + }, + { + "l1_block_number": 20973977, + "l1_fees": { + "blob_fee": 11889, + "base_fee": 10572529939 + }, + "parent_header": { + "excess_mana": 1322063295, + "mana_used": 102474076, + "proving_cost_per_mana_numerator": 1511499768, + "fee_asset_price_numerator": 4227336050 + }, + "header": { + "excess_mana": 1324537371, + "mana_used": 105245190, + "proving_cost_per_mana_numerator": 1609749354, + "fee_asset_price_numerator": 4807977124 + }, + "oracle_input": { + "proving_cost_modifier": 98249586, + "fee_asset_price_modifier": 580641074 + }, + "outputs": { + "fee_asset_price_at_execution": 10431796038, + "mana_base_fee_components_in_wei": { + "data_cost": 46, + "gas_cost": 35021505, + "proving_cost": 5497832811, + "congestion_cost": 20527432179, + "congestion_multiplier": 4710098050 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 479, + "gas_cost": 365337197, + "proving_cost": 57352270535, + "congestion_cost": 214137985675, + "congestion_multiplier": 4710098050 + } + } + }, + { + "l1_block_number": 20973980, + "l1_fees": { + "blob_fee": 13375, + "base_fee": 9920545956 + }, + "parent_header": { + "excess_mana": 1324537371, + "mana_used": 105245190, + "proving_cost_per_mana_numerator": 1609749354, + "fee_asset_price_numerator": 4807977124 + }, + "header": { + "excess_mana": 1329782561, + "mana_used": 48176168, + "proving_cost_per_mana_numerator": 1671284806, + "fee_asset_price_numerator": 4979384835 + }, + "oracle_input": { + "proving_cost_modifier": 61535452, + "fee_asset_price_modifier": 171407711 + }, + "outputs": { + "fee_asset_price_at_execution": 10492543523, + "mana_base_fee_components_in_wei": { + "data_cost": 52, + "gas_cost": 32861808, + "proving_cost": 5503237063, + "congestion_cost": 20699984279, + "congestion_multiplier": 4739092196 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 545, + "gas_cost": 344803950, + "proving_cost": 57742954400, + "congestion_cost": 217195485972, + "congestion_multiplier": 4739092196 + } + } + }, + { + "l1_block_number": 20973983, + "l1_fees": { + "blob_fee": 12860, + "base_fee": 9493896905 + }, + "parent_header": { + "excess_mana": 1329782561, + "mana_used": 48176168, + "proving_cost_per_mana_numerator": 1671284806, + "fee_asset_price_numerator": 4979384835 + }, + "header": { + "excess_mana": 1277958729, + "mana_used": 143539543, + "proving_cost_per_mana_numerator": 1636083342, + "fee_asset_price_numerator": 5620347702 + }, + "oracle_input": { + "proving_cost_modifier": -35201464, + "fee_asset_price_modifier": 640962867 + }, + "outputs": { + "fee_asset_price_at_execution": 10510543974, + "mana_base_fee_components_in_wei": { + "data_cost": 50, + "gas_cost": 31448533, + "proving_cost": 5506624547, + "congestion_cost": 19163287882, + "congestion_multiplier": 4460280757 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 525, + "gas_cost": 330541189, + "proving_cost": 57877619449, + "congestion_cost": 201416579970, + "congestion_multiplier": 4460280757 + } + } + }, + { + "l1_block_number": 20973986, + "l1_fees": { + "blob_fee": 15047, + "base_fee": 10231684676 + }, + "parent_header": { + "excess_mana": 1277958729, + "mana_used": 143539543, + "proving_cost_per_mana_numerator": 1636083342, + "fee_asset_price_numerator": 5620347702 + }, + "header": { + "excess_mana": 1321498272, + "mana_used": 106821640, + "proving_cost_per_mana_numerator": 1535185490, + "fee_asset_price_numerator": 5430436092 + }, + "oracle_input": { + "proving_cost_modifier": -100897852, + "fee_asset_price_modifier": -189911610 + }, + "outputs": { + "fee_asset_price_at_execution": 10578129024, + "mana_base_fee_components_in_wei": { + "data_cost": 59, + "gas_cost": 33892455, + "proving_cost": 5504686476, + "congestion_cost": 20456076199, + "congestion_multiplier": 4693379879 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 624, + "gas_cost": 358518761, + "proving_cost": 58229283779, + "congestion_cost": 216387013357, + "congestion_multiplier": 4693379879 + } + } + }, + { + "l1_block_number": 20973989, + "l1_fees": { + "blob_fee": 13910, + "base_fee": 10687936636 + }, + "parent_header": { + "excess_mana": 1321498272, + "mana_used": 106821640, + "proving_cost_per_mana_numerator": 1535185490, + "fee_asset_price_numerator": 5430436092 + }, + "header": { + "excess_mana": 1328319912, + "mana_used": 97504621, + "proving_cost_per_mana_numerator": 1734574868, + "fee_asset_price_numerator": 5466526012 + }, + "oracle_input": { + "proving_cost_modifier": 199389378, + "fee_asset_price_modifier": 36089920 + }, + "outputs": { + "fee_asset_price_at_execution": 10558058993, + "mana_base_fee_components_in_wei": { + "data_cost": 54, + "gas_cost": 35403790, + "proving_cost": 5499135166, + "congestion_cost": 20649304863, + "congestion_multiplier": 4730989126 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 570, + "gas_cost": 373795303, + "proving_cost": 58060193493, + "congestion_cost": 218016578907, + "congestion_multiplier": 4730989126 + } + } + }, + { + "l1_block_number": 20973992, + "l1_fees": { + "blob_fee": 12860, + "base_fee": 9937916645 + }, + "parent_header": { + "excess_mana": 1328319912, + "mana_used": 97504621, + "proving_cost_per_mana_numerator": 1734574868, + "fee_asset_price_numerator": 5466526012 + }, + "header": { + "excess_mana": 1325824533, + "mana_used": 99530321, + "proving_cost_per_mana_numerator": 1721795670, + "fee_asset_price_numerator": 6329274402 + }, + "oracle_input": { + "proving_cost_modifier": -12779198, + "fee_asset_price_modifier": 862748390 + }, + "outputs": { + "fee_asset_price_at_execution": 10561870075, + "mana_base_fee_components_in_wei": { + "data_cost": 50, + "gas_cost": 32919348, + "proving_cost": 5510110796, + "congestion_cost": 20604533572, + "congestion_multiplier": 4717196705 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 528, + "gas_cost": 347689876, + "proving_cost": 58197074326, + "congestion_cost": 217622406543, + "congestion_multiplier": 4717196705 + } + } + }, + { + "l1_block_number": 20973995, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 9399164298 + }, + "parent_header": { + "excess_mana": 1325824533, + "mana_used": 99530321, + "proving_cost_per_mana_numerator": 1721795670, + "fee_asset_price_numerator": 6329274402 + }, + "header": { + "excess_mana": 1325354854, + "mana_used": 96817789, + "proving_cost_per_mana_numerator": 1836689389, + "fee_asset_price_numerator": 7008968044 + }, + "oracle_input": { + "proving_cost_modifier": 114893719, + "fee_asset_price_modifier": 679693642 + }, + "outputs": { + "fee_asset_price_at_execution": 10653386651, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 31134731, + "proving_cost": 5509406693, + "congestion_cost": 20580924235, + "congestion_multiplier": 4714605203 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 671, + "gas_cost": 331690327, + "proving_cost": 58693839718, + "congestion_cost": 219256543510, + "congestion_multiplier": 4714605203 + } + } + }, + { + "l1_block_number": 20973998, + "l1_fees": { + "blob_fee": 16928, + "base_fee": 9340485439 + }, + "parent_header": { + "excess_mana": 1325354854, + "mana_used": 96817789, + "proving_cost_per_mana_numerator": 1836689389, + "fee_asset_price_numerator": 7008968044 + }, + "header": { + "excess_mana": 1322172643, + "mana_used": 101220698, + "proving_cost_per_mana_numerator": 1881114566, + "fee_asset_price_numerator": 7096178621 + }, + "oracle_input": { + "proving_cost_modifier": 44425177, + "fee_asset_price_modifier": 87210577 + }, + "outputs": { + "fee_asset_price_at_execution": 10726043685, + "mana_base_fee_components_in_wei": { + "data_cost": 66, + "gas_cost": 30940358, + "proving_cost": 5515740293, + "congestion_cost": 20506547210, + "congestion_multiplier": 4697084483 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 707, + "gas_cost": 331867631, + "proving_cost": 59162071337, + "congestion_cost": 219954121202, + "congestion_multiplier": 4697084483 + } + } + }, + { + "l1_block_number": 20974001, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 9254721351 + }, + "parent_header": { + "excess_mana": 1322172643, + "mana_used": 101220698, + "proving_cost_per_mana_numerator": 1881114566, + "fee_asset_price_numerator": 7096178621 + }, + "header": { + "excess_mana": 1323393341, + "mana_used": 106226548, + "proving_cost_per_mana_numerator": 1946421425, + "fee_asset_price_numerator": 6322662659 + }, + "oracle_input": { + "proving_cost_modifier": 65306859, + "fee_asset_price_modifier": -773515962 + }, + "outputs": { + "fee_asset_price_at_execution": 10735402010, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 30656264, + "proving_cost": 5518191215, + "congestion_cost": 20551808930, + "congestion_multiplier": 4703797730 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 676, + "gas_cost": 329107318, + "proving_cost": 59240001061, + "congestion_cost": 220631930896, + "congestion_multiplier": 4703797730 + } + } + }, + { + "l1_block_number": 20974004, + "l1_fees": { + "blob_fee": 15047, + "base_fee": 8967315970 + }, + "parent_header": { + "excess_mana": 1323393341, + "mana_used": 106226548, + "proving_cost_per_mana_numerator": 1946421425, + "fee_asset_price_numerator": 6322662659 + }, + "header": { + "excess_mana": 1329619889, + "mana_used": 96207687, + "proving_cost_per_mana_numerator": 1796145148, + "fee_asset_price_numerator": 6222816783 + }, + "oracle_input": { + "proving_cost_modifier": -150276277, + "fee_asset_price_modifier": -99845876 + }, + "outputs": { + "fee_asset_price_at_execution": 10652682299, + "mana_base_fee_components_in_wei": { + "data_cost": 59, + "gas_cost": 29704234, + "proving_cost": 5521796150, + "congestion_cost": 20752565150, + "congestion_multiplier": 4738190308 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 628, + "gas_cost": 316429767, + "proving_cost": 58821940105, + "congestion_cost": 221070483432, + "congestion_multiplier": 4738190308 + } + } + }, + { + "l1_block_number": 20974007, + "l1_fees": { + "blob_fee": 19806, + "base_fee": 8078456063 + }, + "parent_header": { + "excess_mana": 1329619889, + "mana_used": 96207687, + "proving_cost_per_mana_numerator": 1796145148, + "fee_asset_price_numerator": 6222816783 + }, + "header": { + "excess_mana": 1325827576, + "mana_used": 95453902, + "proving_cost_per_mana_numerator": 1888136398, + "fee_asset_price_numerator": 5673515616 + }, + "oracle_input": { + "proving_cost_modifier": 91991250, + "fee_asset_price_modifier": -549301167 + }, + "outputs": { + "fee_asset_price_at_execution": 10642051344, + "mana_base_fee_components_in_wei": { + "data_cost": 77, + "gas_cost": 26759885, + "proving_cost": 5513504432, + "congestion_cost": 20594345598, + "congestion_multiplier": 4717213500 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 819, + "gas_cost": 284780070, + "proving_cost": 58674997250, + "congestion_cost": 219166083249, + "congestion_multiplier": 4717213500 + } + } + }, + { + "l1_block_number": 20974010, + "l1_fees": { + "blob_fee": 25067, + "base_fee": 9018975363 + }, + "parent_header": { + "excess_mana": 1325827576, + "mana_used": 95453902, + "proving_cost_per_mana_numerator": 1888136398, + "fee_asset_price_numerator": 5673515616 + }, + "header": { + "excess_mana": 1321281478, + "mana_used": 104937181, + "proving_cost_per_mana_numerator": 2039920330, + "fee_asset_price_numerator": 5051607601 + }, + "oracle_input": { + "proving_cost_modifier": 151783932, + "fee_asset_price_modifier": -621908015 + }, + "outputs": { + "fee_asset_price_at_execution": 10583754690, + "mana_base_fee_components_in_wei": { + "data_cost": 98, + "gas_cost": 29875355, + "proving_cost": 5518578707, + "congestion_cost": 20485944518, + "congestion_multiplier": 4692189559 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1037, + "gas_cost": 316193428, + "proving_cost": 58407283272, + "congestion_cost": 216818211371, + "congestion_multiplier": 4692189559 + } + } + }, + { + "l1_block_number": 20974013, + "l1_fees": { + "blob_fee": 28201, + "base_fee": 9158435578 + }, + "parent_header": { + "excess_mana": 1321281478, + "mana_used": 104937181, + "proving_cost_per_mana_numerator": 2039920330, + "fee_asset_price_numerator": 5051607601 + }, + "header": { + "excess_mana": 1326218659, + "mana_used": 101453540, + "proving_cost_per_mana_numerator": 1852905038, + "fee_asset_price_numerator": 4399385648 + }, + "oracle_input": { + "proving_cost_modifier": -187015292, + "fee_asset_price_modifier": -652221953 + }, + "outputs": { + "fee_asset_price_at_execution": 10518137721, + "mana_base_fee_components_in_wei": { + "data_cost": 110, + "gas_cost": 30337317, + "proving_cost": 5526961383, + "congestion_cost": 20669664012, + "congestion_multiplier": 4719372436 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1156, + "gas_cost": 319092078, + "proving_cost": 58133341005, + "congestion_cost": 217406372725, + "congestion_multiplier": 4719372436 + } + } + }, + { + "l1_block_number": 20974016, + "l1_fees": { + "blob_fee": 37121, + "base_fee": 9951217330 + }, + "parent_header": { + "excess_mana": 1326218659, + "mana_used": 101453540, + "proving_cost_per_mana_numerator": 1852905038, + "fee_asset_price_numerator": 4399385648 + }, + "header": { + "excess_mana": 1327672199, + "mana_used": 92561346, + "proving_cost_per_mana_numerator": 1919364892, + "fee_asset_price_numerator": 4334899474 + }, + "oracle_input": { + "proving_cost_modifier": 66459854, + "fee_asset_price_modifier": -64486174 + }, + "outputs": { + "fee_asset_price_at_execution": 10449759350, + "mana_base_fee_components_in_wei": { + "data_cost": 145, + "gas_cost": 32963407, + "proving_cost": 5516634779, + "congestion_cost": 20685601821, + "congestion_multiplier": 4727405226 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1515, + "gas_cost": 344459670, + "proving_cost": 57647505862, + "congestion_cost": 216159561039, + "congestion_multiplier": 4727405226 + } + } + }, + { + "l1_block_number": 20974019, + "l1_fees": { + "blob_fee": 32996, + "base_fee": 9879258021 + }, + "parent_header": { + "excess_mana": 1327672199, + "mana_used": 92561346, + "proving_cost_per_mana_numerator": 1919364892, + "fee_asset_price_numerator": 4334899474 + }, + "header": { + "excess_mana": 1320233545, + "mana_used": 103870747, + "proving_cost_per_mana_numerator": 1888407636, + "fee_asset_price_numerator": 4717096533 + }, + "oracle_input": { + "proving_cost_modifier": -30957256, + "fee_asset_price_modifier": 382197059 + }, + "outputs": { + "fee_asset_price_at_execution": 10443022872, + "mana_base_fee_components_in_wei": { + "data_cost": 129, + "gas_cost": 32725042, + "proving_cost": 5520302345, + "congestion_cost": 20470903183, + "congestion_multiplier": 4686440077 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1347, + "gas_cost": 341748362, + "proving_cost": 57648643649, + "congestion_cost": 213778110150, + "congestion_multiplier": 4686440077 + } + } + }, + { + "l1_block_number": 20974022, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 9794908709 + }, + "parent_header": { + "excess_mana": 1320233545, + "mana_used": 103870747, + "proving_cost_per_mana_numerator": 1888407636, + "fee_asset_price_numerator": 4717096533 + }, + "header": { + "excess_mana": 1324104292, + "mana_used": 102289492, + "proving_cost_per_mana_numerator": 1853045549, + "fee_asset_price_numerator": 4428560011 + }, + "oracle_input": { + "proving_cost_modifier": -35362087, + "fee_asset_price_modifier": -288536522 + }, + "outputs": { + "fee_asset_price_at_execution": 10483012169, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 32445635, + "proving_cost": 5518593675, + "congestion_cost": 20581655781, + "congestion_multiplier": 4707712036 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1467, + "gas_cost": 340127986, + "proving_cost": 57851484650, + "congestion_cost": 215757748010, + "congestion_multiplier": 4707712036 + } + } + }, + { + "l1_block_number": 20974025, + "l1_fees": { + "blob_fee": 41761, + "base_fee": 10075139545 + }, + "parent_header": { + "excess_mana": 1324104292, + "mana_used": 102289492, + "proving_cost_per_mana_numerator": 1853045549, + "fee_asset_price_numerator": 4428560011 + }, + "header": { + "excess_mana": 1326393784, + "mana_used": 89592734, + "proving_cost_per_mana_numerator": 1892499027, + "fee_asset_price_numerator": 5175900812 + }, + "oracle_input": { + "proving_cost_modifier": 39453478, + "fee_asset_price_modifier": 747340801 + }, + "outputs": { + "fee_asset_price_at_execution": 10452808445, + "mana_base_fee_components_in_wei": { + "data_cost": 164, + "gas_cost": 33373899, + "proving_cost": 5516642530, + "congestion_cost": 20647946045, + "congestion_multiplier": 4720339516 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1714, + "gas_cost": 348850973, + "proving_cost": 57664407625, + "congestion_cost": 215829024791, + "congestion_multiplier": 4720339516 + } + } + }, + { + "l1_block_number": 20974028, + "l1_fees": { + "blob_fee": 46981, + "base_fee": 9477608461 + }, + "parent_header": { + "excess_mana": 1326393784, + "mana_used": 89592734, + "proving_cost_per_mana_numerator": 1892499027, + "fee_asset_price_numerator": 5175900812 + }, + "header": { + "excess_mana": 1315986518, + "mana_used": 102069463, + "proving_cost_per_mana_numerator": 1945964437, + "fee_asset_price_numerator": 5637447585 + }, + "oracle_input": { + "proving_cost_modifier": 53465410, + "fee_asset_price_modifier": 461546773 + }, + "outputs": { + "fee_asset_price_at_execution": 10531219180, + "mana_base_fee_components_in_wei": { + "data_cost": 184, + "gas_cost": 31394578, + "proving_cost": 5518819467, + "congestion_cost": 20331604794, + "congestion_multiplier": 4663210816 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1937, + "gas_cost": 330623181, + "proving_cost": 58119897421, + "congestion_cost": 214116586366, + "congestion_multiplier": 4663210816 + } + } + }, + { + "l1_block_number": 20974031, + "l1_fees": { + "blob_fee": 59461, + "base_fee": 9019167943 + }, + "parent_header": { + "excess_mana": 1315986518, + "mana_used": 102069463, + "proving_cost_per_mana_numerator": 1945964437, + "fee_asset_price_numerator": 5637447585 + }, + "header": { + "excess_mana": 1318055981, + "mana_used": 97994787, + "proving_cost_per_mana_numerator": 1936088689, + "fee_asset_price_numerator": 5007018649 + }, + "oracle_input": { + "proving_cost_modifier": -9875748, + "fee_asset_price_modifier": -630428936 + }, + "outputs": { + "fee_asset_price_at_execution": 10579938026, + "mana_base_fee_components_in_wei": { + "data_cost": 233, + "gas_cost": 29875993, + "proving_cost": 5521770916, + "congestion_cost": 20399612901, + "congestion_multiplier": 4674515397 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2465, + "gas_cost": 316086154, + "proving_cost": 58419994085, + "congestion_cost": 215826640246, + "congestion_multiplier": 4674515397 + } + } + }, + { + "l1_block_number": 20974034, + "l1_fees": { + "blob_fee": 72358, + "base_fee": 9324283056 + }, + "parent_header": { + "excess_mana": 1318055981, + "mana_used": 97994787, + "proving_cost_per_mana_numerator": 1936088689, + "fee_asset_price_numerator": 5007018649 + }, + "header": { + "excess_mana": 1316050768, + "mana_used": 99918209, + "proving_cost_per_mana_numerator": 1958868996, + "fee_asset_price_numerator": 5270966323 + }, + "oracle_input": { + "proving_cost_modifier": 22780307, + "fee_asset_price_modifier": 263947674 + }, + "outputs": { + "fee_asset_price_at_execution": 10513448839, + "mana_base_fee_components_in_wei": { + "data_cost": 284, + "gas_cost": 30886687, + "proving_cost": 5521225626, + "congestion_cost": 20340505260, + "congestion_multiplier": 4663561375 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2985, + "gas_cost": 324725603, + "proving_cost": 58047123147, + "congestion_cost": 213848861410, + "congestion_multiplier": 4663561375 + } + } + }, + { + "l1_block_number": 20974037, + "l1_fees": { + "blob_fee": 75255, + "base_fee": 9492816563 + }, + "parent_header": { + "excess_mana": 1316050768, + "mana_used": 99918209, + "proving_cost_per_mana_numerator": 1958868996, + "fee_asset_price_numerator": 5270966323 + }, + "header": { + "excess_mana": 1315968977, + "mana_used": 99985093, + "proving_cost_per_mana_numerator": 1994790733, + "fee_asset_price_numerator": 4558441443 + }, + "oracle_input": { + "proving_cost_modifier": 35921737, + "fee_asset_price_modifier": -712524880 + }, + "outputs": { + "fee_asset_price_at_execution": 10541235498, + "mana_base_fee_components_in_wei": { + "data_cost": 295, + "gas_cost": 31444954, + "proving_cost": 5522483522, + "congestion_cost": 20344680423, + "congestion_multiplier": 4663115114 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 3109, + "gas_cost": 331468665, + "proving_cost": 58213799339, + "congestion_cost": 214458067470, + "congestion_multiplier": 4663115114 + } + } + }, + { + "l1_block_number": 20974040, + "l1_fees": { + "blob_fee": 66894, + "base_fee": 9282090683 + }, + "parent_header": { + "excess_mana": 1315968977, + "mana_used": 99985093, + "proving_cost_per_mana_numerator": 1994790733, + "fee_asset_price_numerator": 4558441443 + }, + "header": { + "excess_mana": 1315954070, + "mana_used": 110668432, + "proving_cost_per_mana_numerator": 1762277778, + "fee_asset_price_numerator": 5018819856 + }, + "oracle_input": { + "proving_cost_modifier": -232512955, + "fee_asset_price_modifier": 460378413 + }, + "outputs": { + "fee_asset_price_at_execution": 10466393523, + "mana_base_fee_components_in_wei": { + "data_cost": 263, + "gas_cost": 30746925, + "proving_cost": 5524467650, + "congestion_cost": 20348939634, + "congestion_multiplier": 4663033785 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2752, + "gas_cost": 321809416, + "proving_cost": 57821252429, + "congestion_cost": 212980009985, + "congestion_multiplier": 4663033785 + } + } + }, + { + "l1_block_number": 20974043, + "l1_fees": { + "blob_fee": 52854, + "base_fee": 9331294615 + }, + "parent_header": { + "excess_mana": 1315954070, + "mana_used": 110668432, + "proving_cost_per_mana_numerator": 1762277778, + "fee_asset_price_numerator": 5018819856 + }, + "header": { + "excess_mana": 1326622502, + "mana_used": 94321207, + "proving_cost_per_mana_numerator": 1584325470, + "fee_asset_price_numerator": 4350620895 + }, + "oracle_input": { + "proving_cost_modifier": -177952308, + "fee_asset_price_modifier": -668198961 + }, + "outputs": { + "fee_asset_price_at_execution": 10514689627, + "mana_base_fee_components_in_wei": { + "data_cost": 207, + "gas_cost": 30909913, + "proving_cost": 5511637469, + "congestion_cost": 20627160897, + "congestion_multiplier": 4721602849 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2176, + "gas_cost": 325008141, + "proving_cost": 57953157323, + "congestion_cost": 216888194718, + "congestion_multiplier": 4721602849 + } + } + }, + { + "l1_block_number": 20974046, + "l1_fees": { + "blob_fee": 54971, + "base_fee": 9208669518 + }, + "parent_header": { + "excess_mana": 1326622502, + "mana_used": 94321207, + "proving_cost_per_mana_numerator": 1584325470, + "fee_asset_price_numerator": 4350620895 + }, + "header": { + "excess_mana": 1320943709, + "mana_used": 92582756, + "proving_cost_per_mana_numerator": 1701387963, + "fee_asset_price_numerator": 4237511017 + }, + "oracle_input": { + "proving_cost_modifier": 117062493, + "fee_asset_price_modifier": -113109878 + }, + "outputs": { + "fee_asset_price_at_execution": 10444664793, + "mana_base_fee_components_in_wei": { + "data_cost": 216, + "gas_cost": 30503717, + "proving_cost": 5501838104, + "congestion_cost": 20416198881, + "congestion_multiplier": 4690335620 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 2256, + "gas_cost": 318601099, + "proving_cost": 57464854741, + "congestion_cost": 213240353659, + "congestion_multiplier": 4690335620 + } + } + }, + { + "l1_block_number": 20974049, + "l1_fees": { + "blob_fee": 41761, + "base_fee": 9312230602 + }, + "parent_header": { + "excess_mana": 1320943709, + "mana_used": 92582756, + "proving_cost_per_mana_numerator": 1701387963, + "fee_asset_price_numerator": 4237511017 + }, + "header": { + "excess_mana": 1313526465, + "mana_used": 110100940, + "proving_cost_per_mana_numerator": 1786169668, + "fee_asset_price_numerator": 4586868437 + }, + "oracle_input": { + "proving_cost_modifier": 84781705, + "fee_asset_price_modifier": 349357420 + }, + "outputs": { + "fee_asset_price_at_execution": 10432857524, + "mana_base_fee_components_in_wei": { + "data_cost": 164, + "gas_cost": 30846763, + "proving_cost": 5508282465, + "congestion_cost": 20216759715, + "congestion_multiplier": 4649808171 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1710, + "gas_cost": 321819883, + "proving_cost": 57467126159, + "congestion_cost": 210918573703, + "congestion_multiplier": 4649808171 + } + } + }, + { + "l1_block_number": 20974052, + "l1_fees": { + "blob_fee": 41761, + "base_fee": 9243837121 + }, + "parent_header": { + "excess_mana": 1313526465, + "mana_used": 110100940, + "proving_cost_per_mana_numerator": 1786169668, + "fee_asset_price_numerator": 4586868437 + }, + "header": { + "excess_mana": 1323627405, + "mana_used": 91251238, + "proving_cost_per_mana_numerator": 1733491217, + "fee_asset_price_numerator": 4656046491 + }, + "oracle_input": { + "proving_cost_modifier": -52678451, + "fee_asset_price_modifier": 69178054 + }, + "outputs": { + "fee_asset_price_at_execution": 10469369227, + "mana_base_fee_components_in_wei": { + "data_cost": 164, + "gas_cost": 30620210, + "proving_cost": 5512954461, + "congestion_cost": 20539421871, + "congestion_multiplier": 4705086065 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1716, + "gas_cost": 320574284, + "proving_cost": 57717155783, + "congestion_cost": 215034791276, + "congestion_multiplier": 4705086065 + } + } + }, + { + "l1_block_number": 20974055, + "l1_fees": { + "blob_fee": 35692, + "base_fee": 8867356451 + }, + "parent_header": { + "excess_mana": 1323627405, + "mana_used": 91251238, + "proving_cost_per_mana_numerator": 1733491217, + "fee_asset_price_numerator": 4656046491 + }, + "header": { + "excess_mana": 1314878643, + "mana_used": 117778673, + "proving_cost_per_mana_numerator": 1558279507, + "fee_asset_price_numerator": 4221180692 + }, + "oracle_input": { + "proving_cost_modifier": -175211710, + "fee_asset_price_modifier": -434865799 + }, + "outputs": { + "fee_asset_price_at_execution": 10476614239, + "mana_base_fee_components_in_wei": { + "data_cost": 140, + "gas_cost": 29373118, + "proving_cost": 5510051086, + "congestion_cost": 20258617713, + "congestion_multiplier": 4657170214 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1466, + "gas_cost": 307730826, + "proving_cost": 57726679665, + "congestion_cost": 212241722794, + "congestion_multiplier": 4657170214 + } + } + }, + { + "l1_block_number": 20974058, + "l1_fees": { + "blob_fee": 30505, + "base_fee": 8944349837 + }, + "parent_header": { + "excess_mana": 1314878643, + "mana_used": 117778673, + "proving_cost_per_mana_numerator": 1558279507, + "fee_asset_price_numerator": 4221180692 + }, + "header": { + "excess_mana": 1332657316, + "mana_used": 94983045, + "proving_cost_per_mana_numerator": 1526777300, + "fee_asset_price_numerator": 4367616093 + }, + "oracle_input": { + "proving_cost_modifier": -31502207, + "fee_asset_price_modifier": 146435401 + }, + "outputs": { + "fee_asset_price_at_execution": 10431153944, + "mana_base_fee_components_in_wei": { + "data_cost": 119, + "gas_cost": 29628158, + "proving_cost": 5500405284, + "congestion_cost": 20765601159, + "congestion_multiplier": 4755058795 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1241, + "gas_cost": 309055877, + "proving_cost": 57375574271, + "congestion_cost": 216609182429, + "congestion_multiplier": 4755058795 + } + } + }, + { + "l1_block_number": 20974061, + "l1_fees": { + "blob_fee": 32996, + "base_fee": 9186237001 + }, + "parent_header": { + "excess_mana": 1332657316, + "mana_used": 94983045, + "proving_cost_per_mana_numerator": 1526777300, + "fee_asset_price_numerator": 4367616093 + }, + "header": { + "excess_mana": 1327640361, + "mana_used": 106363982, + "proving_cost_per_mana_numerator": 1463686342, + "fee_asset_price_numerator": 4520398689 + }, + "oracle_input": { + "proving_cost_modifier": -63090958, + "fee_asset_price_modifier": 152782596 + }, + "outputs": { + "fee_asset_price_at_execution": 10446440035, + "mana_base_fee_components_in_wei": { + "data_cost": 129, + "gas_cost": 30429410, + "proving_cost": 5498672808, + "congestion_cost": 20608231336, + "congestion_multiplier": 4727229131 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1347, + "gas_cost": 317879006, + "proving_cost": 57441555760, + "congestion_cost": 215282652878, + "congestion_multiplier": 4727229131 + } + } + }, + { + "l1_block_number": 20974064, + "l1_fees": { + "blob_fee": 28201, + "base_fee": 8647342222 + }, + "parent_header": { + "excess_mana": 1327640361, + "mana_used": 106363982, + "proving_cost_per_mana_numerator": 1463686342, + "fee_asset_price_numerator": 4520398689 + }, + "header": { + "excess_mana": 1334004343, + "mana_used": 96516464, + "proving_cost_per_mana_numerator": 1472271650, + "fee_asset_price_numerator": 4708785624 + }, + "oracle_input": { + "proving_cost_modifier": 8585308, + "fee_asset_price_modifier": 188386935 + }, + "outputs": { + "fee_asset_price_at_execution": 10462412576, + "mana_base_fee_components_in_wei": { + "data_cost": 110, + "gas_cost": 28644321, + "proving_cost": 5495204737, + "congestion_cost": 20783807180, + "congestion_multiplier": 4762558779 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1150, + "gas_cost": 299688704, + "proving_cost": 57493099148, + "congestion_cost": 217448765617, + "congestion_multiplier": 4762558779 + } + } + }, + { + "l1_block_number": 20974067, + "l1_fees": { + "blob_fee": 26071, + "base_fee": 9137278849 + }, + "parent_header": { + "excess_mana": 1334004343, + "mana_used": 96516464, + "proving_cost_per_mana_numerator": 1472271650, + "fee_asset_price_numerator": 4708785624 + }, + "header": { + "excess_mana": 1330520807, + "mana_used": 90569854, + "proving_cost_per_mana_numerator": 1289735269, + "fee_asset_price_numerator": 5085567680 + }, + "oracle_input": { + "proving_cost_modifier": -182536381, + "fee_asset_price_modifier": 376782056 + }, + "outputs": { + "fee_asset_price_at_execution": 10482140971, + "mana_base_fee_components_in_wei": { + "data_cost": 102, + "gas_cost": 30267236, + "proving_cost": 5495676537, + "congestion_cost": 20684643182, + "congestion_multiplier": 4743187345 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 1069, + "gas_cost": 317265434, + "proving_cost": 57606456191, + "congestion_cost": 216819345768, + "congestion_multiplier": 4743187345 + } + } + }, + { + "l1_block_number": 20974070, + "l1_fees": { + "blob_fee": 22282, + "base_fee": 8823926412 + }, + "parent_header": { + "excess_mana": 1330520807, + "mana_used": 90569854, + "proving_cost_per_mana_numerator": 1289735269, + "fee_asset_price_numerator": 5085567680 + }, + "header": { + "excess_mana": 1321090661, + "mana_used": 106526420, + "proving_cost_per_mana_numerator": 1281893651, + "fee_asset_price_numerator": 5053281775 + }, + "oracle_input": { + "proving_cost_modifier": -7841618, + "fee_asset_price_modifier": -32285905 + }, + "outputs": { + "fee_asset_price_at_execution": 10521710296, + "mana_base_fee_components_in_wei": { + "data_cost": 87, + "gas_cost": 29229256, + "proving_cost": 5485654079, + "congestion_cost": 20356218469, + "congestion_multiplier": 4691142117 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 915, + "gas_cost": 307541763, + "proving_cost": 57718463003, + "congestion_cost": 214182233452, + "congestion_multiplier": 4691142117 + } + } + }, + { + "l1_block_number": 20974073, + "l1_fees": { + "blob_fee": 16276, + "base_fee": 8118906685 + }, + "parent_header": { + "excess_mana": 1321090661, + "mana_used": 106526420, + "proving_cost_per_mana_numerator": 1281893651, + "fee_asset_price_numerator": 5053281775 + }, + "header": { + "excess_mana": 1327617081, + "mana_used": 109708384, + "proving_cost_per_mana_numerator": 1333514174, + "fee_asset_price_numerator": 5729363449 + }, + "oracle_input": { + "proving_cost_modifier": 51620523, + "fee_asset_price_modifier": 676081674 + }, + "outputs": { + "fee_asset_price_at_execution": 10518313815, + "mana_base_fee_components_in_wei": { + "data_cost": 63, + "gas_cost": 26893878, + "proving_cost": 5485223931, + "congestion_cost": 20544216587, + "congestion_multiplier": 4727100375 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 662, + "gas_cost": 282878248, + "proving_cost": 57695306651, + "congestion_cost": 216090517145, + "congestion_multiplier": 4727100375 + } + } + }, + { + "l1_block_number": 20974076, + "l1_fees": { + "blob_fee": 15649, + "base_fee": 8773229158 + }, + "parent_header": { + "excess_mana": 1327617081, + "mana_used": 109708384, + "proving_cost_per_mana_numerator": 1333514174, + "fee_asset_price_numerator": 5729363449 + }, + "header": { + "excess_mana": 1337325465, + "mana_used": 102116789, + "proving_cost_per_mana_numerator": 1262796025, + "fee_asset_price_numerator": 5693645457 + }, + "oracle_input": { + "proving_cost_modifier": -70718149, + "fee_asset_price_modifier": -35717992 + }, + "outputs": { + "fee_asset_price_at_execution": 10589667138, + "mana_base_fee_components_in_wei": { + "data_cost": 61, + "gas_cost": 29061321, + "proving_cost": 5488056164, + "congestion_cost": 20860777103, + "congestion_multiplier": 4781100716 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 645, + "gas_cost": 307749715, + "proving_cost": 58116688011, + "congestion_cost": 220908685760, + "congestion_multiplier": 4781100716 + } + } + }, + { + "l1_block_number": 20974079, + "l1_fees": { + "blob_fee": 14467, + "base_fee": 8811930844 + }, + "parent_header": { + "excess_mana": 1337325465, + "mana_used": 102116789, + "proving_cost_per_mana_numerator": 1262796025, + "fee_asset_price_numerator": 5693645457 + }, + "header": { + "excess_mana": 1339442254, + "mana_used": 86520455, + "proving_cost_per_mana_numerator": 1345831705, + "fee_asset_price_numerator": 5664501917 + }, + "oracle_input": { + "proving_cost_modifier": 83035680, + "fee_asset_price_modifier": -29143540 + }, + "outputs": { + "fee_asset_price_at_execution": 10585885397, + "mana_base_fee_components_in_wei": { + "data_cost": 56, + "gas_cost": 29189520, + "proving_cost": 5484176484, + "congestion_cost": 20911957474, + "congestion_multiplier": 4792956471 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 592, + "gas_cost": 308996913, + "proving_cost": 58054863756, + "congestion_cost": 221371585246, + "congestion_multiplier": 4792956471 + } + } + }, + { + "l1_block_number": 20974082, + "l1_fees": { + "blob_fee": 10568, + "base_fee": 8983995122 + }, + "parent_header": { + "excess_mana": 1339442254, + "mana_used": 86520455, + "proving_cost_per_mana_numerator": 1345831705, + "fee_asset_price_numerator": 5664501917 + }, + "header": { + "excess_mana": 1325962709, + "mana_used": 95650619, + "proving_cost_per_mana_numerator": 1431637765, + "fee_asset_price_numerator": 5095534826 + }, + "oracle_input": { + "proving_cost_modifier": 85806060, + "fee_asset_price_modifier": -568967091 + }, + "outputs": { + "fee_asset_price_at_execution": 10582800745, + "mana_base_fee_components_in_wei": { + "data_cost": 41, + "gas_cost": 29759483, + "proving_cost": 5488732198, + "congestion_cost": 20517528044, + "congestion_multiplier": 4717959377 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 433, + "gas_cost": 314938678, + "proving_cost": 58086159194, + "congestion_cost": 217132911069, + "congestion_multiplier": 4717959377 + } + } + }, + { + "l1_block_number": 20974085, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 9107507567 + }, + "parent_header": { + "excess_mana": 1325962709, + "mana_used": 95650619, + "proving_cost_per_mana_numerator": 1431637765, + "fee_asset_price_numerator": 5095534826 + }, + "header": { + "excess_mana": 1321613328, + "mana_used": 100534579, + "proving_cost_per_mana_numerator": 1304815455, + "fee_asset_price_numerator": 5440940203 + }, + "oracle_input": { + "proving_cost_modifier": -126822310, + "fee_asset_price_modifier": 345405377 + }, + "outputs": { + "fee_asset_price_at_execution": 10522759062, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 30168618, + "proving_cost": 5493443884, + "congestion_cost": 20404289476, + "congestion_multiplier": 4694011723 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 399, + "gas_cost": 317457098, + "proving_cost": 57806186411, + "congestion_cost": 214709421987, + "congestion_multiplier": 4694011723 + } + } + }, + { + "l1_block_number": 20974088, + "l1_fees": { + "blob_fee": 9770, + "base_fee": 8571228619 + }, + "parent_header": { + "excess_mana": 1321613328, + "mana_used": 100534579, + "proving_cost_per_mana_numerator": 1304815455, + "fee_asset_price_numerator": 5440940203 + }, + "header": { + "excess_mana": 1322147907, + "mana_used": 105255685, + "proving_cost_per_mana_numerator": 1331312627, + "fee_asset_price_numerator": 4921429737 + }, + "oracle_input": { + "proving_cost_modifier": 26497172, + "fee_asset_price_modifier": -519510466 + }, + "outputs": { + "fee_asset_price_at_execution": 10559168081, + "mana_base_fee_components_in_wei": { + "data_cost": 38, + "gas_cost": 28392194, + "proving_cost": 5486481388, + "congestion_cost": 20388204010, + "congestion_multiplier": 4696948546 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 401, + "gas_cost": 299797948, + "proving_cost": 57932679149, + "congestion_cost": 215282473011, + "congestion_multiplier": 4696948546 + } + } + }, + { + "l1_block_number": 20974091, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 9165139797 + }, + "parent_header": { + "excess_mana": 1322147907, + "mana_used": 105255685, + "proving_cost_per_mana_numerator": 1331312627, + "fee_asset_price_numerator": 4921429737 + }, + "header": { + "excess_mana": 1327403592, + "mana_used": 101065209, + "proving_cost_per_mana_numerator": 1299439387, + "fee_asset_price_numerator": 4946730380 + }, + "oracle_input": { + "proving_cost_modifier": -31873240, + "fee_asset_price_modifier": 25300643 + }, + "outputs": { + "fee_asset_price_at_execution": 10504454343, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 30359525, + "proving_cost": 5487935343, + "congestion_cost": 20560724103, + "congestion_multiplier": 4725919777 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 336, + "gas_cost": 318910244, + "proving_cost": 57647766247, + "congestion_cost": 215979187598, + "congestion_multiplier": 4725919777 + } + } + }, + { + "l1_block_number": 20974094, + "l1_fees": { + "blob_fee": 8350, + "base_fee": 9073892217 + }, + "parent_header": { + "excess_mana": 1327403592, + "mana_used": 101065209, + "proving_cost_per_mana_numerator": 1299439387, + "fee_asset_price_numerator": 4946730380 + }, + "header": { + "excess_mana": 1328468801, + "mana_used": 89728000, + "proving_cost_per_mana_numerator": 1308013303, + "fee_asset_price_numerator": 4925732676 + }, + "oracle_input": { + "proving_cost_modifier": 8573916, + "fee_asset_price_modifier": -20997704 + }, + "outputs": { + "fee_asset_price_at_execution": 10507112373, + "mana_base_fee_components_in_wei": { + "data_cost": 32, + "gas_cost": 30057267, + "proving_cost": 5486186439, + "congestion_cost": 20585591951, + "congestion_multiplier": 4731813337 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 336, + "gas_cost": 315815081, + "proving_cost": 57643977413, + "congestion_cost": 216295127893, + "congestion_multiplier": 4731813337 + } + } + }, + { + "l1_block_number": 20974097, + "l1_fees": { + "blob_fee": 7422, + "base_fee": 8775012304 + }, + "parent_header": { + "excess_mana": 1328468801, + "mana_used": 89728000, + "proving_cost_per_mana_numerator": 1308013303, + "fee_asset_price_numerator": 4925732676 + }, + "header": { + "excess_mana": 1318196801, + "mana_used": 110180461, + "proving_cost_per_mana_numerator": 1308611786, + "fee_asset_price_numerator": 4359061244 + }, + "oracle_input": { + "proving_cost_modifier": 598483, + "fee_asset_price_modifier": -566671432 + }, + "outputs": { + "fee_asset_price_at_execution": 10504906353, + "mana_base_fee_components_in_wei": { + "data_cost": 29, + "gas_cost": 29067228, + "proving_cost": 5486656840, + "congestion_cost": 20271861518, + "congestion_multiplier": 4675285631 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 304, + "gas_cost": 305348508, + "proving_cost": 57636816295, + "congestion_cost": 212954006847, + "congestion_multiplier": 4675285631 + } + } + }, + { + "l1_block_number": 20974100, + "l1_fees": { + "blob_fee": 7136, + "base_fee": 8687630284 + }, + "parent_header": { + "excess_mana": 1318196801, + "mana_used": 110180461, + "proving_cost_per_mana_numerator": 1308611786, + "fee_asset_price_numerator": 4359061244 + }, + "header": { + "excess_mana": 1328377262, + "mana_used": 118939145, + "proving_cost_per_mana_numerator": 1405119072, + "fee_asset_price_numerator": 3995754984 + }, + "oracle_input": { + "proving_cost_modifier": 96507286, + "fee_asset_price_modifier": -363306260 + }, + "outputs": { + "fee_asset_price_at_execution": 10445546396, + "mana_base_fee_components_in_wei": { + "data_cost": 28, + "gas_cost": 28777775, + "proving_cost": 5486689677, + "congestion_cost": 20579900121, + "congestion_multiplier": 4731306584 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 292, + "gas_cost": 300599583, + "proving_cost": 57311471581, + "congestion_cost": 214968301538, + "congestion_multiplier": 4731306584 + } + } + }, + { + "l1_block_number": 20974103, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 8779992851 + }, + "parent_header": { + "excess_mana": 1328377262, + "mana_used": 118939145, + "proving_cost_per_mana_numerator": 1405119072, + "fee_asset_price_numerator": 3995754984 + }, + "header": { + "excess_mana": 1347316407, + "mana_used": 83523832, + "proving_cost_per_mana_numerator": 1432998603, + "fee_asset_price_numerator": 4308644264 + }, + "oracle_input": { + "proving_cost_modifier": 27879531, + "fee_asset_price_modifier": 312889280 + }, + "outputs": { + "fee_asset_price_at_execution": 10407665925, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 29083726, + "proving_cost": 5491987288, + "congestion_cost": 21186098929, + "congestion_multiplier": 4837316851 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 249, + "gas_cost": 302693704, + "proving_cost": 57158768957, + "congestion_cost": 220497839907, + "congestion_multiplier": 4837316851 + } + } + }, + { + "l1_block_number": 20974106, + "l1_fees": { + "blob_fee": 6343, + "base_fee": 9971002047 + }, + "parent_header": { + "excess_mana": 1347316407, + "mana_used": 83523832, + "proving_cost_per_mana_numerator": 1432998603, + "fee_asset_price_numerator": 4308644264 + }, + "header": { + "excess_mana": 1330840239, + "mana_used": 88135080, + "proving_cost_per_mana_numerator": 1595042674, + "fee_asset_price_numerator": 4514596152 + }, + "oracle_input": { + "proving_cost_modifier": 162044071, + "fee_asset_price_modifier": 205951888 + }, + "outputs": { + "fee_asset_price_at_execution": 10440281394, + "mana_base_fee_components_in_wei": { + "data_cost": 24, + "gas_cost": 33028944, + "proving_cost": 5493518642, + "congestion_cost": 20696701798, + "congestion_multiplier": 4744960373 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 250, + "gas_cost": 344831469, + "proving_cost": 57353880465, + "congestion_cost": 216079390698, + "congestion_multiplier": 4744960373 + } + } + }, + { + "l1_block_number": 20974109, + "l1_fees": { + "blob_fee": 5638, + "base_fee": 9495549897 + }, + "parent_header": { + "excess_mana": 1330840239, + "mana_used": 88135080, + "proving_cost_per_mana_numerator": 1595042674, + "fee_asset_price_numerator": 4514596152 + }, + "header": { + "excess_mana": 1318975319, + "mana_used": 103366901, + "proving_cost_per_mana_numerator": 1576902899, + "fee_asset_price_numerator": 4393549612 + }, + "oracle_input": { + "proving_cost_modifier": -18139775, + "fee_asset_price_modifier": -121046540 + }, + "outputs": { + "fee_asset_price_at_execution": 10461805508, + "mana_base_fee_components_in_wei": { + "data_cost": 22, + "gas_cost": 31454009, + "proving_cost": 5502427779, + "congestion_cost": 20362173397, + "congestion_multiplier": 4679546130 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 230, + "gas_cost": 329065724, + "proving_cost": 57565329245, + "congestion_cost": 213025097799, + "congestion_multiplier": 4679546130 + } + } + }, + { + "l1_block_number": 20974112, + "l1_fees": { + "blob_fee": 5012, + "base_fee": 9531667424 + }, + "parent_header": { + "excess_mana": 1318975319, + "mana_used": 103366901, + "proving_cost_per_mana_numerator": 1576902899, + "fee_asset_price_numerator": 4393549612 + }, + "header": { + "excess_mana": 1322342220, + "mana_used": 105121839, + "proving_cost_per_mana_numerator": 1304053042, + "fee_asset_price_numerator": 5192433162 + }, + "oracle_input": { + "proving_cost_modifier": -272849857, + "fee_asset_price_modifier": 798883550 + }, + "outputs": { + "fee_asset_price_at_execution": 10449149516, + "mana_base_fee_components_in_wei": { + "data_cost": 19, + "gas_cost": 31573648, + "proving_cost": 5501429742, + "congestion_cost": 20461137906, + "congestion_multiplier": 4698016501 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 198, + "gas_cost": 329917768, + "proving_cost": 57485261925, + "congestion_cost": 213801489247, + "congestion_multiplier": 4698016501 + } + } + }, + { + "l1_block_number": 20974115, + "l1_fees": { + "blob_fee": 4819, + "base_fee": 10731011935 + }, + "parent_header": { + "excess_mana": 1322342220, + "mana_used": 105121839, + "proving_cost_per_mana_numerator": 1304053042, + "fee_asset_price_numerator": 5192433162 + }, + "header": { + "excess_mana": 1327464059, + "mana_used": 108840687, + "proving_cost_per_mana_numerator": 1179553844, + "fee_asset_price_numerator": 4891944810 + }, + "oracle_input": { + "proving_cost_modifier": -124499198, + "fee_asset_price_modifier": -300488352 + }, + "outputs": { + "fee_asset_price_at_execution": 10532960382, + "mana_base_fee_components_in_wei": { + "data_cost": 18, + "gas_cost": 35546477, + "proving_cost": 5486439558, + "congestion_cost": 20576323341, + "congestion_multiplier": 4726254131 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 189, + "gas_cost": 374409633, + "proving_cost": 57788450502, + "congestion_cost": 216729598557, + "congestion_multiplier": 4726254131 + } + } + }, + { + "l1_block_number": 20974118, + "l1_fees": { + "blob_fee": 5212, + "base_fee": 10880046233 + }, + "parent_header": { + "excess_mana": 1327464059, + "mana_used": 108840687, + "proving_cost_per_mana_numerator": 1179553844, + "fee_asset_price_numerator": 4891944810 + }, + "header": { + "excess_mana": 1336304746, + "mana_used": 73668457, + "proving_cost_per_mana_numerator": 1313673273, + "fee_asset_price_numerator": 4922105240 + }, + "oracle_input": { + "proving_cost_modifier": 134119429, + "fee_asset_price_modifier": 30160430 + }, + "outputs": { + "fee_asset_price_at_execution": 10501357569, + "mana_base_fee_components_in_wei": { + "data_cost": 20, + "gas_cost": 36040153, + "proving_cost": 5479613235, + "congestion_cost": 20823766635, + "congestion_multiplier": 4775394336 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 210, + "gas_cost": 378470533, + "proving_cost": 57543377920, + "congestion_cost": 218677819367, + "congestion_multiplier": 4775394336 + } + } + }, + { + "l1_block_number": 20974121, + "l1_fees": { + "blob_fee": 3960, + "base_fee": 10929199366 + }, + "parent_header": { + "excess_mana": 1336304746, + "mana_used": 73668457, + "proving_cost_per_mana_numerator": 1313673273, + "fee_asset_price_numerator": 4922105240 + }, + "header": { + "excess_mana": 1309973203, + "mana_used": 114284930, + "proving_cost_per_mana_numerator": 1217891954, + "fee_asset_price_numerator": 4382088410 + }, + "oracle_input": { + "proving_cost_modifier": -95781319, + "fee_asset_price_modifier": -540016830 + }, + "outputs": { + "fee_asset_price_at_execution": 10504525301, + "mana_base_fee_components_in_wei": { + "data_cost": 15, + "gas_cost": 36202972, + "proving_cost": 5486967392, + "congestion_cost": 20051967119, + "congestion_multiplier": 4630517573 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 157, + "gas_cost": 380295035, + "proving_cost": 57637987795, + "congestion_cost": 210636395936, + "congestion_multiplier": 4630517573 + } + } + }, + { + "l1_block_number": 20974124, + "l1_fees": { + "blob_fee": 3661, + "base_fee": 10608376541 + }, + "parent_header": { + "excess_mana": 1309973203, + "mana_used": 114284930, + "proving_cost_per_mana_numerator": 1217891954, + "fee_asset_price_numerator": 4382088410 + }, + "header": { + "excess_mana": 1324258133, + "mana_used": 104636722, + "proving_cost_per_mana_numerator": 1276217998, + "fee_asset_price_numerator": 4279528698 + }, + "oracle_input": { + "proving_cost_modifier": 58326044, + "fee_asset_price_modifier": -102559712 + }, + "outputs": { + "fee_asset_price_at_execution": 10447951986, + "mana_base_fee_components_in_wei": { + "data_cost": 14, + "gas_cost": 35140247, + "proving_cost": 5481714418, + "congestion_cost": 20459583680, + "congestion_multiplier": 4708559473 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 146, + "gas_cost": 367143613, + "proving_cost": 57272689040, + "congestion_cost": 213760747942, + "congestion_multiplier": 4708559473 + } + } + }, + { + "l1_block_number": 20974127, + "l1_fees": { + "blob_fee": 2781, + "base_fee": 10777238232 + }, + "parent_header": { + "excess_mana": 1324258133, + "mana_used": 104636722, + "proving_cost_per_mana_numerator": 1276217998, + "fee_asset_price_numerator": 4279528698 + }, + "header": { + "excess_mana": 1328894855, + "mana_used": 83656362, + "proving_cost_per_mana_numerator": 1180049967, + "fee_asset_price_numerator": 3780652926 + }, + "oracle_input": { + "proving_cost_modifier": -96168031, + "fee_asset_price_modifier": -498875772 + }, + "outputs": { + "fee_asset_price_at_execution": 10437242090, + "mana_base_fee_components_in_wei": { + "data_cost": 10, + "gas_cost": 35699601, + "proving_cost": 5484912618, + "congestion_cost": 20614919218, + "congestion_multiplier": 4734172654 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 104, + "gas_cost": 372605378, + "proving_cost": 57247360836, + "congestion_cost": 215162902544, + "congestion_multiplier": 4734172654 + } + } + }, + { + "l1_block_number": 20974130, + "l1_fees": { + "blob_fee": 2571, + "base_fee": 11304295945 + }, + "parent_header": { + "excess_mana": 1328894855, + "mana_used": 83656362, + "proving_cost_per_mana_numerator": 1180049967, + "fee_asset_price_numerator": 3780652926 + }, + "header": { + "excess_mana": 1312551217, + "mana_used": 128278391, + "proving_cost_per_mana_numerator": 1224832645, + "fee_asset_price_numerator": 3584705140 + }, + "oracle_input": { + "proving_cost_modifier": 44782678, + "fee_asset_price_modifier": -195947786 + }, + "outputs": { + "fee_asset_price_at_execution": 10385302882, + "mana_base_fee_components_in_wei": { + "data_cost": 10, + "gas_cost": 37445480, + "proving_cost": 5479640421, + "congestion_cost": 20107050382, + "congestion_multiplier": 4644505579 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 103, + "gas_cost": 388882651, + "proving_cost": 56907725456, + "congestion_cost": 208817808280, + "congestion_multiplier": 4644505579 + } + } + }, + { + "l1_block_number": 20974133, + "l1_fees": { + "blob_fee": 2285, + "base_fee": 10659083042 + }, + "parent_header": { + "excess_mana": 1312551217, + "mana_used": 128278391, + "proving_cost_per_mana_numerator": 1224832645, + "fee_asset_price_numerator": 3584705140 + }, + "header": { + "excess_mana": 1340829608, + "mana_used": 96867550, + "proving_cost_per_mana_numerator": 1260260737, + "fee_asset_price_numerator": 3246488766 + }, + "oracle_input": { + "proving_cost_modifier": 35428092, + "fee_asset_price_modifier": -338216374 + }, + "outputs": { + "fee_asset_price_at_execution": 10364973035, + "mana_base_fee_components_in_wei": { + "data_cost": 8, + "gas_cost": 35308212, + "proving_cost": 5482094900, + "congestion_cost": 20970229829, + "congestion_multiplier": 4800742736 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 82, + "gas_cost": 365968665, + "proving_cost": 56821765813, + "congestion_cost": 217355866715, + "congestion_multiplier": 4800742736 + } + } + }, + { + "l1_block_number": 20974136, + "l1_fees": { + "blob_fee": 2031, + "base_fee": 9963610155 + }, + "parent_header": { + "excess_mana": 1340829608, + "mana_used": 96867550, + "proving_cost_per_mana_numerator": 1260260737, + "fee_asset_price_numerator": 3246488766 + }, + "header": { + "excess_mana": 1337697158, + "mana_used": 89334588, + "proving_cost_per_mana_numerator": 1221780971, + "fee_asset_price_numerator": 3082804055 + }, + "oracle_input": { + "proving_cost_modifier": -38479766, + "fee_asset_price_modifier": -163684711 + }, + "outputs": { + "fee_asset_price_at_execution": 10329976215, + "mana_base_fee_components_in_wei": { + "data_cost": 7, + "gas_cost": 33004458, + "proving_cost": 5484037446, + "congestion_cost": 20871964696, + "congestion_multiplier": 4783180377 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 72, + "gas_cost": 340935266, + "proving_cost": 56649976379, + "congestion_cost": 215606898869, + "congestion_multiplier": 4783180377 + } + } + }, + { + "l1_block_number": 20974139, + "l1_fees": { + "blob_fee": 1736, + "base_fee": 10028608487 + }, + "parent_header": { + "excess_mana": 1337697158, + "mana_used": 89334588, + "proving_cost_per_mana_numerator": 1221780971, + "fee_asset_price_numerator": 3082804055 + }, + "header": { + "excess_mana": 1327031746, + "mana_used": 99486098, + "proving_cost_per_mana_numerator": 1490272456, + "fee_asset_price_numerator": 2527104241 + }, + "oracle_input": { + "proving_cost_modifier": 268491485, + "fee_asset_price_modifier": -555699814 + }, + "outputs": { + "fee_asset_price_at_execution": 10313081454, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 33219765, + "proving_cost": 5481927607, + "congestion_cost": 20537659691, + "congestion_multiplier": 4723864166 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 61, + "gas_cost": 342598142, + "proving_cost": 56535565935, + "congestion_cost": 211806557267, + "congestion_multiplier": 4723864166 + } + } + }, + { + "l1_block_number": 20974142, + "l1_fees": { + "blob_fee": 1953, + "base_fee": 9542754428 + }, + "parent_header": { + "excess_mana": 1327031746, + "mana_used": 99486098, + "proving_cost_per_mana_numerator": 1490272456, + "fee_asset_price_numerator": 2527104241 + }, + "header": { + "excess_mana": 1326517844, + "mana_used": 108694901, + "proving_cost_per_mana_numerator": 1574032256, + "fee_asset_price_numerator": 3142134000 + }, + "oracle_input": { + "proving_cost_modifier": 83759800, + "fee_asset_price_modifier": 615029759 + }, + "outputs": { + "fee_asset_price_at_execution": 10255930620, + "mana_base_fee_components_in_wei": { + "data_cost": 7, + "gas_cost": 31610374, + "proving_cost": 5496665893, + "congestion_cost": 20570852696, + "congestion_multiplier": 4721024724 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 71, + "gas_cost": 324193802, + "proving_cost": 56373424039, + "congestion_cost": 210973238044, + "congestion_multiplier": 4721024724 + } + } + }, + { + "l1_block_number": 20974145, + "l1_fees": { + "blob_fee": 1484, + "base_fee": 9528375984 + }, + "parent_header": { + "excess_mana": 1326517844, + "mana_used": 108694901, + "proving_cost_per_mana_numerator": 1574032256, + "fee_asset_price_numerator": 3142134000 + }, + "header": { + "excess_mana": 1335212745, + "mana_used": 74816411, + "proving_cost_per_mana_numerator": 1482684488, + "fee_asset_price_numerator": 3536744697 + }, + "oracle_input": { + "proving_cost_modifier": -91347768, + "fee_asset_price_modifier": 394610697 + }, + "outputs": { + "fee_asset_price_at_execution": 10319202015, + "mana_base_fee_components_in_wei": { + "data_cost": 5, + "gas_cost": 31562745, + "proving_cost": 5501271818, + "congestion_cost": 20854896694, + "congestion_multiplier": 4769296992 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 51, + "gas_cost": 325702341, + "proving_cost": 56768735229, + "congestion_cost": 215205891987, + "congestion_multiplier": 4769296992 + } + } + }, + { + "l1_block_number": 20974148, + "l1_fees": { + "blob_fee": 1543, + "base_fee": 9131788018 + }, + "parent_header": { + "excess_mana": 1335212745, + "mana_used": 74816411, + "proving_cost_per_mana_numerator": 1482684488, + "fee_asset_price_numerator": 3536744697 + }, + "header": { + "excess_mana": 1310029156, + "mana_used": 104983478, + "proving_cost_per_mana_numerator": 1414641441, + "fee_asset_price_numerator": 3308538546 + }, + "oracle_input": { + "proving_cost_modifier": -68043047, + "fee_asset_price_modifier": -228206151 + }, + "outputs": { + "fee_asset_price_at_execution": 10360003140, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 30249047, + "proving_cost": 5496248823, + "congestion_cost": 20065722997, + "congestion_multiplier": 4630820720 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 62, + "gas_cost": 313380221, + "proving_cost": 56941155064, + "congestion_cost": 207880953255, + "congestion_multiplier": 4630820720 + } + } + }, + { + "l1_block_number": 20974151, + "l1_fees": { + "blob_fee": 1543, + "base_fee": 9146141907 + }, + "parent_header": { + "excess_mana": 1310029156, + "mana_used": 104983478, + "proving_cost_per_mana_numerator": 1414641441, + "fee_asset_price_numerator": 3308538546 + }, + "header": { + "excess_mana": 1315012634, + "mana_used": 107439287, + "proving_cost_per_mana_numerator": 1389165965, + "fee_asset_price_numerator": 4165704660 + }, + "oracle_input": { + "proving_cost_modifier": -25475476, + "fee_asset_price_modifier": 857166114 + }, + "outputs": { + "fee_asset_price_at_execution": 10336387931, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 30296595, + "proving_cost": 5492510280, + "congestion_cost": 20201877350, + "congestion_multiplier": 4657900373 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 62, + "gas_cost": 313157358, + "proving_cost": 56772716969, + "congestion_cost": 208814441224, + "congestion_multiplier": 4657900373 + } + } + }, + { + "l1_block_number": 20974154, + "l1_fees": { + "blob_fee": 1605, + "base_fee": 8760412288 + }, + "parent_header": { + "excess_mana": 1315012634, + "mana_used": 107439287, + "proving_cost_per_mana_numerator": 1389165965, + "fee_asset_price_numerator": 4165704660 + }, + "header": { + "excess_mana": 1322451921, + "mana_used": 18730895, + "proving_cost_per_mana_numerator": 1407055898, + "fee_asset_price_numerator": 4506427180 + }, + "oracle_input": { + "proving_cost_modifier": 17889933, + "fee_asset_price_modifier": 340722520 + }, + "outputs": { + "fee_asset_price_at_execution": 10425368758, + "mana_base_fee_components_in_wei": { + "data_cost": 6, + "gas_cost": 29018865, + "proving_cost": 5491111215, + "congestion_cost": 20416860949, + "congestion_multiplier": 4698619531 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 62, + "gas_cost": 302532368, + "proving_cost": 57246859307, + "congestion_cost": 212853304274, + "congestion_multiplier": 4698619531 + } + } + }, + { + "l1_block_number": 20974157, + "l1_fees": { + "blob_fee": 1426, + "base_fee": 8436997127 + }, + "parent_header": { + "excess_mana": 1322451921, + "mana_used": 18730895, + "proving_cost_per_mana_numerator": 1407055898, + "fee_asset_price_numerator": 4506427180 + }, + "header": { + "excess_mana": 1241182816, + "mana_used": 157332552, + "proving_cost_per_mana_numerator": 1287220253, + "fee_asset_price_numerator": 5099720058 + }, + "oracle_input": { + "proving_cost_modifier": -119835645, + "fee_asset_price_modifier": 593292878 + }, + "outputs": { + "fee_asset_price_at_execution": 10460950921, + "mana_base_fee_components_in_wei": { + "data_cost": 5, + "gas_cost": 27947552, + "proving_cost": 5492093659, + "congestion_cost": 18063975452, + "congestion_multiplier": 4272434887 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 52, + "gas_cost": 292357969, + "proving_cost": 57452522220, + "congestion_cost": 188966360641, + "congestion_multiplier": 4272434887 + } + } + }, + { + "l1_block_number": 20974160, + "l1_fees": { + "blob_fee": 1219, + "base_fee": 10808069079 + }, + "parent_header": { + "excess_mana": 1241182816, + "mana_used": 157332552, + "proving_cost_per_mana_numerator": 1287220253, + "fee_asset_price_numerator": 5099720058 + }, + "header": { + "excess_mana": 1298515368, + "mana_used": 118327080, + "proving_cost_per_mana_numerator": 1088996923, + "fee_asset_price_numerator": 5193259556 + }, + "oracle_input": { + "proving_cost_modifier": -198223330, + "fee_asset_price_modifier": 93539498 + }, + "outputs": { + "fee_asset_price_at_execution": 10523199473, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 35801728, + "proving_cost": 5485516115, + "congestion_cost": 19704791765, + "congestion_multiplier": 4568856623 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 42, + "gas_cost": 376748725, + "proving_cost": 57725180290, + "congestion_cost": 207357454317, + "congestion_multiplier": 4568856623 + } + } + }, + { + "l1_block_number": 20974163, + "l1_fees": { + "blob_fee": 1084, + "base_fee": 10151808592 + }, + "parent_header": { + "excess_mana": 1298515368, + "mana_used": 118327080, + "proving_cost_per_mana_numerator": 1088996923, + "fee_asset_price_numerator": 5193259556 + }, + "header": { + "excess_mana": 1316842448, + "mana_used": 89473864, + "proving_cost_per_mana_numerator": 1164598933, + "fee_asset_price_numerator": 5476749594 + }, + "oracle_input": { + "proving_cost_modifier": 75602010, + "fee_asset_price_modifier": 283490038 + }, + "outputs": { + "fee_asset_price_at_execution": 10533047427, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 33627865, + "proving_cost": 5474653312, + "congestion_cost": 20203731299, + "congestion_multiplier": 4667883072 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 42, + "gas_cost": 354203896, + "proving_cost": 57664782981, + "congestion_cost": 212806859974, + "congestion_multiplier": 4667883072 + } + } + }, + { + "l1_block_number": 20974166, + "l1_fees": { + "blob_fee": 823, + "base_fee": 9893170338 + }, + "parent_header": { + "excess_mana": 1316842448, + "mana_used": 89473864, + "proving_cost_per_mana_numerator": 1164598933, + "fee_asset_price_numerator": 5476749594 + }, + "header": { + "excess_mana": 1306316312, + "mana_used": 57418796, + "proving_cost_per_mana_numerator": 1202744964, + "fee_asset_price_numerator": 5218827127 + }, + "oracle_input": { + "proving_cost_modifier": 38146031, + "fee_asset_price_modifier": -257922467 + }, + "outputs": { + "fee_asset_price_at_execution": 10562949932, + "mana_base_fee_components_in_wei": { + "data_cost": 3, + "gas_cost": 32771126, + "proving_cost": 5478793825, + "congestion_cost": 19900871787, + "congestion_multiplier": 4610747937 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 31, + "gas_cost": 346159763, + "proving_cost": 57872224861, + "congestion_cost": 210211912289, + "congestion_multiplier": 4610747937 + } + } + }, + { + "l1_block_number": 20974169, + "l1_fees": { + "blob_fee": 926, + "base_fee": 9477902554 + }, + "parent_header": { + "excess_mana": 1306316312, + "mana_used": 57418796, + "proving_cost_per_mana_numerator": 1202744964, + "fee_asset_price_numerator": 5218827127 + }, + "header": { + "excess_mana": 1263735108, + "mana_used": 144445614, + "proving_cost_per_mana_numerator": 1275483706, + "fee_asset_price_numerator": 5255608628 + }, + "oracle_input": { + "proving_cost_modifier": 72738742, + "fee_asset_price_modifier": 36781501 + }, + "outputs": { + "fee_asset_price_at_execution": 10535740815, + "mana_base_fee_components_in_wei": { + "data_cost": 3, + "gas_cost": 31395552, + "proving_cost": 5480884166, + "congestion_cost": 18668264634, + "congestion_multiplier": 4386668598 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 31, + "gas_cost": 330775398, + "proving_cost": 57745175010, + "congestion_cost": 196683997649, + "congestion_multiplier": 4386668598 + } + } + }, + { + "l1_block_number": 20974172, + "l1_fees": { + "blob_fee": 890, + "base_fee": 8894215403 + }, + "parent_header": { + "excess_mana": 1263735108, + "mana_used": 144445614, + "proving_cost_per_mana_numerator": 1275483706, + "fee_asset_price_numerator": 5255608628 + }, + "header": { + "excess_mana": 1308180722, + "mana_used": 113971510, + "proving_cost_per_mana_numerator": 1254728663, + "fee_asset_price_numerator": 4448615753 + }, + "oracle_input": { + "proving_cost_modifier": -20755043, + "fee_asset_price_modifier": -806992875 + }, + "outputs": { + "fee_asset_price_at_execution": 10539616732, + "mana_base_fee_components_in_wei": { + "data_cost": 3, + "gas_cost": 29462088, + "proving_cost": 5484872343, + "congestion_cost": 19966393739, + "congestion_multiplier": 4620816615 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 31, + "gas_cost": 310519115, + "proving_cost": 57808452319, + "congestion_cost": 210438137529, + "congestion_multiplier": 4620816615 + } + } + }, + { + "l1_block_number": 20974175, + "l1_fees": { + "blob_fee": 1042, + "base_fee": 8477418490 + }, + "parent_header": { + "excess_mana": 1308180722, + "mana_used": 113971510, + "proving_cost_per_mana_numerator": 1254728663, + "fee_asset_price_numerator": 4448615753 + }, + "header": { + "excess_mana": 1322152232, + "mana_used": 107289899, + "proving_cost_per_mana_numerator": 1284412021, + "fee_asset_price_numerator": 3610717908 + }, + "oracle_input": { + "proving_cost_modifier": 29683358, + "fee_asset_price_modifier": -837897845 + }, + "outputs": { + "fee_asset_price_at_execution": 10454905044, + "mana_base_fee_components_in_wei": { + "data_cost": 4, + "gas_cost": 28081448, + "proving_cost": 5483734073, + "congestion_cost": 20377029395, + "congestion_multiplier": 4696972314 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 41, + "gas_cost": 293588872, + "proving_cost": 57331919019, + "congestion_cost": 213039907403, + "congestion_multiplier": 4696972314 + } + } + }, + { + "l1_block_number": 20974178, + "l1_fees": { + "blob_fee": 761, + "base_fee": 9568615682 + }, + "parent_header": { + "excess_mana": 1322152232, + "mana_used": 107289899, + "proving_cost_per_mana_numerator": 1284412021, + "fee_asset_price_numerator": 3610717908 + }, + "header": { + "excess_mana": 1329442131, + "mana_used": 88045123, + "proving_cost_per_mana_numerator": 1371214073, + "fee_asset_price_numerator": 3074238422 + }, + "oracle_input": { + "proving_cost_modifier": 86802052, + "fee_asset_price_modifier": -536479486 + }, + "outputs": { + "fee_asset_price_at_execution": 10367669602, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 31696039, + "proving_cost": 5485362071, + "congestion_cost": 20618377034, + "congestion_multiplier": 4737204977 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 328614060, + "proving_cost": 56870421599, + "congestion_cost": 213764520817, + "congestion_multiplier": 4737204977 + } + } + }, + { + "l1_block_number": 20974181, + "l1_fees": { + "blob_fee": 761, + "base_fee": 9315023234 + }, + "parent_header": { + "excess_mana": 1329442131, + "mana_used": 88045123, + "proving_cost_per_mana_numerator": 1371214073, + "fee_asset_price_numerator": 3074238422 + }, + "header": { + "excess_mana": 1317487254, + "mana_used": 108329434, + "proving_cost_per_mana_numerator": 1403657471, + "fee_asset_price_numerator": 3193055101 + }, + "oracle_input": { + "proving_cost_modifier": 32443398, + "fee_asset_price_modifier": 118816679 + }, + "outputs": { + "fee_asset_price_at_execution": 10312198111, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 30856014, + "proving_cost": 5490125545, + "congestion_cost": 20269764602, + "congestion_multiplier": 4671405959 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 318193329, + "proving_cost": 56615262274, + "congestion_cost": 209025828239, + "congestion_multiplier": 4671405959 + } + } + }, + { + "l1_block_number": 20974184, + "l1_fees": { + "blob_fee": 703, + "base_fee": 9674041257 + }, + "parent_header": { + "excess_mana": 1317487254, + "mana_used": 108329434, + "proving_cost_per_mana_numerator": 1403657471, + "fee_asset_price_numerator": 3193055101 + }, + "header": { + "excess_mana": 1325816688, + "mana_used": 95514331, + "proving_cost_per_mana_numerator": 1448230411, + "fee_asset_price_numerator": 3108372249 + }, + "oracle_input": { + "proving_cost_modifier": 44572940, + "fee_asset_price_modifier": -84682852 + }, + "outputs": { + "fee_asset_price_at_execution": 10324458004, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 32045261, + "proving_cost": 5491907017, + "congestion_cost": 20533378043, + "congestion_multiplier": 4717153408 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 330849951, + "proving_cost": 56700963358, + "congestion_cost": 211995999285, + "congestion_multiplier": 4717153408 + } + } + }, + { + "l1_block_number": 20974187, + "l1_fees": { + "blob_fee": 625, + "base_fee": 10003788198 + }, + "parent_header": { + "excess_mana": 1325816688, + "mana_used": 95514331, + "proving_cost_per_mana_numerator": 1448230411, + "fee_asset_price_numerator": 3108372249 + }, + "header": { + "excess_mana": 1321331019, + "mana_used": 108247087, + "proving_cost_per_mana_numerator": 1370678469, + "fee_asset_price_numerator": 3067437500 + }, + "oracle_input": { + "proving_cost_modifier": -77551942, + "fee_asset_price_modifier": -40934749 + }, + "outputs": { + "fee_asset_price_at_execution": 10315718660, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 33137548, + "proving_cost": 5494355468, + "congestion_cost": 20410055381, + "congestion_multiplier": 4692461540 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 341837622, + "proving_cost": 56678225225, + "congestion_cost": 210544389145, + "congestion_multiplier": 4692461540 + } + } + }, + { + "l1_block_number": 20974190, + "l1_fees": { + "blob_fee": 534, + "base_fee": 9982107079 + }, + "parent_header": { + "excess_mana": 1321331019, + "mana_used": 108247087, + "proving_cost_per_mana_numerator": 1370678469, + "fee_asset_price_numerator": 3067437500 + }, + "header": { + "excess_mana": 1329578106, + "mana_used": 94836752, + "proving_cost_per_mana_numerator": 1315359805, + "fee_asset_price_numerator": 2072392464 + }, + "oracle_input": { + "proving_cost_modifier": -55318664, + "fee_asset_price_modifier": -995045036 + }, + "outputs": { + "fee_asset_price_at_execution": 10311496810, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 33065729, + "proving_cost": 5490096140, + "congestion_cost": 20645350867, + "congestion_multiplier": 4737958682 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 340957159, + "proving_cost": 56611108834, + "congestion_cost": 212884469606, + "congestion_multiplier": 4737958682 + } + } + }, + { + "l1_block_number": 20974193, + "l1_fees": { + "blob_fee": 439, + "base_fee": 9835913437 + }, + "parent_header": { + "excess_mana": 1329578106, + "mana_used": 94836752, + "proving_cost_per_mana_numerator": 1315359805, + "fee_asset_price_numerator": 2072392464 + }, + "header": { + "excess_mana": 1324414858, + "mana_used": 99286901, + "proving_cost_per_mana_numerator": 1200670532, + "fee_asset_price_numerator": 2044356545 + }, + "oracle_input": { + "proving_cost_modifier": -114689273, + "fee_asset_price_modifier": -28035919 + }, + "outputs": { + "fee_asset_price_at_execution": 10209401563, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 32581463, + "proving_cost": 5487059932, + "congestion_cost": 20474684481, + "congestion_multiplier": 4709422952 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 332637239, + "proving_cost": 56019598246, + "congestion_cost": 209034275742, + "congestion_multiplier": 4709422952 + } + } + }, + { + "l1_block_number": 20974196, + "l1_fees": { + "blob_fee": 556, + "base_fee": 10115073494 + }, + "parent_header": { + "excess_mana": 1324414858, + "mana_used": 99286901, + "proving_cost_per_mana_numerator": 1200670532, + "fee_asset_price_numerator": 2044356545 + }, + "header": { + "excess_mana": 1323701759, + "mana_used": 96289879, + "proving_cost_per_mana_numerator": 1147361388, + "fee_asset_price_numerator": 1998932862 + }, + "oracle_input": { + "proving_cost_modifier": -53309144, + "fee_asset_price_modifier": -45423683 + }, + "outputs": { + "fee_asset_price_at_execution": 10206539664, + "mana_base_fee_components_in_wei": { + "data_cost": 2, + "gas_cost": 33506180, + "proving_cost": 5480770470, + "congestion_cost": 20433126751, + "congestion_multiplier": 4705495397 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 20, + "gas_cost": 341982155, + "proving_cost": 55939701191, + "congestion_cost": 208551518643, + "congestion_multiplier": 4705495397 + } + } + }, + { + "l1_block_number": 20974199, + "l1_fees": { + "blob_fee": 475, + "base_fee": 10075372811 + }, + "parent_header": { + "excess_mana": 1323701759, + "mana_used": 96289879, + "proving_cost_per_mana_numerator": 1147361388, + "fee_asset_price_numerator": 1998932862 + }, + "header": { + "excess_mana": 1319991638, + "mana_used": 89782724, + "proving_cost_per_mana_numerator": 1200037686, + "fee_asset_price_numerator": 1805396846 + }, + "oracle_input": { + "proving_cost_modifier": 52676298, + "fee_asset_price_modifier": -193536016 + }, + "outputs": { + "fee_asset_price_at_execution": 10201904531, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 33374672, + "proving_cost": 5477849497, + "congestion_cost": 20309488552, + "congestion_multiplier": 4685113856 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 340485217, + "proving_cost": 55884497603, + "congestion_cost": 207195463280, + "congestion_multiplier": 4685113856 + } + } + }, + { + "l1_block_number": 20974202, + "l1_fees": { + "blob_fee": 439, + "base_fee": 9814380947 + }, + "parent_header": { + "excess_mana": 1319991638, + "mana_used": 89782724, + "proving_cost_per_mana_numerator": 1200037686, + "fee_asset_price_numerator": 1805396846 + }, + "header": { + "excess_mana": 1309774362, + "mana_used": 103450185, + "proving_cost_per_mana_numerator": 1346901685, + "fee_asset_price_numerator": 2325955733 + }, + "oracle_input": { + "proving_cost_modifier": 146863999, + "fee_asset_price_modifier": 520558887 + }, + "outputs": { + "fee_asset_price_at_execution": 10182179265, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 32510136, + "proving_cost": 5480735786, + "congestion_cost": 20009997686, + "congestion_multiplier": 4629440436 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 331024032, + "proving_cost": 55805834277, + "congestion_cost": 203745383531, + "congestion_multiplier": 4629440436 + } + } + }, + { + "l1_block_number": 20974205, + "l1_fees": { + "blob_fee": 333, + "base_fee": 9109952895 + }, + "parent_header": { + "excess_mana": 1309774362, + "mana_used": 103450185, + "proving_cost_per_mana_numerator": 1346901685, + "fee_asset_price_numerator": 2325955733 + }, + "header": { + "excess_mana": 1313224547, + "mana_used": 98620120, + "proving_cost_per_mana_numerator": 1479876845, + "fee_asset_price_numerator": 2117602111 + }, + "oracle_input": { + "proving_cost_modifier": 132975160, + "fee_asset_price_modifier": -208353622 + }, + "outputs": { + "fee_asset_price_at_execution": 10235321703, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 30176718, + "proving_cost": 5488790927, + "congestion_cost": 20134109812, + "congestion_multiplier": 4648165944 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 308868416, + "proving_cost": 56179540898, + "congestion_cost": 206079091129, + "congestion_multiplier": 4648165944 + } + } + }, + { + "l1_block_number": 20974208, + "l1_fees": { + "blob_fee": 347, + "base_fee": 9950819786 + }, + "parent_header": { + "excess_mana": 1313224547, + "mana_used": 98620120, + "proving_cost_per_mana_numerator": 1479876845, + "fee_asset_price_numerator": 2117602111 + }, + "header": { + "excess_mana": 1311844667, + "mana_used": 108251001, + "proving_cost_per_mana_numerator": 1268393069, + "fee_asset_price_numerator": 1217566793 + }, + "oracle_input": { + "proving_cost_modifier": -211483776, + "fee_asset_price_modifier": -900035318 + }, + "outputs": { + "fee_asset_price_at_execution": 10214018240, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 32962090, + "proving_cost": 5496094510, + "congestion_cost": 20129457900, + "congestion_multiplier": 4640667722 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 336675388, + "proving_cost": 56137209573, + "congestion_cost": 205602650151, + "congestion_multiplier": 4640667722 + } + } + }, + { + "l1_block_number": 20974211, + "l1_fees": { + "blob_fee": 263, + "base_fee": 9969692206 + }, + "parent_header": { + "excess_mana": 1311844667, + "mana_used": 108251001, + "proving_cost_per_mana_numerator": 1268393069, + "fee_asset_price_numerator": 1217566793 + }, + "header": { + "excess_mana": 1320095668, + "mana_used": 101607200, + "proving_cost_per_mana_numerator": 1217358203, + "fee_asset_price_numerator": 2217566793 + }, + "oracle_input": { + "proving_cost_modifier": -51034866, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10122500931, + "mana_base_fee_components_in_wei": { + "data_cost": 1, + "gas_cost": 33024605, + "proving_cost": 5484483444, + "congestion_cost": 20335791912, + "congestion_multiplier": 4685684140 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 10, + "gas_cost": 334291594, + "proving_cost": 55516688767, + "congestion_cost": 205849072561, + "congestion_multiplier": 4685684140 + } + } + }, + { + "l1_block_number": 20974214, + "l1_fees": { + "blob_fee": 243, + "base_fee": 9652277053 + }, + "parent_header": { + "excess_mana": 1320095668, + "mana_used": 101607200, + "proving_cost_per_mana_numerator": 1217358203, + "fee_asset_price_numerator": 2217566793 + }, + "header": { + "excess_mana": 1321702868, + "mana_used": 99783600, + "proving_cost_per_mana_numerator": 1135291698, + "fee_asset_price_numerator": 2179707139 + }, + "oracle_input": { + "proving_cost_modifier": -82066505, + "fee_asset_price_modifier": -37859654 + }, + "outputs": { + "fee_asset_price_at_execution": 10224233756, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31973167, + "proving_cost": 5481685160, + "congestion_cost": 20370229997, + "congestion_multiplier": 4694503502 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 326901133, + "proving_cost": 56046030452, + "congestion_cost": 208269993152, + "congestion_multiplier": 4694503502 + } + } + }, + { + "l1_block_number": 20974217, + "l1_fees": { + "blob_fee": 225, + "base_fee": 9865412617 + }, + "parent_header": { + "excess_mana": 1321702868, + "mana_used": 99783600, + "proving_cost_per_mana_numerator": 1135291698, + "fee_asset_price_numerator": 2179707139 + }, + "header": { + "excess_mana": 1321486468, + "mana_used": 98596813, + "proving_cost_per_mana_numerator": 1094238523, + "fee_asset_price_numerator": 1388857516 + }, + "oracle_input": { + "proving_cost_modifier": -41053175, + "fee_asset_price_modifier": -790849623 + }, + "outputs": { + "fee_asset_price_at_execution": 10220363630, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32679179, + "proving_cost": 5477188378, + "congestion_cost": 20349676832, + "congestion_multiplier": 4693315061 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 333993092, + "proving_cost": 55978856893, + "congestion_cost": 207981096976, + "congestion_multiplier": 4693315061 + } + } + }, + { + "l1_block_number": 20974220, + "l1_fees": { + "blob_fee": 253, + "base_fee": 9818833574 + }, + "parent_header": { + "excess_mana": 1321486468, + "mana_used": 98596813, + "proving_cost_per_mana_numerator": 1094238523, + "fee_asset_price_numerator": 1388857516 + }, + "header": { + "excess_mana": 1320083281, + "mana_used": 92508710, + "proving_cost_per_mana_numerator": 978809119, + "fee_asset_price_numerator": 1109991750 + }, + "oracle_input": { + "proving_cost_modifier": -115429404, + "fee_asset_price_modifier": -278865766 + }, + "outputs": { + "fee_asset_price_at_execution": 10139854694, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32524886, + "proving_cost": 5474940279, + "congestion_cost": 20298403009, + "congestion_multiplier": 4685616232 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 329797617, + "proving_cost": 55515098887, + "congestion_cost": 205822857031, + "congestion_multiplier": 4685616232 + } + } + }, + { + "l1_block_number": 20974223, + "l1_fees": { + "blob_fee": 192, + "base_fee": 9384598617 + }, + "parent_header": { + "excess_mana": 1320083281, + "mana_used": 92508710, + "proving_cost_per_mana_numerator": 978809119, + "fee_asset_price_numerator": 1109991750 + }, + "header": { + "excess_mana": 1312591991, + "mana_used": 106413231, + "proving_cost_per_mana_numerator": 816457518, + "fee_asset_price_numerator": 1325809432 + }, + "oracle_input": { + "proving_cost_modifier": -162351601, + "fee_asset_price_modifier": 215817682 + }, + "outputs": { + "fee_asset_price_at_execution": 10111617501, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31086482, + "proving_cost": 5468624234, + "congestion_cost": 20044944980, + "congestion_multiplier": 4644727153 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 314334615, + "proving_cost": 55296636510, + "congestion_cost": 202686816466, + "congestion_multiplier": 4644727153 + } + } + }, + { + "l1_block_number": 20974226, + "l1_fees": { + "blob_fee": 152, + "base_fee": 8938087949 + }, + "parent_header": { + "excess_mana": 1312591991, + "mana_used": 106413231, + "proving_cost_per_mana_numerator": 816457518, + "fee_asset_price_numerator": 1325809432 + }, + "header": { + "excess_mana": 1319005222, + "mana_used": 99107098, + "proving_cost_per_mana_numerator": 745722018, + "fee_asset_price_numerator": 1445651906 + }, + "oracle_input": { + "proving_cost_modifier": -70735500, + "fee_asset_price_modifier": 119842474 + }, + "outputs": { + "fee_asset_price_at_execution": 10133463725, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29607416, + "proving_cost": 5459753039, + "congestion_cost": 20199253758, + "congestion_multiplier": 4679709854 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 300025676, + "proving_cost": 55326209368, + "congestion_cost": 204688405228, + "congestion_multiplier": 4679709854 + } + } + }, + { + "l1_block_number": 20974229, + "l1_fees": { + "blob_fee": 185, + "base_fee": 9200504098 + }, + "parent_header": { + "excess_mana": 1319005222, + "mana_used": 99107098, + "proving_cost_per_mana_numerator": 745722018, + "fee_asset_price_numerator": 1445651906 + }, + "header": { + "excess_mana": 1318112320, + "mana_used": 103217114, + "proving_cost_per_mana_numerator": 746372879, + "fee_asset_price_numerator": 1519902006 + }, + "oracle_input": { + "proving_cost_modifier": 650861, + "fee_asset_price_modifier": 74250100 + }, + "outputs": { + "fee_asset_price_at_execution": 10145615199, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30476669, + "proving_cost": 5455892420, + "congestion_cost": 20161438249, + "congestion_multiplier": 4674823535 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 309204556, + "proving_cost": 55353385060, + "congestion_cost": 204550194332, + "congestion_multiplier": 4674823535 + } + } + }, + { + "l1_block_number": 20974232, + "l1_fees": { + "blob_fee": 140, + "base_fee": 9021763235 + }, + "parent_header": { + "excess_mana": 1318112320, + "mana_used": 103217114, + "proving_cost_per_mana_numerator": 746372879, + "fee_asset_price_numerator": 1519902006 + }, + "header": { + "excess_mana": 1321329434, + "mana_used": 84219796, + "proving_cost_per_mana_numerator": 788129718, + "fee_asset_price_numerator": 1463242432 + }, + "oracle_input": { + "proving_cost_modifier": 41756839, + "fee_asset_price_modifier": -56659574 + }, + "outputs": { + "fee_asset_price_at_execution": 10153151125, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29884590, + "proving_cost": 5455927931, + "congestion_cost": 20256104011, + "congestion_multiplier": 4692452838 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 303422758, + "proving_cost": 55394860810, + "congestion_cost": 205663285227, + "congestion_multiplier": 4692452838 + } + } + }, + { + "l1_block_number": 20974235, + "l1_fees": { + "blob_fee": 140, + "base_fee": 9164923160 + }, + "parent_header": { + "excess_mana": 1321329434, + "mana_used": 84219796, + "proving_cost_per_mana_numerator": 788129718, + "fee_asset_price_numerator": 1463242432 + }, + "header": { + "excess_mana": 1305549230, + "mana_used": 98726224, + "proving_cost_per_mana_numerator": 891349908, + "fee_asset_price_numerator": 1143970606 + }, + "oracle_input": { + "proving_cost_modifier": 103220190, + "fee_asset_price_modifier": -319271826 + }, + "outputs": { + "fee_asset_price_at_execution": 10147400023, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30358807, + "proving_cost": 5458206630, + "congestion_cost": 19795124387, + "congestion_multiplier": 4606611712 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 308062958, + "proving_cost": 55386606082, + "congestion_cost": 200869045659, + "congestion_multiplier": 4606611712 + } + } + }, + { + "l1_block_number": 20974238, + "l1_fees": { + "blob_fee": 106, + "base_fee": 8939418809 + }, + "parent_header": { + "excess_mana": 1305549230, + "mana_used": 98726224, + "proving_cost_per_mana_numerator": 891349908, + "fee_asset_price_numerator": 1143970606 + }, + "header": { + "excess_mana": 1304275454, + "mana_used": 114376447, + "proving_cost_per_mana_numerator": 917752670, + "fee_asset_price_numerator": 1702129583 + }, + "oracle_input": { + "proving_cost_modifier": 26402762, + "fee_asset_price_modifier": 558158977 + }, + "outputs": { + "fee_asset_price_at_execution": 10115053897, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29611824, + "proving_cost": 5463843510, + "congestion_cost": 19775074128, + "congestion_multiplier": 4599751509 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 299525195, + "proving_cost": 55267071588, + "congestion_cost": 200025940621, + "congestion_multiplier": 4599751509 + } + } + }, + { + "l1_block_number": 20974241, + "l1_fees": { + "blob_fee": 120, + "base_fee": 8940268760 + }, + "parent_header": { + "excess_mana": 1304275454, + "mana_used": 114376447, + "proving_cost_per_mana_numerator": 917752670, + "fee_asset_price_numerator": 1702129583 + }, + "header": { + "excess_mana": 1318651901, + "mana_used": 97571146, + "proving_cost_per_mana_numerator": 1019116089, + "fee_asset_price_numerator": 1481195032 + }, + "oracle_input": { + "proving_cost_modifier": 101363419, + "fee_asset_price_modifier": -220934551 + }, + "outputs": { + "fee_asset_price_at_execution": 10171669835, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29614640, + "proving_cost": 5465286306, + "congestion_cost": 20209013332, + "congestion_multiplier": 4677775729 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 301230340, + "proving_cost": 55591087858, + "congestion_cost": 205559411304, + "congestion_multiplier": 4677775729 + } + } + }, + { + "l1_block_number": 20974244, + "l1_fees": { + "blob_fee": 106, + "base_fee": 9460271090 + }, + "parent_header": { + "excess_mana": 1318651901, + "mana_used": 97571146, + "proving_cost_per_mana_numerator": 1019116089, + "fee_asset_price_numerator": 1481195032 + }, + "header": { + "excess_mana": 1316223047, + "mana_used": 32027503, + "proving_cost_per_mana_numerator": 1187087490, + "fee_asset_price_numerator": 1394617026 + }, + "oracle_input": { + "proving_cost_modifier": 167971401, + "fee_asset_price_modifier": -86578006 + }, + "outputs": { + "fee_asset_price_at_execution": 10149221908, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31337147, + "proving_cost": 5470828915, + "congestion_cost": 20162695715, + "congestion_multiplier": 4664501487 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318047658, + "proving_cost": 55524656679, + "congestion_cost": 204635673075, + "congestion_multiplier": 4664501487 + } + } + }, + { + "l1_block_number": 20974247, + "l1_fees": { + "blob_fee": 102, + "base_fee": 9031372745 + }, + "parent_header": { + "excess_mana": 1316223047, + "mana_used": 32027503, + "proving_cost_per_mana_numerator": 1187087490, + "fee_asset_price_numerator": 1394617026 + }, + "header": { + "excess_mana": 1248250550, + "mana_used": 145636650, + "proving_cost_per_mana_numerator": 1106794821, + "fee_asset_price_numerator": 394617026 + }, + "oracle_input": { + "proving_cost_modifier": -80292669, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10140438717, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29916422, + "proving_cost": 5480026065, + "congestion_cost": 18226400425, + "congestion_multiplier": 4307911193 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 303365643, + "proving_cost": 55569868479, + "congestion_cost": 184823696541, + "congestion_multiplier": 4307911193 + } + } + }, + { + "l1_block_number": 20974250, + "l1_fees": { + "blob_fee": 95, + "base_fee": 9218102281 + }, + "parent_header": { + "excess_mana": 1248250550, + "mana_used": 145636650, + "proving_cost_per_mana_numerator": 1106794821, + "fee_asset_price_numerator": 394617026 + }, + "header": { + "excess_mana": 1293887200, + "mana_used": 111223594, + "proving_cost_per_mana_numerator": 1143972617, + "fee_asset_price_numerator": 893140627 + }, + "oracle_input": { + "proving_cost_modifier": 37177796, + "fee_asset_price_modifier": 498523601 + }, + "outputs": { + "fee_asset_price_at_execution": 10039539666, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30534963, + "proving_cost": 5475627772, + "congestion_cost": 19514850155, + "congestion_multiplier": 4544183326 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 306556972, + "proving_cost": 54972782213, + "congestion_cost": 195920112207, + "congestion_multiplier": 4544183326 + } + } + }, + { + "l1_block_number": 20974253, + "l1_fees": { + "blob_fee": 84, + "base_fee": 8858491309 + }, + "parent_header": { + "excess_mana": 1293887200, + "mana_used": 111223594, + "proving_cost_per_mana_numerator": 1143972617, + "fee_asset_price_numerator": 893140627 + }, + "header": { + "excess_mana": 1305110794, + "mana_used": 92953174, + "proving_cost_per_mana_numerator": 1132317302, + "fee_asset_price_numerator": 1632530897 + }, + "oracle_input": { + "proving_cost_modifier": -11655315, + "fee_asset_price_modifier": 739390270 + }, + "outputs": { + "fee_asset_price_at_execution": 10089714102, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29343752, + "proving_cost": 5477663868, + "congestion_cost": 19848628161, + "congestion_multiplier": 4604249264 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 296070068, + "proving_cost": 55268062374, + "congestion_cost": 200266983461, + "congestion_multiplier": 4604249264 + } + } + }, + { + "l1_block_number": 20974256, + "l1_fees": { + "blob_fee": 95, + "base_fee": 9136766129 + }, + "parent_header": { + "excess_mana": 1305110794, + "mana_used": 92953174, + "proving_cost_per_mana_numerator": 1132317302, + "fee_asset_price_numerator": 1632530897 + }, + "header": { + "excess_mana": 1298063968, + "mana_used": 107189994, + "proving_cost_per_mana_numerator": 1165670304, + "fee_asset_price_numerator": 2616929052 + }, + "oracle_input": { + "proving_cost_modifier": 33353002, + "fee_asset_price_modifier": 984398155 + }, + "outputs": { + "fee_asset_price_at_execution": 10164592949, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30265537, + "proving_cost": 5477025467, + "congestion_cost": 19641446460, + "congestion_multiplier": 4566444273 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 307636863, + "proving_cost": 55671734443, + "congestion_cost": 199647308195, + "congestion_multiplier": 4566444273 + } + } + }, + { + "l1_block_number": 20974259, + "l1_fees": { + "blob_fee": 66, + "base_fee": 8691734272 + }, + "parent_header": { + "excess_mana": 1298063968, + "mana_used": 107189994, + "proving_cost_per_mana_numerator": 1165670304, + "fee_asset_price_numerator": 2616929052 + }, + "header": { + "excess_mana": 1305253962, + "mana_used": 112260026, + "proving_cost_per_mana_numerator": 1055123064, + "fee_asset_price_numerator": 1699841887 + }, + "oracle_input": { + "proving_cost_modifier": -110547240, + "fee_asset_price_modifier": -917087165 + }, + "outputs": { + "fee_asset_price_at_execution": 10265147129, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28791369, + "proving_cost": 5478852524, + "congestion_cost": 19855169526, + "congestion_multiplier": 4605020570 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 295547638, + "proving_cost": 56241227256, + "congestion_cost": 203816236455, + "congestion_multiplier": 4605020570 + } + } + }, + { + "l1_block_number": 20974262, + "l1_fees": { + "blob_fee": 69, + "base_fee": 8321749796 + }, + "parent_header": { + "excess_mana": 1305253962, + "mana_used": 112260026, + "proving_cost_per_mana_numerator": 1055123064, + "fee_asset_price_numerator": 1699841887 + }, + "header": { + "excess_mana": 1317513988, + "mana_used": 109487908, + "proving_cost_per_mana_numerator": 1052148096, + "fee_asset_price_numerator": 1967593911 + }, + "oracle_input": { + "proving_cost_modifier": -2974968, + "fee_asset_price_modifier": 267752024 + }, + "outputs": { + "fee_asset_price_at_execution": 10171437140, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27565796, + "proving_cost": 5472799150, + "congestion_cost": 20194876347, + "congestion_multiplier": 4671552078 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 280383761, + "proving_cost": 55666232534, + "congestion_cost": 205410915313, + "congestion_multiplier": 4671552078 + } + } + }, + { + "l1_block_number": 20974265, + "l1_fees": { + "blob_fee": 57, + "base_fee": 9442998411 + }, + "parent_header": { + "excess_mana": 1317513988, + "mana_used": 109487908, + "proving_cost_per_mana_numerator": 1052148096, + "fee_asset_price_numerator": 1967593911 + }, + "header": { + "excess_mana": 1327001896, + "mana_used": 114634510, + "proving_cost_per_mana_numerator": 960116821, + "fee_asset_price_numerator": 2366369325 + }, + "oracle_input": { + "proving_cost_modifier": -92031275, + "fee_asset_price_modifier": 398775414 + }, + "outputs": { + "fee_asset_price_at_execution": 10198707862, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31279932, + "proving_cost": 5472636338, + "congestion_cost": 20494928561, + "congestion_multiplier": 4723699191 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 319014888, + "proving_cost": 55813819246, + "congestion_cost": 209021789046, + "congestion_multiplier": 4723699191 + } + } + }, + { + "l1_block_number": 20974268, + "l1_fees": { + "blob_fee": 64, + "base_fee": 9012000240 + }, + "parent_header": { + "excess_mana": 1327001896, + "mana_used": 114634510, + "proving_cost_per_mana_numerator": 960116821, + "fee_asset_price_numerator": 2366369325 + }, + "header": { + "excess_mana": 1341636406, + "mana_used": 89366688, + "proving_cost_per_mana_numerator": 925777547, + "fee_asset_price_numerator": 2157703337 + }, + "oracle_input": { + "proving_cost_modifier": -34339274, + "fee_asset_price_modifier": -208665988 + }, + "outputs": { + "fee_asset_price_at_execution": 10239459000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29852250, + "proving_cost": 5467602118, + "congestion_cost": 20919334213, + "congestion_multiplier": 4805276554 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 305670889, + "proving_cost": 55985287715, + "congestion_cost": 214202664981, + "congestion_multiplier": 4805276554 + } + } + }, + { + "l1_block_number": 20974271, + "l1_fees": { + "blob_fee": 59, + "base_fee": 9481407782 + }, + "parent_header": { + "excess_mana": 1341636406, + "mana_used": 89366688, + "proving_cost_per_mana_numerator": 925777547, + "fee_asset_price_numerator": 2157703337 + }, + "header": { + "excess_mana": 1331003094, + "mana_used": 89635246, + "proving_cost_per_mana_numerator": 923560611, + "fee_asset_price_numerator": 1942813050 + }, + "oracle_input": { + "proving_cost_modifier": -2216936, + "fee_asset_price_modifier": -214890287 + }, + "outputs": { + "fee_asset_price_at_execution": 10218115008, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31407163, + "proving_cost": 5465724906, + "congestion_cost": 20591512231, + "congestion_multiplier": 4745864566 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 320922003, + "proving_cost": 55849405691, + "congestion_cost": 210406440164, + "congestion_multiplier": 4745864566 + } + } + }, + { + "l1_block_number": 20974274, + "l1_fees": { + "blob_fee": 54, + "base_fee": 9203478287 + }, + "parent_header": { + "excess_mana": 1331003094, + "mana_used": 89635246, + "proving_cost_per_mana_numerator": 923560611, + "fee_asset_price_numerator": 1942813050 + }, + "header": { + "excess_mana": 1320638340, + "mana_used": 91836527, + "proving_cost_per_mana_numerator": 1042882656, + "fee_asset_price_numerator": 2648789941 + }, + "oracle_input": { + "proving_cost_modifier": 119322045, + "fee_asset_price_modifier": 705976891 + }, + "outputs": { + "fee_asset_price_at_execution": 10196180847, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30486521, + "proving_cost": 5465603735, + "congestion_cost": 20273209097, + "congestion_multiplier": 4688660148 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 310846081, + "proving_cost": 55728284120, + "congestion_cost": 206709306302, + "congestion_multiplier": 4688660148 + } + } + }, + { + "l1_block_number": 20974277, + "l1_fees": { + "blob_fee": 43, + "base_fee": 9064503000 + }, + "parent_header": { + "excess_mana": 1320638340, + "mana_used": 91836527, + "proving_cost_per_mana_numerator": 1042882656, + "fee_asset_price_numerator": 2648789941 + }, + "header": { + "excess_mana": 1312474867, + "mana_used": 111243703, + "proving_cost_per_mana_numerator": 1078349352, + "fee_asset_price_numerator": 3011021132 + }, + "oracle_input": { + "proving_cost_modifier": 35466696, + "fee_asset_price_modifier": 362231191 + }, + "outputs": { + "fee_asset_price_at_execution": 10268418217, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30026166, + "proving_cost": 5472129298, + "congestion_cost": 20050353589, + "congestion_multiplier": 4644090706 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 308321229, + "proving_cost": 56190112169, + "congestion_cost": 205885416050, + "congestion_multiplier": 4644090706 + } + } + }, + { + "l1_block_number": 20974280, + "l1_fees": { + "blob_fee": 50, + "base_fee": 9027090063 + }, + "parent_header": { + "excess_mana": 1312474867, + "mana_used": 111243703, + "proving_cost_per_mana_numerator": 1078349352, + "fee_asset_price_numerator": 3011021132 + }, + "header": { + "excess_mana": 1323718570, + "mana_used": 114041429, + "proving_cost_per_mana_numerator": 1072397891, + "fee_asset_price_numerator": 3131769371 + }, + "oracle_input": { + "proving_cost_modifier": -5951461, + "fee_asset_price_modifier": 120748239 + }, + "outputs": { + "fee_asset_price_at_execution": 10305681079, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29902235, + "proving_cost": 5474070426, + "congestion_cost": 20395454769, + "congestion_multiplier": 4705587950 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 308162897, + "proving_cost": 56414024014, + "congestion_cost": 210189052310, + "congestion_multiplier": 4705587950 + } + } + }, + { + "l1_block_number": 20974283, + "l1_fees": { + "blob_fee": 38, + "base_fee": 9084972090 + }, + "parent_header": { + "excess_mana": 1323718570, + "mana_used": 114041429, + "proving_cost_per_mana_numerator": 1072397891, + "fee_asset_price_numerator": 3131769371 + }, + "header": { + "excess_mana": 1337759999, + "mana_used": 78419505, + "proving_cost_per_mana_numerator": 936551251, + "fee_asset_price_numerator": 2673481901 + }, + "oracle_input": { + "proving_cost_modifier": -135846640, + "fee_asset_price_modifier": -458287470 + }, + "outputs": { + "fee_asset_price_at_execution": 10318132524, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30093970, + "proving_cost": 5473744648, + "congestion_cost": 20823949908, + "congestion_multiplier": 4783532068 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 310513570, + "proving_cost": 56478822680, + "congestion_cost": 214864274823, + "congestion_multiplier": 4783532068 + } + } + }, + { + "l1_block_number": 20974286, + "l1_fees": { + "blob_fee": 35, + "base_fee": 8666650959 + }, + "parent_header": { + "excess_mana": 1337759999, + "mana_used": 78419505, + "proving_cost_per_mana_numerator": 936551251, + "fee_asset_price_numerator": 2673481901 + }, + "header": { + "excess_mana": 1316179504, + "mana_used": 103490229, + "proving_cost_per_mana_numerator": 998373423, + "fee_asset_price_numerator": 2663921959 + }, + "oracle_input": { + "proving_cost_modifier": 61822172, + "fee_asset_price_modifier": -9559942 + }, + "outputs": { + "fee_asset_price_at_execution": 10270954004, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28708281, + "proving_cost": 5466313799, + "congestion_cost": 20135210806, + "congestion_multiplier": 4664263858 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 294861433, + "proving_cost": 56144257600, + "congestion_cost": 206807824049, + "congestion_multiplier": 4664263858 + } + } + }, + { + "l1_block_number": 20974289, + "l1_fees": { + "blob_fee": 38, + "base_fee": 8614468929 + }, + "parent_header": { + "excess_mana": 1316179504, + "mana_used": 103490229, + "proving_cost_per_mana_numerator": 998373423, + "fee_asset_price_numerator": 2663921959 + }, + "header": { + "excess_mana": 1319669733, + "mana_used": 98929763, + "proving_cost_per_mana_numerator": 1036853456, + "fee_asset_price_numerator": 2157225896 + }, + "oracle_input": { + "proving_cost_modifier": 38480033, + "fee_asset_price_modifier": -506696063 + }, + "outputs": { + "fee_asset_price_at_execution": 10269972154, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28535428, + "proving_cost": 5469694237, + "congestion_cost": 20251902251, + "congestion_multiplier": 4683349639 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 293058050, + "proving_cost": 56173607504, + "congestion_cost": 207986472183, + "congestion_multiplier": 4683349639 + } + } + }, + { + "l1_block_number": 20974292, + "l1_fees": { + "blob_fee": 38, + "base_fee": 8495067114 + }, + "parent_header": { + "excess_mana": 1319669733, + "mana_used": 98929763, + "proving_cost_per_mana_numerator": 1036853456, + "fee_asset_price_numerator": 2157225896 + }, + "header": { + "excess_mana": 1318599496, + "mana_used": 98480109, + "proving_cost_per_mana_numerator": 1068580002, + "fee_asset_price_numerator": 2099518642 + }, + "oracle_input": { + "proving_cost_modifier": 31726546, + "fee_asset_price_modifier": -57707254 + }, + "outputs": { + "fee_asset_price_at_execution": 10218066223, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28139909, + "proving_cost": 5471799382, + "congestion_cost": 20225965830, + "congestion_multiplier": 4677488925 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 287535453, + "proving_cost": 55911208444, + "congestion_cost": 206670258275, + "congestion_multiplier": 4677488925 + } + } + }, + { + "l1_block_number": 20974295, + "l1_fees": { + "blob_fee": 35, + "base_fee": 7894600668 + }, + "parent_header": { + "excess_mana": 1318599496, + "mana_used": 98480109, + "proving_cost_per_mana_numerator": 1068580002, + "fee_asset_price_numerator": 2099518642 + }, + "header": { + "excess_mana": 1317079605, + "mana_used": 102788618, + "proving_cost_per_mana_numerator": 1126364944, + "fee_asset_price_numerator": 1862921956 + }, + "oracle_input": { + "proving_cost_modifier": 57784942, + "fee_asset_price_modifier": -236596686 + }, + "outputs": { + "fee_asset_price_at_execution": 10212171359, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 26150864, + "proving_cost": 5473535671, + "congestion_cost": 20179331409, + "congestion_multiplier": 4669178467 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 267057104, + "proving_cost": 55896684211, + "congestion_cost": 206074790258, + "congestion_multiplier": 4669178467 + } + } + }, + { + "l1_block_number": 20974298, + "l1_fees": { + "blob_fee": 29, + "base_fee": 9295653283 + }, + "parent_header": { + "excess_mana": 1317079605, + "mana_used": 102788618, + "proving_cost_per_mana_numerator": 1126364944, + "fee_asset_price_numerator": 1862921956 + }, + "header": { + "excess_mana": 1319868223, + "mana_used": 67256254, + "proving_cost_per_mana_numerator": 1099051796, + "fee_asset_price_numerator": 2373592741 + }, + "oracle_input": { + "proving_cost_modifier": -27313148, + "fee_asset_price_modifier": 510670785 + }, + "outputs": { + "fee_asset_price_at_execution": 10188038260, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30791851, + "proving_cost": 5476699464, + "congestion_cost": 20292006953, + "congestion_multiplier": 4684437395 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313708556, + "proving_cost": 55796823677, + "congestion_cost": 206735743209, + "congestion_multiplier": 4684437395 + } + } + }, + { + "l1_block_number": 20974301, + "l1_fees": { + "blob_fee": 29, + "base_fee": 8488500665 + }, + "parent_header": { + "excess_mana": 1319868223, + "mana_used": 67256254, + "proving_cost_per_mana_numerator": 1099051796, + "fee_asset_price_numerator": 2373592741 + }, + "header": { + "excess_mana": 1287124477, + "mana_used": 139548221, + "proving_cost_per_mana_numerator": 1173630933, + "fee_asset_price_numerator": 2320168027 + }, + "oracle_input": { + "proving_cost_modifier": 74579137, + "fee_asset_price_modifier": -53424714 + }, + "outputs": { + "fee_asset_price_at_execution": 10240198666, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28118158, + "proving_cost": 5475203809, + "congestion_cost": 19307688946, + "congestion_multiplier": 4508369865 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 287935524, + "proving_cost": 56067174740, + "congestion_cost": 197714570588, + "congestion_multiplier": 4508369865 + } + } + }, + { + "l1_block_number": 20974304, + "l1_fees": { + "blob_fee": 27, + "base_fee": 8290746738 + }, + "parent_header": { + "excess_mana": 1287124477, + "mana_used": 139548221, + "proving_cost_per_mana_numerator": 1173630933, + "fee_asset_price_numerator": 2320168027 + }, + "header": { + "excess_mana": 1326672698, + "mana_used": 93161620, + "proving_cost_per_mana_numerator": 1280813726, + "fee_asset_price_numerator": 2140695673 + }, + "oracle_input": { + "proving_cost_modifier": 107182793, + "fee_asset_price_modifier": -179472354 + }, + "outputs": { + "fee_asset_price_at_execution": 10234729330, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27463098, + "proving_cost": 5479288692, + "congestion_cost": 20495470194, + "congestion_multiplier": 4721880153 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 281077374, + "proving_cost": 56079036683, + "congestion_cost": 209765589926, + "congestion_multiplier": 4721880153 + } + } + }, + { + "l1_block_number": 20974307, + "l1_fees": { + "blob_fee": 24, + "base_fee": 8892201701 + }, + "parent_header": { + "excess_mana": 1326672698, + "mana_used": 93161620, + "proving_cost_per_mana_numerator": 1280813726, + "fee_asset_price_numerator": 2140695673 + }, + "header": { + "excess_mana": 1319834318, + "mana_used": 87306878, + "proving_cost_per_mana_numerator": 1345813509, + "fee_asset_price_numerator": 1808374966 + }, + "oracle_input": { + "proving_cost_modifier": 64999783, + "fee_asset_price_modifier": -332320707 + }, + "outputs": { + "fee_asset_price_at_execution": 10216377293, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29455418, + "proving_cost": 5485164695, + "congestion_cost": 20317247825, + "congestion_multiplier": 4684251573 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 300927663, + "proving_cost": 56038512038, + "congestion_cost": 207568669335, + "congestion_multiplier": 4684251573 + } + } + }, + { + "l1_block_number": 20974310, + "l1_fees": { + "blob_fee": 23, + "base_fee": 8265977323 + }, + "parent_header": { + "excess_mana": 1319834318, + "mana_used": 87306878, + "proving_cost_per_mana_numerator": 1345813509, + "fee_asset_price_numerator": 1808374966 + }, + "header": { + "excess_mana": 1307141196, + "mana_used": 108136345, + "proving_cost_per_mana_numerator": 1474632566, + "fee_asset_price_numerator": 1328322599 + }, + "oracle_input": { + "proving_cost_modifier": 128819057, + "fee_asset_price_modifier": -480052367 + }, + "outputs": { + "fee_asset_price_at_execution": 10182482507, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27381049, + "proving_cost": 5488731199, + "congestion_cost": 19941848910, + "congestion_multiplier": 4615199984 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 278807052, + "proving_cost": 55888909419, + "congestion_cost": 203057527683, + "congestion_multiplier": 4615199984 + } + } + }, + { + "l1_block_number": 20974313, + "l1_fees": { + "blob_fee": 22, + "base_fee": 9126618125 + }, + "parent_header": { + "excess_mana": 1307141196, + "mana_used": 108136345, + "proving_cost_per_mana_numerator": 1474632566, + "fee_asset_price_numerator": 1328322599 + }, + "header": { + "excess_mana": 1315277541, + "mana_used": 110084780, + "proving_cost_per_mana_numerator": 1508104099, + "fee_asset_price_numerator": 1315266421 + }, + "oracle_input": { + "proving_cost_modifier": 33471533, + "fee_asset_price_modifier": -13056178 + }, + "outputs": { + "fee_asset_price_at_execution": 10133718399, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30231922, + "proving_cost": 5495806287, + "congestion_cost": 20221676266, + "congestion_multiplier": 4659344272 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 306361784, + "proving_cost": 55692953287, + "congestion_cost": 204920772835, + "congestion_multiplier": 4659344272 + } + } + }, + { + "l1_block_number": 20974316, + "l1_fees": { + "blob_fee": 24, + "base_fee": 9501279935 + }, + "parent_header": { + "excess_mana": 1315277541, + "mana_used": 110084780, + "proving_cost_per_mana_numerator": 1508104099, + "fee_asset_price_numerator": 1315266421 + }, + "header": { + "excess_mana": 1325362321, + "mana_used": 99455031, + "proving_cost_per_mana_numerator": 1658641650, + "fee_asset_price_numerator": 906040862 + }, + "oracle_input": { + "proving_cost_modifier": 150537551, + "fee_asset_price_modifier": -409225559 + }, + "outputs": { + "fee_asset_price_at_execution": 10132395409, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31472989, + "proving_cost": 5497646126, + "congestion_cost": 20538722365, + "congestion_multiplier": 4714646391 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318896769, + "proving_cost": 55704324367, + "congestion_cost": 208106456197, + "congestion_multiplier": 4714646391 + } + } + }, + { + "l1_block_number": 20974319, + "l1_fees": { + "blob_fee": 24, + "base_fee": 10745149155 + }, + "parent_header": { + "excess_mana": 1325362321, + "mana_used": 99455031, + "proving_cost_per_mana_numerator": 1658641650, + "fee_asset_price_numerator": 906040862 + }, + "header": { + "excess_mana": 1324817352, + "mana_used": 105869692, + "proving_cost_per_mana_numerator": 1757611722, + "fee_asset_price_numerator": 1253906944 + }, + "oracle_input": { + "proving_cost_modifier": 98970072, + "fee_asset_price_modifier": 347866082 + }, + "outputs": { + "fee_asset_price_at_execution": 10091015783, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35593306, + "proving_cost": 5505928380, + "congestion_cost": 20568140344, + "congestion_multiplier": 4711641226 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 359172612, + "proving_cost": 55560410182, + "congestion_cost": 207553428838, + "congestion_multiplier": 4711641226 + } + } + }, + { + "l1_block_number": 20974322, + "l1_fees": { + "blob_fee": 26, + "base_fee": 10241684423 + }, + "parent_header": { + "excess_mana": 1324817352, + "mana_used": 105869692, + "proving_cost_per_mana_numerator": 1757611722, + "fee_asset_price_numerator": 1253906944 + }, + "header": { + "excess_mana": 1330687044, + "mana_used": 39552574, + "proving_cost_per_mana_numerator": 1660840076, + "fee_asset_price_numerator": 1440977437 + }, + "oracle_input": { + "proving_cost_modifier": -96771646, + "fee_asset_price_modifier": 187070493 + }, + "outputs": { + "fee_asset_price_at_execution": 10126180131, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33925579, + "proving_cost": 5511380299, + "congestion_cost": 20762235035, + "congestion_multiplier": 4744109972 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 343536524, + "proving_cost": 55809229678, + "congestion_cost": 210242131886, + "congestion_multiplier": 4744109972 + } + } + }, + { + "l1_block_number": 20974325, + "l1_fees": { + "blob_fee": 19, + "base_fee": 10099236170 + }, + "parent_header": { + "excess_mana": 1330687044, + "mana_used": 39552574, + "proving_cost_per_mana_numerator": 1660840076, + "fee_asset_price_numerator": 1440977437 + }, + "header": { + "excess_mana": 1270239618, + "mana_used": 128754870, + "proving_cost_per_mana_numerator": 1769688662, + "fee_asset_price_numerator": 1403976904 + }, + "oracle_input": { + "proving_cost_modifier": 108848586, + "fee_asset_price_modifier": -37000533 + }, + "outputs": { + "fee_asset_price_at_execution": 10145140956, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33453719, + "proving_cost": 5506049425, + "congestion_cost": 18946096267, + "congestion_multiplier": 4420179712 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 339392694, + "proving_cost": 55859647527, + "congestion_cost": 192210817194, + "congestion_multiplier": 4420179712 + } + } + }, + { + "l1_block_number": 20974328, + "l1_fees": { + "blob_fee": 24, + "base_fee": 10714018785 + }, + "parent_header": { + "excess_mana": 1270239618, + "mana_used": 128754870, + "proving_cost_per_mana_numerator": 1769688662, + "fee_asset_price_numerator": 1403976904 + }, + "header": { + "excess_mana": 1298994488, + "mana_used": 122069543, + "proving_cost_per_mana_numerator": 1630222122, + "fee_asset_price_numerator": 1855086357 + }, + "oracle_input": { + "proving_cost_modifier": -139466540, + "fee_asset_price_modifier": 451109453 + }, + "outputs": { + "fee_asset_price_at_execution": 10141387894, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35490187, + "proving_cost": 5512045945, + "congestion_cost": 19812573210, + "congestion_multiplier": 4571418507 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 359919752, + "proving_cost": 55899796017, + "congestion_cost": 200926990100, + "congestion_multiplier": 4571418507 + } + } + }, + { + "l1_block_number": 20974331, + "l1_fees": { + "blob_fee": 20, + "base_fee": 9990102695 + }, + "parent_header": { + "excess_mana": 1298994488, + "mana_used": 122069543, + "proving_cost_per_mana_numerator": 1630222122, + "fee_asset_price_numerator": 1855086357 + }, + "header": { + "excess_mana": 1321064031, + "mana_used": 101851803, + "proving_cost_per_mana_numerator": 1671509921, + "fee_asset_price_numerator": 1964747298 + }, + "oracle_input": { + "proving_cost_modifier": 41287799, + "fee_asset_price_modifier": 109660941 + }, + "outputs": { + "fee_asset_price_at_execution": 10187239997, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33092215, + "proving_cost": 5504363844, + "congestion_cost": 20438727925, + "congestion_multiplier": 4690995957 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 337118336, + "proving_cost": 56074275509, + "congestion_cost": 208214226605, + "congestion_multiplier": 4690995957 + } + } + }, + { + "l1_block_number": 20974334, + "l1_fees": { + "blob_fee": 22, + "base_fee": 9894921586 + }, + "parent_header": { + "excess_mana": 1321064031, + "mana_used": 101851803, + "proving_cost_per_mana_numerator": 1671509921, + "fee_asset_price_numerator": 1964747298 + }, + "header": { + "excess_mana": 1322915834, + "mana_used": 96372923, + "proving_cost_per_mana_numerator": 1556471872, + "fee_asset_price_numerator": 1480377822 + }, + "oracle_input": { + "proving_cost_modifier": -115038049, + "fee_asset_price_modifier": -484369476 + }, + "outputs": { + "fee_asset_price_at_execution": 10198417548, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32776927, + "proving_cost": 5506636943, + "congestion_cost": 20502315374, + "congestion_multiplier": 4701170531 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334272787, + "proving_cost": 56158982829, + "congestion_cost": 209091172884, + "congestion_multiplier": 4701170531 + } + } + }, + { + "l1_block_number": 20974337, + "l1_fees": { + "blob_fee": 23, + "base_fee": 9960455736 + }, + "parent_header": { + "excess_mana": 1322915834, + "mana_used": 96372923, + "proving_cost_per_mana_numerator": 1556471872, + "fee_asset_price_numerator": 1480377822 + }, + "header": { + "excess_mana": 1319288757, + "mana_used": 109308423, + "proving_cost_per_mana_numerator": 1597101767, + "fee_asset_price_numerator": 1899533473 + }, + "oracle_input": { + "proving_cost_modifier": 40629895, + "fee_asset_price_modifier": 419155651 + }, + "outputs": { + "fee_asset_price_at_execution": 10149138968, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32994009, + "proving_cost": 5500305858, + "congestion_cost": 20369529517, + "congestion_multiplier": 4681262539 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334860782, + "proving_cost": 55823368519, + "congestion_cost": 206733185780, + "congestion_multiplier": 4681262539 + } + } + }, + { + "l1_block_number": 20974340, + "l1_fees": { + "blob_fee": 22, + "base_fee": 9964721878 + }, + "parent_header": { + "excess_mana": 1319288757, + "mana_used": 109308423, + "proving_cost_per_mana_numerator": 1597101767, + "fee_asset_price_numerator": 1899533473 + }, + "header": { + "excess_mana": 1328597180, + "mana_used": 102019767, + "proving_cost_per_mana_numerator": 1557408475, + "fee_asset_price_numerator": 2190235844 + }, + "oracle_input": { + "proving_cost_modifier": -39693292, + "fee_asset_price_modifier": 290702371 + }, + "outputs": { + "fee_asset_price_at_execution": 10191768938, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33008141, + "proving_cost": 5502541081, + "congestion_cost": 20661571016, + "congestion_multiplier": 4732524125 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336411346, + "proving_cost": 56080627269, + "congestion_cost": 210577957691, + "congestion_multiplier": 4732524125 + } + } + }, + { + "l1_block_number": 20974343, + "l1_fees": { + "blob_fee": 19, + "base_fee": 9815866122 + }, + "parent_header": { + "excess_mana": 1328597180, + "mana_used": 102019767, + "proving_cost_per_mana_numerator": 1557408475, + "fee_asset_price_numerator": 2190235844 + }, + "header": { + "excess_mana": 1330616947, + "mana_used": 91158650, + "proving_cost_per_mana_numerator": 1599926904, + "fee_asset_price_numerator": 2259250132 + }, + "oracle_input": { + "proving_cost_modifier": 42518429, + "fee_asset_price_modifier": 69014288 + }, + "outputs": { + "fee_asset_price_at_execution": 10221439758, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32515056, + "proving_cost": 5500357374, + "congestion_cost": 20713530191, + "congestion_multiplier": 4743720907 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332350686, + "proving_cost": 56221571545, + "congestion_cost": 211722101022, + "congestion_multiplier": 4743720907 + } + } + }, + { + "l1_block_number": 20974346, + "l1_fees": { + "blob_fee": 17, + "base_fee": 9039417707 + }, + "parent_header": { + "excess_mana": 1330616947, + "mana_used": 91158650, + "proving_cost_per_mana_numerator": 1599926904, + "fee_asset_price_numerator": 2259250132 + }, + "header": { + "excess_mana": 1321775597, + "mana_used": 107408210, + "proving_cost_per_mana_numerator": 1470245111, + "fee_asset_price_numerator": 2095941984 + }, + "oracle_input": { + "proving_cost_modifier": -129681793, + "fee_asset_price_modifier": -163308148 + }, + "outputs": { + "fee_asset_price_at_execution": 10228496447, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29943071, + "proving_cost": 5502696537, + "congestion_cost": 20442566619, + "congestion_multiplier": 4694902988 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 306272595, + "proving_cost": 56284311977, + "congestion_cost": 209096720030, + "congestion_multiplier": 4694902988 + } + } + }, + { + "l1_block_number": 20974349, + "l1_fees": { + "blob_fee": 15, + "base_fee": 8475102127 + }, + "parent_header": { + "excess_mana": 1321775597, + "mana_used": 107408210, + "proving_cost_per_mana_numerator": 1470245111, + "fee_asset_price_numerator": 2095941984 + }, + "header": { + "excess_mana": 1329183807, + "mana_used": 98319714, + "proving_cost_per_mana_numerator": 1375804603, + "fee_asset_price_numerator": 1850876842 + }, + "oracle_input": { + "proving_cost_modifier": -94440508, + "fee_asset_price_modifier": -245065142 + }, + "outputs": { + "fee_asset_price_at_execution": 10211806111, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28073775, + "proving_cost": 5495565167, + "congestion_cost": 20635063568, + "congestion_multiplier": 4735773425 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 286683947, + "proving_cost": 56119645955, + "congestion_cost": 210721268244, + "congestion_multiplier": 4735773425 + } + } + }, + { + "l1_block_number": 20974352, + "l1_fees": { + "blob_fee": 14, + "base_fee": 9315624609 + }, + "parent_header": { + "excess_mana": 1329183807, + "mana_used": 98319714, + "proving_cost_per_mana_numerator": 1375804603, + "fee_asset_price_numerator": 1850876842 + }, + "header": { + "excess_mana": 1327503521, + "mana_used": 79040235, + "proving_cost_per_mana_numerator": 1312310154, + "fee_asset_price_numerator": 1909017143 + }, + "oracle_input": { + "proving_cost_modifier": -63494449, + "fee_asset_price_modifier": 58140301 + }, + "outputs": { + "fee_asset_price_at_execution": 10186811173, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30858006, + "proving_cost": 5490377577, + "congestion_cost": 20574731732, + "congestion_multiplier": 4726472349 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 314344680, + "proving_cost": 55929439645, + "congestion_cost": 209590907089, + "congestion_multiplier": 4726472349 + } + } + }, + { + "l1_block_number": 20974355, + "l1_fees": { + "blob_fee": 12, + "base_fee": 9031807679 + }, + "parent_header": { + "excess_mana": 1327503521, + "mana_used": 79040235, + "proving_cost_per_mana_numerator": 1312310154, + "fee_asset_price_numerator": 1909017143 + }, + "header": { + "excess_mana": 1306543756, + "mana_used": 107770546, + "proving_cost_per_mana_numerator": 1372426141, + "fee_asset_price_numerator": 2236036991 + }, + "oracle_input": { + "proving_cost_modifier": 60115987, + "fee_asset_price_modifier": 327019848 + }, + "outputs": { + "fee_asset_price_at_execution": 10192735538, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29917862, + "proving_cost": 5486892598, + "congestion_cost": 19926581814, + "congestion_multiplier": 4611975064 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 304944855, + "proving_cost": 55926445176, + "congestion_cost": 203106378606, + "congestion_multiplier": 4611975064 + } + } + }, + { + "l1_block_number": 20974358, + "l1_fees": { + "blob_fee": 12, + "base_fee": 9209742295 + }, + "parent_header": { + "excess_mana": 1306543756, + "mana_used": 107770546, + "proving_cost_per_mana_numerator": 1372426141, + "fee_asset_price_numerator": 2236036991 + }, + "header": { + "excess_mana": 1314314302, + "mana_used": 108806778, + "proving_cost_per_mana_numerator": 1324351893, + "fee_asset_price_numerator": 1806378454 + }, + "oracle_input": { + "proving_cost_modifier": -48074248, + "fee_asset_price_modifier": -429658537 + }, + "outputs": { + "fee_asset_price_at_execution": 10226122367, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30507271, + "proving_cost": 5490192090, + "congestion_cost": 20173166539, + "congestion_multiplier": 4654096197 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 311971086, + "proving_cost": 56143376130, + "congestion_cost": 206293269557, + "congestion_multiplier": 4654096197 + } + } + }, + { + "l1_block_number": 20974361, + "l1_fees": { + "blob_fee": 9, + "base_fee": 8782605352 + }, + "parent_header": { + "excess_mana": 1314314302, + "mana_used": 108806778, + "proving_cost_per_mana_numerator": 1324351893, + "fee_asset_price_numerator": 1806378454 + }, + "header": { + "excess_mana": 1323121080, + "mana_used": 90226091, + "proving_cost_per_mana_numerator": 1264633275, + "fee_asset_price_numerator": 2350054816 + }, + "oracle_input": { + "proving_cost_modifier": -59718618, + "fee_asset_price_modifier": 543676362 + }, + "outputs": { + "fee_asset_price_at_execution": 10182279215, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29092380, + "proving_cost": 5487553355, + "congestion_cost": 20424275275, + "congestion_multiplier": 4702299596 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 296226736, + "proving_cost": 55875800467, + "congestion_cost": 207965673614, + "congestion_multiplier": 4702299596 + } + } + }, + { + "l1_block_number": 20974364, + "l1_fees": { + "blob_fee": 7, + "base_fee": 9499075723 + }, + "parent_header": { + "excess_mana": 1323121080, + "mana_used": 90226091, + "proving_cost_per_mana_numerator": 1264633275, + "fee_asset_price_numerator": 2350054816 + }, + "header": { + "excess_mana": 1313347171, + "mana_used": 111455713, + "proving_cost_per_mana_numerator": 1260495242, + "fee_asset_price_numerator": 2066832958 + }, + "oracle_input": { + "proving_cost_modifier": -4138033, + "fee_asset_price_modifier": -283221858 + }, + "outputs": { + "fee_asset_price_at_execution": 10237788619, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31465688, + "proving_cost": 5484277243, + "congestion_cost": 20126024081, + "congestion_multiplier": 4648832865 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 322139062, + "proving_cost": 56146871141, + "congestion_cost": 206045980282, + "congestion_multiplier": 4648832865 + } + } + }, + { + "l1_block_number": 20974367, + "l1_fees": { + "blob_fee": 8, + "base_fee": 9417033890 + }, + "parent_header": { + "excess_mana": 1313347171, + "mana_used": 111455713, + "proving_cost_per_mana_numerator": 1260495242, + "fee_asset_price_numerator": 2066832958 + }, + "header": { + "excess_mana": 1324802884, + "mana_used": 102257732, + "proving_cost_per_mana_numerator": 1259391999, + "fee_asset_price_numerator": 1704421437 + }, + "oracle_input": { + "proving_cost_modifier": -1103243, + "fee_asset_price_modifier": -362411521 + }, + "outputs": { + "fee_asset_price_at_execution": 10208833986, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31193924, + "proving_cost": 5484050306, + "congestion_cost": 20470167981, + "congestion_multiplier": 4711561470 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318453591, + "proving_cost": 55985759144, + "congestion_cost": 208976546583, + "congestion_multiplier": 4711561470 + } + } + }, + { + "l1_block_number": 20974370, + "l1_fees": { + "blob_fee": 6, + "base_fee": 9309211929 + }, + "parent_header": { + "excess_mana": 1324802884, + "mana_used": 102257732, + "proving_cost_per_mana_numerator": 1259391999, + "fee_asset_price_numerator": 1704421437 + }, + "header": { + "excess_mana": 1327060616, + "mana_used": 98249684, + "proving_cost_per_mana_numerator": 1204937291, + "fee_asset_price_numerator": 1449652955 + }, + "oracle_input": { + "proving_cost_modifier": -54454708, + "fee_asset_price_modifier": -254768482 + }, + "outputs": { + "fee_asset_price_at_execution": 10171902957, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30836764, + "proving_cost": 5483989804, + "congestion_cost": 20537345011, + "congestion_multiplier": 4724023731 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313668570, + "proving_cost": 55782612103, + "congestion_cost": 208903880446, + "congestion_multiplier": 4724023731 + } + } + }, + { + "l1_block_number": 20974373, + "l1_fees": { + "blob_fee": 6, + "base_fee": 9007719109 + }, + "parent_header": { + "excess_mana": 1327060616, + "mana_used": 98249684, + "proving_cost_per_mana_numerator": 1204937291, + "fee_asset_price_numerator": 1449652955 + }, + "header": { + "excess_mana": 1325310300, + "mana_used": 103778888, + "proving_cost_per_mana_numerator": 1187210311, + "fee_asset_price_numerator": 547655613 + }, + "oracle_input": { + "proving_cost_modifier": -17726980, + "fee_asset_price_modifier": -901997342 + }, + "outputs": { + "fee_asset_price_at_execution": 10146021138, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29838069, + "proving_cost": 5481004326, + "congestion_cost": 20469249499, + "congestion_multiplier": 4714359445 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 302737678, + "proving_cost": 55610385749, + "congestion_cost": 207681438095, + "congestion_multiplier": 4714359445 + } + } + }, + { + "l1_block_number": 20974376, + "l1_fees": { + "blob_fee": 6, + "base_fee": 8992739005 + }, + "parent_header": { + "excess_mana": 1325310300, + "mana_used": 103778888, + "proving_cost_per_mana_numerator": 1187210311, + "fee_asset_price_numerator": 547655613 + }, + "header": { + "excess_mana": 1329089188, + "mana_used": 102202562, + "proving_cost_per_mana_numerator": 1334620866, + "fee_asset_price_numerator": 390261417 + }, + "oracle_input": { + "proving_cost_modifier": 147410555, + "fee_asset_price_modifier": -157394196 + }, + "outputs": { + "fee_asset_price_at_execution": 10054915798, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29788447, + "proving_cost": 5480032796, + "congestion_cost": 20580555301, + "congestion_multiplier": 4735249184 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 299520326, + "proving_cost": 55101268334, + "congestion_cost": 206935750627, + "congestion_multiplier": 4735249184 + } + } + }, + { + "l1_block_number": 20974379, + "l1_fees": { + "blob_fee": 6, + "base_fee": 9042037019 + }, + "parent_header": { + "excess_mana": 1329089188, + "mana_used": 102202562, + "proving_cost_per_mana_numerator": 1334620866, + "fee_asset_price_numerator": 390261417 + }, + "header": { + "excess_mana": 1331291750, + "mana_used": 102177014, + "proving_cost_per_mana_numerator": 1416682604, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 82061738, + "fee_asset_price_modifier": -424317117 + }, + "outputs": { + "fee_asset_price_at_execution": 10039102392, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29951747, + "proving_cost": 5488116900, + "congestion_cost": 20678783723, + "congestion_multiplier": 4747467646 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 300688654, + "proving_cost": 55095767498, + "congestion_cost": 207596427137, + "congestion_multiplier": 4747467646 + } + } + }, + { + "l1_block_number": 20974382, + "l1_fees": { + "blob_fee": 7, + "base_fee": 8510788576 + }, + "parent_header": { + "excess_mana": 1331291750, + "mana_used": 102177014, + "proving_cost_per_mana_numerator": 1416682604, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1333468764, + "mana_used": 97887752, + "proving_cost_per_mana_numerator": 1423671361, + "fee_asset_price_numerator": 360076914 + }, + "oracle_input": { + "proving_cost_modifier": 6988757, + "fee_asset_price_modifier": 360076914 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28191987, + "proving_cost": 5492622392, + "congestion_cost": 20755917728, + "congestion_multiplier": 4759575364 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 281919870, + "proving_cost": 54926223920, + "congestion_cost": 207559177280, + "congestion_multiplier": 4759575364 + } + } + }, + { + "l1_block_number": 20974385, + "l1_fees": { + "blob_fee": 5, + "base_fee": 9374725308 + }, + "parent_header": { + "excess_mana": 1333468764, + "mana_used": 97887752, + "proving_cost_per_mana_numerator": 1423671361, + "fee_asset_price_numerator": 360076914 + }, + "header": { + "excess_mana": 1331356516, + "mana_used": 97037409, + "proving_cost_per_mana_numerator": 1534145393, + "fee_asset_price_numerator": 952978592 + }, + "oracle_input": { + "proving_cost_modifier": 110474032, + "fee_asset_price_modifier": 592901678 + }, + "outputs": { + "fee_asset_price_at_execution": 10036072596, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31053777, + "proving_cost": 5493006272, + "congestion_cost": 20703223638, + "congestion_multiplier": 4747827405 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 311657960, + "proving_cost": 55128209716, + "congestion_cost": 207779055402, + "congestion_multiplier": 4747827405 + } + } + }, + { + "l1_block_number": 20974388, + "l1_fees": { + "blob_fee": 5, + "base_fee": 8322579740 + }, + "parent_header": { + "excess_mana": 1331356516, + "mana_used": 97037409, + "proving_cost_per_mana_numerator": 1534145393, + "fee_asset_price_numerator": 952978592 + }, + "header": { + "excess_mana": 1328393925, + "mana_used": 94346326, + "proving_cost_per_mana_numerator": 1589826455, + "fee_asset_price_numerator": 1952978592 + }, + "oracle_input": { + "proving_cost_modifier": 55681062, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10095753389, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27568545, + "proving_cost": 5499077970, + "congestion_cost": 20622122312, + "congestion_multiplier": 4731398825 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 278325231, + "proving_cost": 55517335052, + "congestion_cost": 208195861219, + "congestion_multiplier": 4731398825 + } + } + }, + { + "l1_block_number": 20974391, + "l1_fees": { + "blob_fee": 4, + "base_fee": 8799523084 + }, + "parent_header": { + "excess_mana": 1328393925, + "mana_used": 94346326, + "proving_cost_per_mana_numerator": 1589826455, + "fee_asset_price_numerator": 1952978592 + }, + "header": { + "excess_mana": 1322740251, + "mana_used": 111007432, + "proving_cost_per_mana_numerator": 1527438719, + "fee_asset_price_numerator": 2099675722 + }, + "oracle_input": { + "proving_cost_modifier": -62387736, + "fee_asset_price_modifier": 146697130 + }, + "outputs": { + "fee_asset_price_at_execution": 10197217397, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29148420, + "proving_cost": 5502140768, + "congestion_cost": 20466903129, + "congestion_multiplier": 4700204859 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 297232775, + "proving_cost": 56106525560, + "congestion_cost": 208705460649, + "congestion_multiplier": 4700204859 + } + } + }, + { + "l1_block_number": 20974394, + "l1_fees": { + "blob_fee": 4, + "base_fee": 8519958823 + }, + "parent_header": { + "excess_mana": 1322740251, + "mana_used": 111007432, + "proving_cost_per_mana_numerator": 1527438719, + "fee_asset_price_numerator": 2099675722 + }, + "header": { + "excess_mana": 1333747683, + "mana_used": 91076828, + "proving_cost_per_mana_numerator": 1499445967, + "fee_asset_price_numerator": 1358497570 + }, + "oracle_input": { + "proving_cost_modifier": -27992752, + "fee_asset_price_modifier": -741178152 + }, + "outputs": { + "fee_asset_price_at_execution": 10212187400, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28222363, + "proving_cost": 5498709178, + "congestion_cost": 20787501587, + "congestion_multiplier": 4761128835 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 288212059, + "proving_cost": 56153848583, + "congestion_cost": 212285861784, + "congestion_multiplier": 4761128835 + } + } + }, + { + "l1_block_number": 20974397, + "l1_fees": { + "blob_fee": 4, + "base_fee": 9023488741 + }, + "parent_header": { + "excess_mana": 1333747683, + "mana_used": 91076828, + "proving_cost_per_mana_numerator": 1499445967, + "fee_asset_price_numerator": 1358497570 + }, + "header": { + "excess_mana": 1324824511, + "mana_used": 102348677, + "proving_cost_per_mana_numerator": 1684170181, + "fee_asset_price_numerator": 1669934689 + }, + "oracle_input": { + "proving_cost_modifier": 184724214, + "fee_asset_price_modifier": 311437119 + }, + "outputs": { + "fee_asset_price_at_execution": 10136776707, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29890306, + "proving_cost": 5497170153, + "congestion_cost": 20514683583, + "congestion_multiplier": 4711680691 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 302991357, + "proving_cost": 55723586361, + "congestion_cost": 207952766695, + "congestion_multiplier": 4711680691 + } + } + }, + { + "l1_block_number": 20974400, + "l1_fees": { + "blob_fee": 4, + "base_fee": 8545578463 + }, + "parent_header": { + "excess_mana": 1324824511, + "mana_used": 102348677, + "proving_cost_per_mana_numerator": 1684170181, + "fee_asset_price_numerator": 1669934689 + }, + "header": { + "excess_mana": 1327173188, + "mana_used": 92938693, + "proving_cost_per_mana_numerator": 1871615142, + "fee_asset_price_numerator": 2669934689 + }, + "oracle_input": { + "proving_cost_modifier": 187444961, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10168395603, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28307228, + "proving_cost": 5507334142, + "congestion_cost": 20618304320, + "congestion_multiplier": 4724645970 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 287839092, + "proving_cost": 56000752273, + "congestion_cost": 209655074988, + "congestion_multiplier": 4724645970 + } + } + }, + { + "l1_block_number": 20974403, + "l1_fees": { + "blob_fee": 3, + "base_fee": 8672936965 + }, + "parent_header": { + "excess_mana": 1327173188, + "mana_used": 92938693, + "proving_cost_per_mana_numerator": 1871615142, + "fee_asset_price_numerator": 2669934689 + }, + "header": { + "excess_mana": 1320111881, + "mana_used": 100219596, + "proving_cost_per_mana_numerator": 1771461342, + "fee_asset_price_numerator": 2497321334 + }, + "oracle_input": { + "proving_cost_modifier": -100153800, + "fee_asset_price_modifier": -172613355 + }, + "outputs": { + "fee_asset_price_at_execution": 10270589678, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28729103, + "proving_cost": 5517667044, + "congestion_cost": 20442757299, + "congestion_multiplier": 4685773024 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 295064828, + "proving_cost": 56669694188, + "congestion_cost": 209959172104, + "congestion_multiplier": 4685773024 + } + } + }, + { + "l1_block_number": 20974406, + "l1_fees": { + "blob_fee": 4, + "base_fee": 9479498490 + }, + "parent_header": { + "excess_mana": 1320111881, + "mana_used": 100219596, + "proving_cost_per_mana_numerator": 1771461342, + "fee_asset_price_numerator": 2497321334 + }, + "header": { + "excess_mana": 1320331477, + "mana_used": 87249250, + "proving_cost_per_mana_numerator": 1566676181, + "fee_asset_price_numerator": 3051306617 + }, + "oracle_input": { + "proving_cost_modifier": -204785161, + "fee_asset_price_modifier": 553985283 + }, + "outputs": { + "fee_asset_price_at_execution": 10252876561, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31400838, + "proving_cost": 5512143657, + "congestion_cost": 20438921506, + "congestion_multiplier": 4686977082 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 321948915, + "proving_cost": 56515328501, + "congestion_cost": 209557739240, + "congestion_multiplier": 4686977082 + } + } + }, + { + "l1_block_number": 20974409, + "l1_fees": { + "blob_fee": 3, + "base_fee": 9875043082 + }, + "parent_header": { + "excess_mana": 1320331477, + "mana_used": 87249250, + "proving_cost_per_mana_numerator": 1566676181, + "fee_asset_price_numerator": 3051306617 + }, + "header": { + "excess_mana": 1307580727, + "mana_used": 115675532, + "proving_cost_per_mana_numerator": 1629461953, + "fee_asset_price_numerator": 2394692137 + }, + "oracle_input": { + "proving_cost_modifier": 62785772, + "fee_asset_price_modifier": -656614480 + }, + "outputs": { + "fee_asset_price_at_execution": 10309833609, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32711080, + "proving_cost": 5500867155, + "congestion_cost": 20018128567, + "congestion_multiplier": 4617573967 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 337245791, + "proving_cost": 56713025073, + "congestion_cost": 206383574689, + "congestion_multiplier": 4617573967 + } + } + }, + { + "l1_block_number": 20974412, + "l1_fees": { + "blob_fee": 3, + "base_fee": 10014800521 + }, + "parent_header": { + "excess_mana": 1307580727, + "mana_used": 115675532, + "proving_cost_per_mana_numerator": 1629461953, + "fee_asset_price_numerator": 2394692137 + }, + "header": { + "excess_mana": 1323256259, + "mana_used": 105099465, + "proving_cost_per_mana_numerator": 1668234004, + "fee_asset_price_numerator": 2403049174 + }, + "oracle_input": { + "proving_cost_modifier": 38772051, + "fee_asset_price_modifier": 8357037 + }, + "outputs": { + "fee_asset_price_at_execution": 10242359514, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33174026, + "proving_cost": 5504322001, + "congestion_cost": 20505587938, + "congestion_multiplier": 4703043368 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 339780300, + "proving_cost": 56377244815, + "congestion_cost": 210025603706, + "congestion_multiplier": 4703043368 + } + } + }, + { + "l1_block_number": 20974415, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9730168250 + }, + "parent_header": { + "excess_mana": 1323256259, + "mana_used": 105099465, + "proving_cost_per_mana_numerator": 1668234004, + "fee_asset_price_numerator": 2403049174 + }, + "header": { + "excess_mana": 1328355724, + "mana_used": 103057264, + "proving_cost_per_mana_numerator": 1662305093, + "fee_asset_price_numerator": 2860952379 + }, + "oracle_input": { + "proving_cost_modifier": -5928911, + "fee_asset_price_modifier": 457903205 + }, + "outputs": { + "fee_asset_price_at_execution": 10243215507, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32231182, + "proving_cost": 5506456554, + "congestion_cost": 20665881666, + "congestion_multiplier": 4731187359 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 330150943, + "proving_cost": 56403821162, + "congestion_cost": 211685079546, + "congestion_multiplier": 4731187359 + } + } + }, + { + "l1_block_number": 20974418, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9791395571 + }, + "parent_header": { + "excess_mana": 1328355724, + "mana_used": 103057264, + "proving_cost_per_mana_numerator": 1662305093, + "fee_asset_price_numerator": 2860952379 + }, + "header": { + "excess_mana": 1331412988, + "mana_used": 91900546, + "proving_cost_per_mana_numerator": 1810563151, + "fee_asset_price_numerator": 1860952379 + }, + "oracle_input": { + "proving_cost_modifier": 148258058, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10290227071, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32433997, + "proving_cost": 5506130090, + "congestion_cost": 20759319767, + "congestion_multiplier": 4748141114 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 333753193, + "proving_cost": 56659328908, + "congestion_cost": 213618114241, + "congestion_multiplier": 4748141114 + } + } + }, + { + "l1_block_number": 20974421, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9523218022 + }, + "parent_header": { + "excess_mana": 1331412988, + "mana_used": 91900546, + "proving_cost_per_mana_numerator": 1810563151, + "fee_asset_price_numerator": 1860952379 + }, + "header": { + "excess_mana": 1323313534, + "mana_used": 102883709, + "proving_cost_per_mana_numerator": 1818236942, + "fee_asset_price_numerator": 2187559535 + }, + "oracle_input": { + "proving_cost_modifier": 7673791, + "fee_asset_price_modifier": 326607156 + }, + "outputs": { + "fee_asset_price_at_execution": 10187837601, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31545659, + "proving_cost": 5514299426, + "congestion_cost": 20538252740, + "congestion_multiplier": 4703358537 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 321382050, + "proving_cost": 56178787035, + "congestion_cost": 209240383523, + "congestion_multiplier": 4703358537 + } + } + }, + { + "l1_block_number": 20974424, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9104142284 + }, + "parent_header": { + "excess_mana": 1323313534, + "mana_used": 102883709, + "proving_cost_per_mana_numerator": 1818236942, + "fee_asset_price_numerator": 2187559535 + }, + "header": { + "excess_mana": 1326197243, + "mana_used": 96751216, + "proving_cost_per_mana_numerator": 1763396743, + "fee_asset_price_numerator": 1387005711 + }, + "oracle_input": { + "proving_cost_modifier": -54840199, + "fee_asset_price_modifier": -800553824 + }, + "outputs": { + "fee_asset_price_at_execution": 10221166205, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30157471, + "proving_cost": 5514722598, + "congestion_cost": 20622818401, + "congestion_multiplier": 4719254185 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 308244523, + "proving_cost": 56366896248, + "congestion_cost": 210789254492, + "congestion_multiplier": 4719254185 + } + } + }, + { + "l1_block_number": 20974427, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9433024582 + }, + "parent_header": { + "excess_mana": 1326197243, + "mana_used": 96751216, + "proving_cost_per_mana_numerator": 1763396743, + "fee_asset_price_numerator": 1387005711 + }, + "header": { + "excess_mana": 1322948459, + "mana_used": 97573641, + "proving_cost_per_mana_numerator": 1659879098, + "fee_asset_price_numerator": 1287275603 + }, + "oracle_input": { + "proving_cost_modifier": -103517645, + "fee_asset_price_modifier": -99730108 + }, + "outputs": { + "fee_asset_price_at_execution": 10139666926, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31246893, + "proving_cost": 5511699143, + "congestion_cost": 20516383221, + "congestion_multiplier": 4701349984 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 316833087, + "proving_cost": 55886793506, + "congestion_cost": 208029292387, + "congestion_multiplier": 4701349984 + } + } + }, + { + "l1_block_number": 20974430, + "l1_fees": { + "blob_fee": 2, + "base_fee": 9577344523 + }, + "parent_header": { + "excess_mana": 1322948459, + "mana_used": 97573641, + "proving_cost_per_mana_numerator": 1659879098, + "fee_asset_price_numerator": 1287275603 + }, + "header": { + "excess_mana": 1320522100, + "mana_used": 108291556, + "proving_cost_per_mana_numerator": 1760133785, + "fee_asset_price_numerator": 2109308002 + }, + "oracle_input": { + "proving_cost_modifier": 100254687, + "fee_asset_price_modifier": 822032399 + }, + "outputs": { + "fee_asset_price_at_execution": 10129559666, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31724953, + "proving_cost": 5505996513, + "congestion_cost": 20423241531, + "congestion_multiplier": 4688022530 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 321359804, + "proving_cost": 55773320199, + "congestion_cost": 206878443661, + "congestion_multiplier": 4688022530 + } + } + }, + { + "l1_block_number": 20974433, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10362139543 + }, + "parent_header": { + "excess_mana": 1320522100, + "mana_used": 108291556, + "proving_cost_per_mana_numerator": 1760133785, + "fee_asset_price_numerator": 2109308002 + }, + "header": { + "excess_mana": 1328813656, + "mana_used": 116536020, + "proving_cost_per_mana_numerator": 1680519423, + "fee_asset_price_numerator": 2585288012 + }, + "oracle_input": { + "proving_cost_modifier": -79614362, + "fee_asset_price_modifier": 475980010 + }, + "outputs": { + "fee_asset_price_at_execution": 10213171114, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34324587, + "proving_cost": 5511519301, + "congestion_cost": 20706644413, + "congestion_multiplier": 4733722916 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 350562880, + "proving_cost": 56290089719, + "congestion_cost": 211480502586, + "congestion_multiplier": 4733722916 + } + } + }, + { + "l1_block_number": 20974436, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10406464639 + }, + "parent_header": { + "excess_mana": 1328813656, + "mana_used": 116536020, + "proving_cost_per_mana_numerator": 1680519423, + "fee_asset_price_numerator": 2585288012 + }, + "header": { + "excess_mana": 1345349676, + "mana_used": 96428044, + "proving_cost_per_mana_numerator": 1476676325, + "fee_asset_price_numerator": 2439022097 + }, + "oracle_input": { + "proving_cost_modifier": -203843098, + "fee_asset_price_modifier": -146265915 + }, + "outputs": { + "fee_asset_price_at_execution": 10261899644, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34471414, + "proving_cost": 5507133086, + "congestion_cost": 21203279479, + "congestion_multiplier": 4826198618 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 353742191, + "proving_cost": 56513647054, + "congestion_cost": 217585926137, + "congestion_multiplier": 4826198618 + } + } + }, + { + "l1_block_number": 20974439, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10104922672 + }, + "parent_header": { + "excess_mana": 1345349676, + "mana_used": 96428044, + "proving_cost_per_mana_numerator": 1476676325, + "fee_asset_price_numerator": 2439022097 + }, + "header": { + "excess_mana": 1341777720, + "mana_used": 95890772, + "proving_cost_per_mana_numerator": 1609085406, + "fee_asset_price_numerator": 3126603769 + }, + "oracle_input": { + "proving_cost_modifier": 132409081, + "fee_asset_price_modifier": 687581672 + }, + "outputs": { + "fee_asset_price_at_execution": 10246900954, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33472556, + "proving_cost": 5495918609, + "congestion_cost": 21045255974, + "congestion_multiplier": 4806071111 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 342989966, + "proving_cost": 56316133637, + "congestion_cost": 215648653517, + "congestion_multiplier": 4806071111 + } + } + }, + { + "l1_block_number": 20974442, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9965861569 + }, + "parent_header": { + "excess_mana": 1341777720, + "mana_used": 95890772, + "proving_cost_per_mana_numerator": 1609085406, + "fee_asset_price_numerator": 3126603769 + }, + "header": { + "excess_mana": 1337668492, + "mana_used": 94902476, + "proving_cost_per_mana_numerator": 1510544942, + "fee_asset_price_numerator": 3479262472 + }, + "oracle_input": { + "proving_cost_modifier": -98540464, + "fee_asset_price_modifier": 352658703 + }, + "outputs": { + "fee_asset_price_at_execution": 10317599544, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33011916, + "proving_cost": 5503200525, + "congestion_cost": 20943602139, + "congestion_multiplier": 4783019955 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 340603729, + "proving_cost": 56779819227, + "congestion_cost": 216087699879, + "congestion_multiplier": 4783019955 + } + } + }, + { + "l1_block_number": 20974445, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9453701170 + }, + "parent_header": { + "excess_mana": 1337668492, + "mana_used": 94902476, + "proving_cost_per_mana_numerator": 1510544942, + "fee_asset_price_numerator": 3479262472 + }, + "header": { + "excess_mana": 1332570968, + "mana_used": 107758024, + "proving_cost_per_mana_numerator": 1408425412, + "fee_asset_price_numerator": 3570246302 + }, + "oracle_input": { + "proving_cost_modifier": -102119530, + "fee_asset_price_modifier": 90983830 + }, + "outputs": { + "fee_asset_price_at_execution": 10354049691, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31315385, + "proving_cost": 5497780316, + "congestion_cost": 20759423456, + "congestion_multiplier": 4754578430 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 324241052, + "proving_cost": 56924290582, + "congestion_cost": 214944102019, + "congestion_multiplier": 4754578430 + } + } + }, + { + "l1_block_number": 20974448, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10049137759 + }, + "parent_header": { + "excess_mana": 1332570968, + "mana_used": 107758024, + "proving_cost_per_mana_numerator": 1408425412, + "fee_asset_price_numerator": 3570246302 + }, + "header": { + "excess_mana": 1340328992, + "mana_used": 91950513, + "proving_cost_per_mana_numerator": 1408723465, + "fee_asset_price_numerator": 3283241701 + }, + "oracle_input": { + "proving_cost_modifier": 298053, + "fee_asset_price_modifier": -287004601 + }, + "outputs": { + "fee_asset_price_at_execution": 10363474489, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33287768, + "proving_cost": 5492168875, + "congestion_cost": 20985306748, + "congestion_multiplier": 4797931665 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 344976934, + "proving_cost": 56917952025, + "congestion_cost": 217480691126, + "congestion_multiplier": 4797931665 + } + } + }, + { + "l1_block_number": 20974451, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9689451624 + }, + "parent_header": { + "excess_mana": 1340328992, + "mana_used": 91950513, + "proving_cost_per_mana_numerator": 1408723465, + "fee_asset_price_numerator": 3283241701 + }, + "header": { + "excess_mana": 1332279505, + "mana_used": 83167517, + "proving_cost_per_mana_numerator": 1481314433, + "fee_asset_price_numerator": 2985347824 + }, + "oracle_input": { + "proving_cost_modifier": 72590968, + "fee_asset_price_modifier": -297893877 + }, + "outputs": { + "fee_asset_price_at_execution": 10333773482, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32096308, + "proving_cost": 5492185244, + "congestion_cost": 20732392993, + "congestion_multiplier": 4752957339 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 331675976, + "proving_cost": 56754998232, + "congestion_cost": 214243852929, + "congestion_multiplier": 4752957339 + } + } + }, + { + "l1_block_number": 20974454, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9132012958 + }, + "parent_header": { + "excess_mana": 1332279505, + "mana_used": 83167517, + "proving_cost_per_mana_numerator": 1481314433, + "fee_asset_price_numerator": 2985347824 + }, + "header": { + "excess_mana": 1315447022, + "mana_used": 104540142, + "proving_cost_per_mana_numerator": 1485447414, + "fee_asset_price_numerator": 3115043922 + }, + "oracle_input": { + "proving_cost_modifier": 4132981, + "fee_asset_price_modifier": 129696098 + }, + "outputs": { + "fee_asset_price_at_execution": 10303035610, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30249792, + "proving_cost": 5496173522, + "congestion_cost": 20228191947, + "congestion_multiplier": 4660268278 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 311664684, + "proving_cost": 56627271515, + "congestion_cost": 208411781955, + "congestion_multiplier": 4660268278 + } + } + }, + { + "l1_block_number": 20974457, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9109047599 + }, + "parent_header": { + "excess_mana": 1315447022, + "mana_used": 104540142, + "proving_cost_per_mana_numerator": 1485447414, + "fee_asset_price_numerator": 3115043922 + }, + "header": { + "excess_mana": 1319987164, + "mana_used": 98613846, + "proving_cost_per_mana_numerator": 1619719960, + "fee_asset_price_numerator": 4071641001 + }, + "oracle_input": { + "proving_cost_modifier": 134272546, + "fee_asset_price_modifier": 956597079 + }, + "outputs": { + "fee_asset_price_at_execution": 10316406914, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30173720, + "proving_cost": 5496400683, + "congestion_cost": 20365920369, + "congestion_multiplier": 4685089331 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 311284373, + "proving_cost": 56703106008, + "congestion_cost": 210103121704, + "congestion_multiplier": 4685089331 + } + } + }, + { + "l1_block_number": 20974460, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9238199253 + }, + "parent_header": { + "excess_mana": 1319987164, + "mana_used": 98613846, + "proving_cost_per_mana_numerator": 1619719960, + "fee_asset_price_numerator": 4071641001 + }, + "header": { + "excess_mana": 1318601010, + "mana_used": 93569588, + "proving_cost_per_mana_numerator": 1534217900, + "fee_asset_price_numerator": 4385474010 + }, + "oracle_input": { + "proving_cost_modifier": -85502060, + "fee_asset_price_modifier": 313833009 + }, + "outputs": { + "fee_asset_price_at_execution": 10415566886, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30601535, + "proving_cost": 5503785797, + "congestion_cost": 20352693978, + "congestion_multiplier": 4677497211 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318732334, + "proving_cost": 57325049094, + "congestion_cost": 211984845438, + "congestion_multiplier": 4677497211 + } + } + }, + { + "l1_block_number": 20974463, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9135208521 + }, + "parent_header": { + "excess_mana": 1318601010, + "mana_used": 93569588, + "proving_cost_per_mana_numerator": 1534217900, + "fee_asset_price_numerator": 4385474010 + }, + "header": { + "excess_mana": 1312170598, + "mana_used": 101029045, + "proving_cost_per_mana_numerator": 1496951851, + "fee_asset_price_numerator": 4427090165 + }, + "oracle_input": { + "proving_cost_modifier": -37266049, + "fee_asset_price_modifier": 41616155 + }, + "outputs": { + "fee_asset_price_at_execution": 10448305718, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30260378, + "proving_cost": 5499081958, + "congestion_cost": 20140285141, + "congestion_multiplier": 4642437729 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 316169680, + "proving_cost": 57456089465, + "congestion_cost": 210431856400, + "congestion_multiplier": 4642437729 + } + } + }, + { + "l1_block_number": 20974466, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9109919091 + }, + "parent_header": { + "excess_mana": 1312170598, + "mana_used": 101029045, + "proving_cost_per_mana_numerator": 1496951851, + "fee_asset_price_numerator": 4427090165 + }, + "header": { + "excess_mana": 1313199643, + "mana_used": 103381370, + "proving_cost_per_mana_numerator": 1456521830, + "fee_asset_price_numerator": 4554855911 + }, + "oracle_input": { + "proving_cost_modifier": -40430021, + "fee_asset_price_modifier": 127765746 + }, + "outputs": { + "fee_asset_price_at_execution": 10452654806, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30176606, + "proving_cost": 5497033049, + "congestion_cost": 20163429451, + "congestion_multiplier": 4648030509 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 315425645, + "proving_cost": 57458588918, + "congestion_cost": 210761367756, + "congestion_multiplier": 4648030509 + } + } + }, + { + "l1_block_number": 20974469, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9426312134 + }, + "parent_header": { + "excess_mana": 1313199643, + "mana_used": 103381370, + "proving_cost_per_mana_numerator": 1456521830, + "fee_asset_price_numerator": 4554855911 + }, + "header": { + "excess_mana": 1316581013, + "mana_used": 93119606, + "proving_cost_per_mana_numerator": 1383332186, + "fee_asset_price_numerator": 4852570946 + }, + "oracle_input": { + "proving_cost_modifier": -73189644, + "fee_asset_price_modifier": 297715035 + }, + "outputs": { + "fee_asset_price_at_execution": 10466018254, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31224658, + "proving_cost": 5494811046, + "congestion_cost": 20260963906, + "congestion_multiplier": 4666455483 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 326797840, + "proving_cost": 57508792709, + "congestion_cost": 212051618083, + "congestion_multiplier": 4666455483 + } + } + }, + { + "l1_block_number": 20974472, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8424055996 + }, + "parent_header": { + "excess_mana": 1316581013, + "mana_used": 93119606, + "proving_cost_per_mana_numerator": 1383332186, + "fee_asset_price_numerator": 4852570946 + }, + "header": { + "excess_mana": 1309700619, + "mana_used": 109263041, + "proving_cost_per_mana_numerator": 1365258008, + "fee_asset_price_numerator": 4182988274 + }, + "oracle_input": { + "proving_cost_modifier": -18074178, + "fee_asset_price_modifier": -669582672 + }, + "outputs": { + "fee_asset_price_at_execution": 10497223592, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27904685, + "proving_cost": 5490790885, + "congestion_cost": 20027572650, + "congestion_multiplier": 4629041029 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 292921717, + "proving_cost": 57638059616, + "congestion_cost": 210233908112, + "congestion_multiplier": 4629041029 + } + } + }, + { + "l1_block_number": 20974475, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9204460195 + }, + "parent_header": { + "excess_mana": 1309700619, + "mana_used": 109263041, + "proving_cost_per_mana_numerator": 1365258008, + "fee_asset_price_numerator": 4182988274 + }, + "header": { + "excess_mana": 1318963660, + "mana_used": 86270240, + "proving_cost_per_mana_numerator": 1280812819, + "fee_asset_price_numerator": 4367269688 + }, + "oracle_input": { + "proving_cost_modifier": -84445189, + "fee_asset_price_modifier": 184281414 + }, + "outputs": { + "fee_asset_price_at_execution": 10427170794, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30489774, + "proving_cost": 5489798560, + "congestion_cost": 20311803193, + "congestion_multiplier": 4679482296 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 317922080, + "proving_cost": 57243067209, + "congestion_cost": 211794641027, + "congestion_multiplier": 4679482296 + } + } + }, + { + "l1_block_number": 20974478, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8598622425 + }, + "parent_header": { + "excess_mana": 1318963660, + "mana_used": 86270240, + "proving_cost_per_mana_numerator": 1280812819, + "fee_asset_price_numerator": 4367269688 + }, + "header": { + "excess_mana": 1305233900, + "mana_used": 122448599, + "proving_cost_per_mana_numerator": 1339381969, + "fee_asset_price_numerator": 5366579735 + }, + "oracle_input": { + "proving_cost_modifier": 58569150, + "fee_asset_price_modifier": 999310047 + }, + "outputs": { + "fee_asset_price_at_execution": 10446403848, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28482936, + "proving_cost": 5485164646, + "congestion_cost": 19876216978, + "congestion_multiplier": 4604912480 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 297544252, + "proving_cost": 57300245064, + "congestion_cost": 207634989522, + "congestion_multiplier": 4604912480 + } + } + }, + { + "l1_block_number": 20974481, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9667058305 + }, + "parent_header": { + "excess_mana": 1305233900, + "mana_used": 122448599, + "proving_cost_per_mana_numerator": 1339381969, + "fee_asset_price_numerator": 5366579735 + }, + "header": { + "excess_mana": 1327682499, + "mana_used": 93784845, + "proving_cost_per_mana_numerator": 1302285571, + "fee_asset_price_numerator": 5548916077 + }, + "oracle_input": { + "proving_cost_modifier": -37096398, + "fee_asset_price_modifier": 182336342 + }, + "outputs": { + "fee_asset_price_at_execution": 10551319153, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32022130, + "proving_cost": 5488378201, + "congestion_cost": 20577083540, + "congestion_multiplier": 4727462196 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 337875713, + "proving_cost": 57909630031, + "congestion_cost": 217115375668, + "congestion_multiplier": 4727462196 + } + } + }, + { + "l1_block_number": 20974484, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10311092960 + }, + "parent_header": { + "excess_mana": 1327682499, + "mana_used": 93784845, + "proving_cost_per_mana_numerator": 1302285571, + "fee_asset_price_numerator": 5548916077 + }, + "header": { + "excess_mana": 1321467344, + "mana_used": 65246777, + "proving_cost_per_mana_numerator": 1238088312, + "fee_asset_price_numerator": 4997963835 + }, + "oracle_input": { + "proving_cost_modifier": -64197259, + "fee_asset_price_modifier": -550952242 + }, + "outputs": { + "fee_asset_price_at_execution": 10570575593, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34155495, + "proving_cost": 5486342588, + "congestion_cost": 20388358990, + "congestion_multiplier": 4693210048 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 361043241, + "proving_cost": 57993799055, + "congestion_cost": 215516689921, + "congestion_multiplier": 4693210048 + } + } + }, + { + "l1_block_number": 20974487, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9964934537 + }, + "parent_header": { + "excess_mana": 1321467344, + "mana_used": 65246777, + "proving_cost_per_mana_numerator": 1238088312, + "fee_asset_price_numerator": 4997963835 + }, + "header": { + "excess_mana": 1286714121, + "mana_used": 129539692, + "proving_cost_per_mana_numerator": 1255659249, + "fee_asset_price_numerator": 4985871086 + }, + "oracle_input": { + "proving_cost_modifier": 17570937, + "fee_asset_price_modifier": -12092749 + }, + "outputs": { + "fee_asset_price_at_execution": 10512496909, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33008845, + "proving_cost": 5482821637, + "congestion_cost": 19339637059, + "congestion_multiplier": 4506205842 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 347005381, + "proving_cost": 57638145511, + "congestion_cost": 203307874803, + "congestion_multiplier": 4506205842 + } + } + }, + { + "l1_block_number": 20974490, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10147307115 + }, + "parent_header": { + "excess_mana": 1286714121, + "mana_used": 129539692, + "proving_cost_per_mana_numerator": 1255659249, + "fee_asset_price_numerator": 4985871086 + }, + "header": { + "excess_mana": 1316253813, + "mana_used": 107842618, + "proving_cost_per_mana_numerator": 1343886692, + "fee_asset_price_numerator": 4131913707 + }, + "oracle_input": { + "proving_cost_modifier": 88227443, + "fee_asset_price_modifier": -853957379 + }, + "outputs": { + "fee_asset_price_at_execution": 10511225736, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33612954, + "proving_cost": 5483785104, + "congestion_cost": 20219439797, + "congestion_multiplier": 4664669394 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 353313347, + "proving_cost": 57641303115, + "congestion_cost": 212531095961, + "congestion_multiplier": 4664669394 + } + } + }, + { + "l1_block_number": 20974493, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9938782318 + }, + "parent_header": { + "excess_mana": 1316253813, + "mana_used": 107842618, + "proving_cost_per_mana_numerator": 1343886692, + "fee_asset_price_numerator": 4131913707 + }, + "header": { + "excess_mana": 1324096431, + "mana_used": 112543554, + "proving_cost_per_mana_numerator": 1347111084, + "fee_asset_price_numerator": 3921942167 + }, + "oracle_input": { + "proving_cost_modifier": 3224392, + "fee_asset_price_modifier": -209971540 + }, + "outputs": { + "fee_asset_price_at_execution": 10421846522, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32922216, + "proving_cost": 5488625443, + "congestion_cost": 20472069640, + "congestion_multiplier": 4707668738 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 343110282, + "proving_cost": 57201611983, + "congestion_cost": 213356767775, + "congestion_multiplier": 4707668738 + } + } + }, + { + "l1_block_number": 20974496, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9644897398 + }, + "parent_header": { + "excess_mana": 1324096431, + "mana_used": 112543554, + "proving_cost_per_mana_numerator": 1347111084, + "fee_asset_price_numerator": 3921942167 + }, + "header": { + "excess_mana": 1336639985, + "mana_used": 73408546, + "proving_cost_per_mana_numerator": 1278285869, + "fee_asset_price_numerator": 3955137169 + }, + "oracle_input": { + "proving_cost_modifier": -68825215, + "fee_asset_price_modifier": 33195002 + }, + "outputs": { + "fee_asset_price_at_execution": 10399986568, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31948722, + "proving_cost": 5488802420, + "congestion_cost": 20853355272, + "congestion_multiplier": 4777267755 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332266279, + "proving_cost": 57083471442, + "congestion_cost": 216874614726, + "congestion_multiplier": 4777267755 + } + } + }, + { + "l1_block_number": 20974499, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9683030291 + }, + "parent_header": { + "excess_mana": 1336639985, + "mana_used": 73408546, + "proving_cost_per_mana_numerator": 1278285869, + "fee_asset_price_numerator": 3955137169 + }, + "header": { + "excess_mana": 1310048531, + "mana_used": 113343265, + "proving_cost_per_mana_numerator": 1214917640, + "fee_asset_price_numerator": 3560832675 + }, + "oracle_input": { + "proving_cost_modifier": -63368229, + "fee_asset_price_modifier": -394304494 + }, + "outputs": { + "fee_asset_price_at_execution": 10403439417, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32075037, + "proving_cost": 5485026040, + "congestion_cost": 20032184067, + "congestion_multiplier": 4630925696 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 333690704, + "proving_cost": 57063136107, + "congestion_cost": 208403613331, + "congestion_multiplier": 4630925696 + } + } + }, + { + "l1_block_number": 20974502, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11058719709 + }, + "parent_header": { + "excess_mana": 1310048531, + "mana_used": 113343265, + "proving_cost_per_mana_numerator": 1214917640, + "fee_asset_price_numerator": 3560832675 + }, + "header": { + "excess_mana": 1323391796, + "mana_used": 94371501, + "proving_cost_per_mana_numerator": 1081226248, + "fee_asset_price_numerator": 3698989537 + }, + "oracle_input": { + "proving_cost_modifier": -133691392, + "fee_asset_price_modifier": 138156862 + }, + "outputs": { + "fee_asset_price_at_execution": 10362498956, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36632009, + "proving_cost": 5481551377, + "congestion_cost": 20438188177, + "congestion_multiplier": 4703789227 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 379599155, + "proving_cost": 56802570421, + "congestion_cost": 211790703646, + "congestion_multiplier": 4703789227 + } + } + }, + { + "l1_block_number": 20974505, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12997295205 + }, + "parent_header": { + "excess_mana": 1323391796, + "mana_used": 94371501, + "proving_cost_per_mana_numerator": 1081226248, + "fee_asset_price_numerator": 3698989537 + }, + "header": { + "excess_mana": 1317763297, + "mana_used": 93168662, + "proving_cost_per_mana_numerator": 1085933046, + "fee_asset_price_numerator": 3297057904 + }, + "oracle_input": { + "proving_cost_modifier": 4706798, + "fee_asset_price_modifier": -401931633 + }, + "outputs": { + "fee_asset_price_at_execution": 10376825353, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 43053540, + "proving_cost": 5474227911, + "congestion_cost": 20264505403, + "congestion_multiplier": 4672914928 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 446759065, + "proving_cost": 56805106974, + "congestion_cost": 210281233431, + "congestion_multiplier": 4672914928 + } + } + }, + { + "l1_block_number": 20974508, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12529147099 + }, + "parent_header": { + "excess_mana": 1317763297, + "mana_used": 93168662, + "proving_cost_per_mana_numerator": 1085933046, + "fee_asset_price_numerator": 3297057904 + }, + "header": { + "excess_mana": 1310931959, + "mana_used": 93314520, + "proving_cost_per_mana_numerator": 1078558840, + "fee_asset_price_numerator": 2473855109 + }, + "oracle_input": { + "proving_cost_modifier": -7374206, + "fee_asset_price_modifier": -823202795 + }, + "outputs": { + "fee_asset_price_at_execution": 10335201316, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41502799, + "proving_cost": 5474485578, + "congestion_cost": 20054560275, + "congestion_multiplier": 4635714745 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 428939782, + "proving_cost": 56579910550, + "congestion_cost": 207267917745, + "congestion_multiplier": 4635714745 + } + } + }, + { + "l1_block_number": 20974511, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10526750513 + }, + "parent_header": { + "excess_mana": 1310931959, + "mana_used": 93314520, + "proving_cost_per_mana_numerator": 1078558840, + "fee_asset_price_numerator": 2473855109 + }, + "header": { + "excess_mana": 1304246479, + "mana_used": 103896298, + "proving_cost_per_mana_numerator": 1029046373, + "fee_asset_price_numerator": 1930554124 + }, + "oracle_input": { + "proving_cost_modifier": -49512467, + "fee_asset_price_modifier": -543300985 + }, + "outputs": { + "fee_asset_price_at_execution": 10250470880, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34869861, + "proving_cost": 5474081893, + "congestion_cost": 19829998367, + "congestion_multiplier": 4599595577 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 357432494, + "proving_cost": 56111917038, + "congestion_cost": 203266820811, + "congestion_multiplier": 4599595577 + } + } + }, + { + "l1_block_number": 20974514, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11093378624 + }, + "parent_header": { + "excess_mana": 1304246479, + "mana_used": 103896298, + "proving_cost_per_mana_numerator": 1029046373, + "fee_asset_price_numerator": 1930554124 + }, + "header": { + "excess_mana": 1308142777, + "mana_used": 117487149, + "proving_cost_per_mana_numerator": 984241441, + "fee_asset_price_numerator": 2186396974 + }, + "oracle_input": { + "proving_cost_modifier": -44804932, + "fee_asset_price_modifier": 255842850 + }, + "outputs": { + "fee_asset_price_at_execution": 10194930982, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36746816, + "proving_cost": 5471372211, + "congestion_cost": 19942758954, + "congestion_multiplier": 4620611475 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 374631252, + "proving_cost": 55780262067, + "congestion_cost": 203315051126, + "congestion_multiplier": 4620611475 + } + } + }, + { + "l1_block_number": 20974517, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10637397356 + }, + "parent_header": { + "excess_mana": 1308142777, + "mana_used": 117487149, + "proving_cost_per_mana_numerator": 984241441, + "fee_asset_price_numerator": 2186396974 + }, + "header": { + "excess_mana": 1325629926, + "mana_used": 96366063, + "proving_cost_per_mana_numerator": 962580842, + "fee_asset_price_numerator": 2295853999 + }, + "oracle_input": { + "proving_cost_modifier": -21660599, + "fee_asset_price_modifier": 109457025 + }, + "outputs": { + "fee_asset_price_at_execution": 10221047378, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35236378, + "proving_cost": 5468921316, + "congestion_cost": 20454125725, + "congestion_multiplier": 4716122768 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 360152688, + "proving_cost": 55898103877, + "congestion_cost": 209062588110, + "congestion_multiplier": 4716122768 + } + } + }, + { + "l1_block_number": 20974520, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10064163696 + }, + "parent_header": { + "excess_mana": 1325629926, + "mana_used": 96366063, + "proving_cost_per_mana_numerator": 962580842, + "fee_asset_price_numerator": 2295853999 + }, + "header": { + "excess_mana": 1321995989, + "mana_used": 104057436, + "proving_cost_per_mana_numerator": 1102561637, + "fee_asset_price_numerator": 2044244503 + }, + "oracle_input": { + "proving_cost_modifier": 139980795, + "fee_asset_price_modifier": -251609496 + }, + "outputs": { + "fee_asset_price_at_execution": 10232241157, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33337542, + "proving_cost": 5467736843, + "congestion_cost": 20332596762, + "congestion_multiplier": 4696113766 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 341117769, + "proving_cost": 55947201960, + "congestion_cost": 208048033416, + "congestion_multiplier": 4696113766 + } + } + }, + { + "l1_block_number": 20974523, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11907531280 + }, + "parent_header": { + "excess_mana": 1321995989, + "mana_used": 104057436, + "proving_cost_per_mana_numerator": 1102561637, + "fee_asset_price_numerator": 2044244503 + }, + "header": { + "excess_mana": 1326053425, + "mana_used": 102990842, + "proving_cost_per_mana_numerator": 1166748460, + "fee_asset_price_numerator": 1690058727 + }, + "oracle_input": { + "proving_cost_modifier": 64186823, + "fee_asset_price_modifier": -354185776 + }, + "outputs": { + "fee_asset_price_at_execution": 10206528229, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 39443697, + "proving_cost": 5475395984, + "congestion_cost": 20506711626, + "congestion_multiplier": 4718460157 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 402583206, + "proving_cost": 55884783675, + "congestion_cost": 209302331094, + "congestion_multiplier": 4718460157 + } + } + }, + { + "l1_block_number": 20974526, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11019213472 + }, + "parent_header": { + "excess_mana": 1326053425, + "mana_used": 102990842, + "proving_cost_per_mana_numerator": 1166748460, + "fee_asset_price_numerator": 1690058727 + }, + "header": { + "excess_mana": 1329044267, + "mana_used": 107221657, + "proving_cost_per_mana_numerator": 1228517743, + "fee_asset_price_numerator": 1122668389 + }, + "oracle_input": { + "proving_cost_modifier": 61769283, + "fee_asset_price_modifier": -567390338 + }, + "outputs": { + "fee_asset_price_at_execution": 10170442101, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36501144, + "proving_cost": 5478911595, + "congestion_cost": 20600068328, + "congestion_multiplier": 4735000317 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 371232771, + "proving_cost": 55722953153, + "congestion_cost": 209511802206, + "congestion_multiplier": 4735000317 + } + } + }, + { + "l1_block_number": 20974529, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11135880229 + }, + "parent_header": { + "excess_mana": 1329044267, + "mana_used": 107221657, + "proving_cost_per_mana_numerator": 1228517743, + "fee_asset_price_numerator": 1122668389 + }, + "header": { + "excess_mana": 1336265924, + "mana_used": 91764333, + "proving_cost_per_mana_numerator": 1208026504, + "fee_asset_price_numerator": 1888536575 + }, + "oracle_input": { + "proving_cost_modifier": -20491239, + "fee_asset_price_modifier": 765868186 + }, + "outputs": { + "fee_asset_price_at_execution": 10112899396, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36887603, + "proving_cost": 5482296924, + "congestion_cost": 20835900880, + "congestion_multiplier": 4775177434 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 373040618, + "proving_cost": 55441917251, + "congestion_cost": 210711369424, + "congestion_multiplier": 4775177434 + } + } + }, + { + "l1_block_number": 20974532, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10401645769 + }, + "parent_header": { + "excess_mana": 1336265924, + "mana_used": 91764333, + "proving_cost_per_mana_numerator": 1208026504, + "fee_asset_price_numerator": 1888536575 + }, + "header": { + "excess_mana": 1328030257, + "mana_used": 87902892, + "proving_cost_per_mana_numerator": 1200128277, + "fee_asset_price_numerator": 1941013105 + }, + "oracle_input": { + "proving_cost_modifier": -7898227, + "fee_asset_price_modifier": 52476530 + }, + "outputs": { + "fee_asset_price_at_execution": 10190648221, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34455451, + "proving_cost": 5481173649, + "congestion_cost": 20569910404, + "congestion_multiplier": 4729386083 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 351123380, + "proving_cost": 55856712495, + "congestion_cost": 209620720864, + "congestion_multiplier": 4729386083 + } + } + }, + { + "l1_block_number": 20974535, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11090844407 + }, + "parent_header": { + "excess_mana": 1328030257, + "mana_used": 87902892, + "proving_cost_per_mana_numerator": 1200128277, + "fee_asset_price_numerator": 1941013105 + }, + "header": { + "excess_mana": 1315933149, + "mana_used": 92877236, + "proving_cost_per_mana_numerator": 1136168049, + "fee_asset_price_numerator": 1382043599 + }, + "oracle_input": { + "proving_cost_modifier": -63960228, + "fee_asset_price_modifier": -558969506 + }, + "outputs": { + "fee_asset_price_at_execution": 10195997323, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36738422, + "proving_cost": 5480740751, + "congestion_cost": 20210082859, + "congestion_multiplier": 4662919646 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 374584852, + "proving_cost": 55881618025, + "congestion_cost": 206061950727, + "congestion_multiplier": 4662919646 + } + } + }, + { + "l1_block_number": 20974538, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10020764445 + }, + "parent_header": { + "excess_mana": 1315933149, + "mana_used": 92877236, + "proving_cost_per_mana_numerator": 1136168049, + "fee_asset_price_numerator": 1382043599 + }, + "header": { + "excess_mana": 1308810385, + "mana_used": 106131552, + "proving_cost_per_mana_numerator": 893392989, + "fee_asset_price_numerator": 1723038366 + }, + "oracle_input": { + "proving_cost_modifier": -242775060, + "fee_asset_price_modifier": 340994767 + }, + "outputs": { + "fee_asset_price_at_execution": 10139163797, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33193782, + "proving_cost": 5477236377, + "congestion_cost": 19971022492, + "congestion_multiplier": 4624222051 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336557192, + "proving_cost": 55534596781, + "congestion_cost": 202489468239, + "congestion_multiplier": 4624222051 + } + } + }, + { + "l1_block_number": 20974541, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9721514258 + }, + "parent_header": { + "excess_mana": 1308810385, + "mana_used": 106131552, + "proving_cost_per_mana_numerator": 893392989, + "fee_asset_price_numerator": 1723038366 + }, + "header": { + "excess_mana": 1314941937, + "mana_used": 106820614, + "proving_cost_per_mana_numerator": 999930664, + "fee_asset_price_numerator": 1858647729 + }, + "oracle_input": { + "proving_cost_modifier": 106537675, + "fee_asset_price_modifier": 135609363 + }, + "outputs": { + "fee_asset_price_at_execution": 10173796829, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32202515, + "proving_cost": 5463955141, + "congestion_cost": 20102279668, + "congestion_multiplier": 4657515109 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 327621844, + "proving_cost": 55589169487, + "congestion_cost": 204516509141, + "congestion_multiplier": 4657515109 + } + } + }, + { + "l1_block_number": 20974544, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9605454919 + }, + "parent_header": { + "excess_mana": 1314941937, + "mana_used": 106820614, + "proving_cost_per_mana_numerator": 999930664, + "fee_asset_price_numerator": 1858647729 + }, + "header": { + "excess_mana": 1321762551, + "mana_used": 94649159, + "proving_cost_per_mana_numerator": 1216200771, + "fee_asset_price_numerator": 1932155741 + }, + "oracle_input": { + "proving_cost_modifier": 216270107, + "fee_asset_price_modifier": 73508012 + }, + "outputs": { + "fee_asset_price_at_execution": 10187602809, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31818069, + "proving_cost": 5469779414, + "congestion_cost": 20327474728, + "congestion_multiplier": 4694831327 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 324149849, + "proving_cost": 55723940122, + "congestion_cost": 207088238638, + "congestion_multiplier": 4694831327 + } + } + }, + { + "l1_block_number": 20974547, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8987171015 + }, + "parent_header": { + "excess_mana": 1321762551, + "mana_used": 94649159, + "proving_cost_per_mana_numerator": 1216200771, + "fee_asset_price_numerator": 1932155741 + }, + "header": { + "excess_mana": 1316411710, + "mana_used": 99651852, + "proving_cost_per_mana_numerator": 1030218038, + "fee_asset_price_numerator": 1640498241 + }, + "oracle_input": { + "proving_cost_modifier": -185982733, + "fee_asset_price_modifier": -291657500 + }, + "outputs": { + "fee_asset_price_at_execution": 10195094267, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29770003, + "proving_cost": 5481621713, + "congestion_cost": 20202178411, + "congestion_multiplier": 4665531222 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 303507986, + "proving_cost": 55885650100, + "congestion_cost": 205963113298, + "congestion_multiplier": 4665531222 + } + } + }, + { + "l1_block_number": 20974550, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9961876485 + }, + "parent_header": { + "excess_mana": 1316411710, + "mana_used": 99651852, + "proving_cost_per_mana_numerator": 1030218038, + "fee_asset_price_numerator": 1640498241 + }, + "header": { + "excess_mana": 1316063562, + "mana_used": 111037651, + "proving_cost_per_mana_numerator": 873740990, + "fee_asset_price_numerator": 1361795236 + }, + "oracle_input": { + "proving_cost_modifier": -156477048, + "fee_asset_price_modifier": -278703005 + }, + "outputs": { + "fee_asset_price_at_execution": 10165402829, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32998715, + "proving_cost": 5471436318, + "congestion_cost": 20166219837, + "congestion_multiplier": 4663631184 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 335445230, + "proving_cost": 55619354225, + "congestion_cost": 204997748181, + "congestion_multiplier": 4663631184 + } + } + }, + { + "l1_block_number": 20974553, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9733495056 + }, + "parent_header": { + "excess_mana": 1316063562, + "mana_used": 111037651, + "proving_cost_per_mana_numerator": 873740990, + "fee_asset_price_numerator": 1361795236 + }, + "header": { + "excess_mana": 1327101213, + "mana_used": 92008411, + "proving_cost_per_mana_numerator": 898901189, + "fee_asset_price_numerator": 1044864044 + }, + "oracle_input": { + "proving_cost_modifier": 25160199, + "fee_asset_price_modifier": -316931192 + }, + "outputs": { + "fee_asset_price_at_execution": 10137110990, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32242202, + "proving_cost": 5462881471, + "congestion_cost": 20465204013, + "congestion_multiplier": 4724248121 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 326842780, + "proving_cost": 55377835796, + "congestion_cost": 207458044512, + "congestion_multiplier": 4724248121 + } + } + }, + { + "l1_block_number": 20974556, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9375339716 + }, + "parent_header": { + "excess_mana": 1327101213, + "mana_used": 92008411, + "proving_cost_per_mana_numerator": 898901189, + "fee_asset_price_numerator": 1044864044 + }, + "header": { + "excess_mana": 1319109624, + "mana_used": 102382194, + "proving_cost_per_mana_numerator": 1025217469, + "fee_asset_price_numerator": 1697126570 + }, + "oracle_input": { + "proving_cost_modifier": 126316280, + "fee_asset_price_modifier": 652262526 + }, + "outputs": { + "fee_asset_price_at_execution": 10105034181, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31055812, + "proving_cost": 5464256115, + "congestion_cost": 20224294915, + "congestion_multiplier": 4680281517 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313820041, + "proving_cost": 55216494815, + "congestion_cost": 204367191402, + "congestion_multiplier": 4680281517 + } + } + }, + { + "l1_block_number": 20974559, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9597087327 + }, + "parent_header": { + "excess_mana": 1319109624, + "mana_used": 102382194, + "proving_cost_per_mana_numerator": 1025217469, + "fee_asset_price_numerator": 1697126570 + }, + "header": { + "excess_mana": 1321491818, + "mana_used": 110585080, + "proving_cost_per_mana_numerator": 988477843, + "fee_asset_price_numerator": 843566589 + }, + "oracle_input": { + "proving_cost_modifier": -36739626, + "fee_asset_price_modifier": -853559981 + }, + "outputs": { + "fee_asset_price_at_execution": 10171160957, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31790351, + "proving_cost": 5471162722, + "congestion_cost": 20324301130, + "congestion_multiplier": 4693344439 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 323344776, + "proving_cost": 55648076667, + "congestion_cost": 206721738131, + "congestion_multiplier": 4693344439 + } + } + }, + { + "l1_block_number": 20974562, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10268313101 + }, + "parent_header": { + "excess_mana": 1321491818, + "mana_used": 110585080, + "proving_cost_per_mana_numerator": 988477843, + "fee_asset_price_numerator": 843566589 + }, + "header": { + "excess_mana": 1332076898, + "mana_used": 92593419, + "proving_cost_per_mana_numerator": 932263532, + "fee_asset_price_numerator": 456153193 + }, + "oracle_input": { + "proving_cost_modifier": -56214311, + "fee_asset_price_modifier": -387413396 + }, + "outputs": { + "fee_asset_price_at_execution": 10084713463, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34013787, + "proving_cost": 5469153006, + "congestion_cost": 20646950577, + "congestion_multiplier": 4751830783 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 343019295, + "proving_cost": 55154840950, + "congestion_cost": 208218580453, + "congestion_multiplier": 4751830783 + } + } + }, + { + "l1_block_number": 20974565, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9810780355 + }, + "parent_header": { + "excess_mana": 1332076898, + "mana_used": 92593419, + "proving_cost_per_mana_numerator": 932263532, + "fee_asset_price_numerator": 456153193 + }, + "header": { + "excess_mana": 1324670317, + "mana_used": 90724497, + "proving_cost_per_mana_numerator": 794288972, + "fee_asset_price_numerator": 128315644 + }, + "oracle_input": { + "proving_cost_modifier": -137974560, + "fee_asset_price_modifier": -327837549 + }, + "outputs": { + "fee_asset_price_at_execution": 10045719515, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32498209, + "proving_cost": 5466079423, + "congestion_cost": 20404290947, + "congestion_multiplier": 4710830748 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 326467892, + "proving_cost": 54910700730, + "congestion_cost": 204975783756, + "congestion_multiplier": 4710830748 + } + } + }, + { + "l1_block_number": 20974568, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10144246321 + }, + "parent_header": { + "excess_mana": 1324670317, + "mana_used": 90724497, + "proving_cost_per_mana_numerator": 794288972, + "fee_asset_price_numerator": 128315644 + }, + "header": { + "excess_mana": 1315394814, + "mana_used": 111555165, + "proving_cost_per_mana_numerator": 868429096, + "fee_asset_price_numerator": 675668512 + }, + "oracle_input": { + "proving_cost_modifier": 74140124, + "fee_asset_price_modifier": 547352868 + }, + "outputs": { + "fee_asset_price_at_execution": 10012839800, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33602815, + "proving_cost": 5458542825, + "congestion_cost": 20101163092, + "congestion_multiplier": 4659983622 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336459603, + "proving_cost": 54655514848, + "congestion_cost": 201269725833, + "congestion_multiplier": 4659983622 + } + } + }, + { + "l1_block_number": 20974571, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9686834828 + }, + "parent_header": { + "excess_mana": 1315394814, + "mana_used": 111555165, + "proving_cost_per_mana_numerator": 868429096, + "fee_asset_price_numerator": 675668512 + }, + "header": { + "excess_mana": 1326949979, + "mana_used": 99938676, + "proving_cost_per_mana_numerator": 896089675, + "fee_asset_price_numerator": 448902582 + }, + "oracle_input": { + "proving_cost_modifier": 27660579, + "fee_asset_price_modifier": -226765930 + }, + "outputs": { + "fee_asset_price_at_execution": 10067795630, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32087640, + "proving_cost": 5462591296, + "congestion_cost": 20458954959, + "congestion_multiplier": 4723412268 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 323051801, + "proving_cost": 54996252778, + "congestion_cost": 205976577330, + "congestion_multiplier": 4723412268 + } + } + }, + { + "l1_block_number": 20974574, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9943977596 + }, + "parent_header": { + "excess_mana": 1326949979, + "mana_used": 99938676, + "proving_cost_per_mana_numerator": 896089675, + "fee_asset_price_numerator": 448902582 + }, + "header": { + "excess_mana": 1326888655, + "mana_used": 99622249, + "proving_cost_per_mana_numerator": 877465442, + "fee_asset_price_numerator": 22204524 + }, + "oracle_input": { + "proving_cost_modifier": -18624233, + "fee_asset_price_modifier": -426698058 + }, + "outputs": { + "fee_asset_price_at_execution": 10044991165, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32939425, + "proving_cost": 5464102489, + "congestion_cost": 20465890418, + "congestion_multiplier": 4723073380 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 330876233, + "proving_cost": 54886861226, + "congestion_cost": 205579688432, + "congestion_multiplier": 4723073380 + } + } + }, + { + "l1_block_number": 20974577, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8945291339 + }, + "parent_header": { + "excess_mana": 1326888655, + "mana_used": 99622249, + "proving_cost_per_mana_numerator": 877465442, + "fee_asset_price_numerator": 22204524 + }, + "header": { + "excess_mana": 1326510904, + "mana_used": 84100471, + "proving_cost_per_mana_numerator": 805729104, + "fee_asset_price_numerator": 259780126 + }, + "oracle_input": { + "proving_cost_modifier": -71736338, + "fee_asset_price_modifier": 237575602 + }, + "outputs": { + "fee_asset_price_at_execution": 10002220698, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29631277, + "proving_cost": 5463084937, + "congestion_cost": 20438322281, + "congestion_multiplier": 4720986391 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 296378572, + "proving_cost": 54642981231, + "congestion_cost": 204428610151, + "congestion_multiplier": 4720986391 + } + } + }, + { + "l1_block_number": 20974580, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10038998201 + }, + "parent_header": { + "excess_mana": 1326510904, + "mana_used": 84100471, + "proving_cost_per_mana_numerator": 805729104, + "fee_asset_price_numerator": 259780126 + }, + "header": { + "excess_mana": 1310611375, + "mana_used": 103492289, + "proving_cost_per_mana_numerator": 792740469, + "fee_asset_price_numerator": 340660283 + }, + "oracle_input": { + "proving_cost_modifier": -12988635, + "fee_asset_price_modifier": 80880157 + }, + "outputs": { + "fee_asset_price_at_execution": 10026011784, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33254181, + "proving_cost": 5459167325, + "congestion_cost": 19959329538, + "congestion_multiplier": 4633976292 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 333406810, + "proving_cost": 54733675931, + "congestion_cost": 200112473148, + "congestion_multiplier": 4633976292 + } + } + }, + { + "l1_block_number": 20974583, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10272200406 + }, + "parent_header": { + "excess_mana": 1310611375, + "mana_used": 103492289, + "proving_cost_per_mana_numerator": 792740469, + "fee_asset_price_numerator": 340660283 + }, + "header": { + "excess_mana": 1314103664, + "mana_used": 0, + "proving_cost_per_mana_numerator": 668559792, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -124180677, + "fee_asset_price_modifier": -608328780 + }, + "outputs": { + "fee_asset_price_at_execution": 10034124118, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34026663, + "proving_cost": 5458458300, + "congestion_cost": 20063769391, + "congestion_multiplier": 4652949353 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 341427759, + "proving_cost": 54770848075, + "congestion_cost": 201322352344, + "congestion_multiplier": 4652949353 + } + } + }, + { + "l1_block_number": 20974586, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10159830088 + }, + "parent_header": { + "excess_mana": 1314103664, + "mana_used": 0, + "proving_cost_per_mana_numerator": 668559792, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1214103664, + "mana_used": 174322033, + "proving_cost_per_mana_numerator": 520915187, + "fee_asset_price_numerator": 191162968 + }, + "oracle_input": { + "proving_cost_modifier": -147644605, + "fee_asset_price_modifier": 191162968 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33654437, + "proving_cost": 5451684156, + "congestion_cost": 17219546656, + "congestion_multiplier": 4139194849 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336544370, + "proving_cost": 54516841560, + "congestion_cost": 172195466560, + "congestion_multiplier": 4139194849 + } + } + }, + { + "l1_block_number": 20974589, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11362253728 + }, + "parent_header": { + "excess_mana": 1214103664, + "mana_used": 174322033, + "proving_cost_per_mana_numerator": 520915187, + "fee_asset_price_numerator": 191162968 + }, + "header": { + "excess_mana": 1288425697, + "mana_used": 118595109, + "proving_cost_per_mana_numerator": 416693447, + "fee_asset_price_numerator": 185644548 + }, + "oracle_input": { + "proving_cost_modifier": -104221740, + "fee_asset_price_modifier": -5518420 + }, + "outputs": { + "fee_asset_price_at_execution": 10019134580, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37637465, + "proving_cost": 5443640978, + "congestion_cost": 19268002426, + "congestion_multiplier": 4515238758 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 377094827, + "proving_cost": 54540571563, + "congestion_cost": 193048709393, + "congestion_multiplier": 4515238758 + } + } + }, + { + "l1_block_number": 20974592, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10488705208 + }, + "parent_header": { + "excess_mana": 1288425697, + "mana_used": 118595109, + "proving_cost_per_mana_numerator": 416693447, + "fee_asset_price_numerator": 185644548 + }, + "header": { + "excess_mana": 1307020806, + "mana_used": 107609608, + "proving_cost_per_mana_numerator": 453557170, + "fee_asset_price_numerator": 619717024 + }, + "oracle_input": { + "proving_cost_modifier": 36863723, + "fee_asset_price_modifier": 434072476 + }, + "outputs": { + "fee_asset_price_at_execution": 10018581697, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34743836, + "proving_cost": 5437970476, + "congestion_cost": 19781399242, + "congestion_multiplier": 4614549950 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 348083959, + "proving_cost": 54480751479, + "congestion_cost": 198181564386, + "congestion_multiplier": 4614549950 + } + } + }, + { + "l1_block_number": 20974595, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9462366449 + }, + "parent_header": { + "excess_mana": 1307020806, + "mana_used": 107609608, + "proving_cost_per_mana_numerator": 453557170, + "fee_asset_price_numerator": 619717024 + }, + "header": { + "excess_mana": 1314630414, + "mana_used": 92131303, + "proving_cost_per_mana_numerator": 531888880, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 78331710, + "fee_asset_price_modifier": -692817214 + }, + "outputs": { + "fee_asset_price_at_execution": 10062164124, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31344088, + "proving_cost": 5439975484, + "congestion_cost": 20002147688, + "congestion_multiplier": 4655817838 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 315389357, + "proving_cost": 54737926150, + "congestion_cost": 201264892869, + "congestion_multiplier": 4655817838 + } + } + }, + { + "l1_block_number": 20974598, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9421740766 + }, + "parent_header": { + "excess_mana": 1314630414, + "mana_used": 92131303, + "proving_cost_per_mana_numerator": 531888880, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1306761717, + "mana_used": 103809271, + "proving_cost_per_mana_numerator": 538177512, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 6288632, + "fee_asset_price_modifier": -126737791 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31209516, + "proving_cost": 5444238379, + "congestion_cost": 19783621866, + "congestion_multiplier": 4613151334 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312095160, + "proving_cost": 54442383790, + "congestion_cost": 197836218660, + "congestion_multiplier": 4613151334 + } + } + }, + { + "l1_block_number": 20974601, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9237341401 + }, + "parent_header": { + "excess_mana": 1306761717, + "mana_used": 103809271, + "proving_cost_per_mana_numerator": 538177512, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1310570988, + "mana_used": 113120852, + "proving_cost_per_mana_numerator": 543916368, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 5738856, + "fee_asset_price_modifier": -73019921 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30598693, + "proving_cost": 5444580758, + "congestion_cost": 19895473457, + "congestion_multiplier": 4633757329 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 305986930, + "proving_cost": 54445807580, + "congestion_cost": 198954734570, + "congestion_multiplier": 4633757329 + } + } + }, + { + "l1_block_number": 20974604, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10238465003 + }, + "parent_header": { + "excess_mana": 1310570988, + "mana_used": 113120852, + "proving_cost_per_mana_numerator": 543916368, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1323691840, + "mana_used": 92397177, + "proving_cost_per_mana_numerator": 426314838, + "fee_asset_price_numerator": 243102440 + }, + "oracle_input": { + "proving_cost_modifier": -117601530, + "fee_asset_price_modifier": 243102440 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33914915, + "proving_cost": 5444893224, + "congestion_cost": 20301399153, + "congestion_multiplier": 4705440789 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 339149150, + "proving_cost": 54448932240, + "congestion_cost": 203013991530, + "congestion_multiplier": 4705440789 + } + } + }, + { + "l1_block_number": 20974607, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9761510720 + }, + "parent_header": { + "excess_mana": 1323691840, + "mana_used": 92397177, + "proving_cost_per_mana_numerator": 426314838, + "fee_asset_price_numerator": 243102440 + }, + "header": { + "excess_mana": 1316089017, + "mana_used": 101644078, + "proving_cost_per_mana_numerator": 570636341, + "fee_asset_price_numerator": 609906024 + }, + "oracle_input": { + "proving_cost_modifier": 144321503, + "fee_asset_price_modifier": 366803584 + }, + "outputs": { + "fee_asset_price_at_execution": 10024339817, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32335004, + "proving_cost": 5438493710, + "congestion_cost": 20043858555, + "congestion_multiplier": 4663770080 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 324137068, + "proving_cost": 54517309041, + "congestion_cost": 200926449399, + "congestion_multiplier": 4663770080 + } + } + }, + { + "l1_block_number": 20974610, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9386744044 + }, + "parent_header": { + "excess_mana": 1316089017, + "mana_used": 101644078, + "proving_cost_per_mana_numerator": 570636341, + "fee_asset_price_numerator": 609906024 + }, + "header": { + "excess_mana": 1317733095, + "mana_used": 92675049, + "proving_cost_per_mana_numerator": 666417343, + "fee_asset_price_numerator": 832510984 + }, + "oracle_input": { + "proving_cost_modifier": 95781002, + "fee_asset_price_modifier": 222604960 + }, + "outputs": { + "fee_asset_price_at_execution": 10061176973, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31093589, + "proving_cost": 5446348292, + "congestion_cost": 20117273616, + "congestion_multiplier": 4672749808 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312838101, + "proving_cost": 54796674022, + "congestion_cost": 202403450064, + "congestion_multiplier": 4672749808 + } + } + }, + { + "l1_block_number": 20974613, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9635997754 + }, + "parent_header": { + "excess_mana": 1317733095, + "mana_used": 92675049, + "proving_cost_per_mana_numerator": 666417343, + "fee_asset_price_numerator": 832510984 + }, + "header": { + "excess_mana": 1310408144, + "mana_used": 98945719, + "proving_cost_per_mana_numerator": 637579467, + "fee_asset_price_numerator": 78183892 + }, + "oracle_input": { + "proving_cost_modifier": -28837876, + "fee_asset_price_modifier": -754327092 + }, + "outputs": { + "fee_asset_price_at_execution": 10083598599, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31919242, + "proving_cost": 5451567358, + "congestion_cost": 19920818941, + "congestion_multiplier": 4632874555 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 321860823, + "proving_cost": 54971416973, + "congestion_cost": 200873541964, + "congestion_multiplier": 4632874555 + } + } + }, + { + "l1_block_number": 20974616, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9497835793 + }, + "parent_header": { + "excess_mana": 1310408144, + "mana_used": 98945719, + "proving_cost_per_mana_numerator": 637579467, + "fee_asset_price_numerator": 78183892 + }, + "header": { + "excess_mana": 1309353863, + "mana_used": 104843069, + "proving_cost_per_mana_numerator": 727519356, + "fee_asset_price_numerator": 219999797 + }, + "oracle_input": { + "proving_cost_modifier": 89939889, + "fee_asset_price_modifier": 141815905 + }, + "outputs": { + "fee_asset_price_at_execution": 10007821446, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31461581, + "proving_cost": 5449995468, + "congestion_cost": 19882140315, + "congestion_multiplier": 4627163387 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 314861885, + "proving_cost": 54542581525, + "congestion_cost": 198976910236, + "congestion_multiplier": 4627163387 + } + } + }, + { + "l1_block_number": 20974619, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9784258718 + }, + "parent_header": { + "excess_mana": 1309353863, + "mana_used": 104843069, + "proving_cost_per_mana_numerator": 727519356, + "fee_asset_price_numerator": 219999797 + }, + "header": { + "excess_mana": 1314196932, + "mana_used": 108701348, + "proving_cost_per_mana_numerator": 695500631, + "fee_asset_price_numerator": 352336839 + }, + "oracle_input": { + "proving_cost_modifier": -32018725, + "fee_asset_price_modifier": 132337042 + }, + "outputs": { + "fee_asset_price_at_execution": 10022024197, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32410357, + "proving_cost": 5454899393, + "congestion_cost": 20047650914, + "congestion_multiplier": 4653457127 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 324817382, + "proving_cost": 54669133708, + "congestion_cost": 200918042553, + "congestion_multiplier": 4653457127 + } + } + }, + { + "l1_block_number": 20974622, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9822631866 + }, + "parent_header": { + "excess_mana": 1314196932, + "mana_used": 108701348, + "proving_cost_per_mana_numerator": 695500631, + "fee_asset_price_numerator": 352336839 + }, + "header": { + "excess_mana": 1322898280, + "mana_used": 91385697, + "proving_cost_per_mana_numerator": 809869333, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 114368702, + "fee_asset_price_modifier": -624014969 + }, + "outputs": { + "fee_asset_price_at_execution": 10035295827, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32537468, + "proving_cost": 5453153084, + "congestion_cost": 20302946558, + "congestion_multiplier": 4701073979 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 326523116, + "proving_cost": 54724004387, + "congestion_cost": 203746074869, + "congestion_multiplier": 4701073979 + } + } + }, + { + "l1_block_number": 20974625, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10157914688 + }, + "parent_header": { + "excess_mana": 1322898280, + "mana_used": 91385697, + "proving_cost_per_mana_numerator": 809869333, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1314283977, + "mana_used": 116675075, + "proving_cost_per_mana_numerator": 782149905, + "fee_asset_price_numerator": 622366323 + }, + "oracle_input": { + "proving_cost_modifier": -27719428, + "fee_asset_price_modifier": 622366323 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33648092, + "proving_cost": 5459393352, + "congestion_cost": 20071194812, + "congestion_multiplier": 4653931072 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336480920, + "proving_cost": 54593933520, + "congestion_cost": 200711948120, + "congestion_multiplier": 4653931072 + } + } + }, + { + "l1_block_number": 20974628, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10107349159 + }, + "parent_header": { + "excess_mana": 1314283977, + "mana_used": 116675075, + "proving_cost_per_mana_numerator": 782149905, + "fee_asset_price_numerator": 622366323 + }, + "header": { + "excess_mana": 1330959052, + "mana_used": 26049996, + "proving_cost_per_mana_numerator": 742577896, + "fee_asset_price_numerator": 880139489 + }, + "oracle_input": { + "proving_cost_modifier": -39572009, + "fee_asset_price_modifier": 257773166 + }, + "outputs": { + "fee_asset_price_at_execution": 10062430704, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33480594, + "proving_cost": 5457880249, + "congestion_cost": 20568551121, + "congestion_multiplier": 4745620022 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336896157, + "proving_cost": 54919541796, + "congestion_cost": 206969620336, + "congestion_multiplier": 4745620022 + } + } + }, + { + "l1_block_number": 20974631, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9986090744 + }, + "parent_header": { + "excess_mana": 1330959052, + "mana_used": 26049996, + "proving_cost_per_mana_numerator": 742577896, + "fee_asset_price_numerator": 880139489 + }, + "header": { + "excess_mana": 1257009048, + "mana_used": 151212674, + "proving_cost_per_mana_numerator": 809308729, + "fee_asset_price_numerator": 870419648 + }, + "oracle_input": { + "proving_cost_modifier": 66730833, + "fee_asset_price_modifier": -9719841 + }, + "outputs": { + "fee_asset_price_at_execution": 10088402410, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33078925, + "proving_cost": 5455720883, + "congestion_cost": 18400011532, + "congestion_multiplier": 4352283227 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 333713506, + "proving_cost": 55039507704, + "congestion_cost": 185626720683, + "congestion_multiplier": 4352283227 + } + } + }, + { + "l1_block_number": 20974634, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10010324507 + }, + "parent_header": { + "excess_mana": 1257009048, + "mana_used": 151212674, + "proving_cost_per_mana_numerator": 809308729, + "fee_asset_price_numerator": 870419648 + }, + "header": { + "excess_mana": 1308221722, + "mana_used": 101948161, + "proving_cost_per_mana_numerator": 809758637, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 449908, + "fee_asset_price_modifier": -1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10087421881, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33159199, + "proving_cost": 5459362746, + "congestion_cost": 19888632222, + "congestion_multiplier": 4621038281 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334490829, + "proving_cost": 55070895220, + "congestion_cost": 200625023859, + "congestion_multiplier": 4621038281 + } + } + }, + { + "l1_block_number": 20974637, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10017086529 + }, + "parent_header": { + "excess_mana": 1308221722, + "mana_used": 101948161, + "proving_cost_per_mana_numerator": 809758637, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1310169883, + "mana_used": 111174043, + "proving_cost_per_mana_numerator": 741892216, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -67866421, + "fee_asset_price_modifier": -726341690 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33181599, + "proving_cost": 5459387308, + "congestion_cost": 19946721242, + "congestion_multiplier": 4631583250 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 331815990, + "proving_cost": 54593873080, + "congestion_cost": 199467212420, + "congestion_multiplier": 4631583250 + } + } + }, + { + "l1_block_number": 20974640, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10370308177 + }, + "parent_header": { + "excess_mana": 1310169883, + "mana_used": 111174043, + "proving_cost_per_mana_numerator": 741892216, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1321343926, + "mana_used": 94802248, + "proving_cost_per_mana_numerator": 773959935, + "fee_asset_price_numerator": 114448902 + }, + "oracle_input": { + "proving_cost_modifier": 32067719, + "fee_asset_price_modifier": 114448902 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34351645, + "proving_cost": 5455683475, + "congestion_cost": 20272132568, + "congestion_multiplier": 4692532402 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 343516450, + "proving_cost": 54556834750, + "congestion_cost": 202721325680, + "congestion_multiplier": 4692532402 + } + } + }, + { + "l1_block_number": 20974643, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10404764610 + }, + "parent_header": { + "excess_mana": 1321343926, + "mana_used": 94802248, + "proving_cost_per_mana_numerator": 773959935, + "fee_asset_price_numerator": 114448902 + }, + "header": { + "excess_mana": 1316146174, + "mana_used": 109144403, + "proving_cost_per_mana_numerator": 798378003, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 24418068, + "fee_asset_price_modifier": -501532851 + }, + "outputs": { + "fee_asset_price_at_execution": 10011451441, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34465782, + "proving_cost": 5457433268, + "congestion_cost": 20122768312, + "congestion_multiplier": 4664081974 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 345052502, + "proving_cost": 54636828155, + "congestion_cost": 201458117814, + "congestion_multiplier": 4664081974 + } + } + }, + { + "l1_block_number": 20974646, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10629066393 + }, + "parent_header": { + "excess_mana": 1316146174, + "mana_used": 109144403, + "proving_cost_per_mana_numerator": 798378003, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1325290577, + "mana_used": 34899899, + "proving_cost_per_mana_numerator": 839834293, + "fee_asset_price_numerator": 457917274 + }, + "oracle_input": { + "proving_cost_modifier": 41456290, + "fee_asset_price_modifier": 457917274 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35208782, + "proving_cost": 5458766031, + "congestion_cost": 20405999564, + "congestion_multiplier": 4714250658 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 352087820, + "proving_cost": 54587660310, + "congestion_cost": 204059995640, + "congestion_multiplier": 4714250658 + } + } + }, + { + "l1_block_number": 20974649, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10631215552 + }, + "parent_header": { + "excess_mana": 1325290577, + "mana_used": 34899899, + "proving_cost_per_mana_numerator": 839834293, + "fee_asset_price_numerator": 457917274 + }, + "header": { + "excess_mana": 1260190476, + "mana_used": 128319221, + "proving_cost_per_mana_numerator": 981905891, + "fee_asset_price_numerator": 1121443867 + }, + "oracle_input": { + "proving_cost_modifier": 142071598, + "fee_asset_price_modifier": 663526593 + }, + "outputs": { + "fee_asset_price_at_execution": 10045896731, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35215901, + "proving_cost": 5461029502, + "congestion_cost": 18514178449, + "congestion_multiplier": 4368513793 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 353775304, + "proving_cost": 54860938422, + "congestion_cost": 185991524757, + "congestion_multiplier": 4368513793 + } + } + }, + { + "l1_block_number": 20974652, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10463260499 + }, + "parent_header": { + "excess_mana": 1260190476, + "mana_used": 128319221, + "proving_cost_per_mana_numerator": 981905891, + "fee_asset_price_numerator": 1121443867 + }, + "header": { + "excess_mana": 1288509697, + "mana_used": 124344163, + "proving_cost_per_mana_numerator": 835441805, + "fee_asset_price_numerator": 944547786 + }, + "oracle_input": { + "proving_cost_modifier": -146464086, + "fee_asset_price_modifier": -176896081 + }, + "outputs": { + "fee_asset_price_at_execution": 10112775562, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34659550, + "proving_cost": 5468793588, + "congestion_cost": 19348394095, + "congestion_multiplier": 4515682538 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 350504250, + "proving_cost": 55304682150, + "congestion_cost": 195665966967, + "congestion_multiplier": 4515682538 + } + } + }, + { + "l1_block_number": 20974655, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10685244750 + }, + "parent_header": { + "excess_mana": 1288509697, + "mana_used": 124344163, + "proving_cost_per_mana_numerator": 835441805, + "fee_asset_price_numerator": 944547786 + }, + "header": { + "excess_mana": 1312853860, + "mana_used": 102282782, + "proving_cost_per_mana_numerator": 809561222, + "fee_asset_price_numerator": 1057140318 + }, + "oracle_input": { + "proving_cost_modifier": -25880583, + "fee_asset_price_modifier": 112592532 + }, + "outputs": { + "fee_asset_price_at_execution": 10094902271, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35394873, + "proving_cost": 5460789632, + "congestion_cost": 20039915628, + "congestion_multiplier": 4646150454 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 357307783, + "proving_cost": 55126137657, + "congestion_cost": 202300989783, + "congestion_multiplier": 4646150454 + } + } + }, + { + "l1_block_number": 20974658, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10095519528 + }, + "parent_header": { + "excess_mana": 1312853860, + "mana_used": 102282782, + "proving_cost_per_mana_numerator": 809561222, + "fee_asset_price_numerator": 1057140318 + }, + "header": { + "excess_mana": 1315136642, + "mana_used": 92935415, + "proving_cost_per_mana_numerator": 706535974, + "fee_asset_price_numerator": 1963428252 + }, + "oracle_input": { + "proving_cost_modifier": -103025248, + "fee_asset_price_modifier": 906287934 + }, + "outputs": { + "fee_asset_price_at_execution": 10106274778, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33441408, + "proving_cost": 5459376531, + "congestion_cost": 20095893169, + "congestion_multiplier": 4658576234 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 337968058, + "proving_cost": 55173959338, + "congestion_cost": 203094618275, + "congestion_multiplier": 4658576234 + } + } + }, + { + "l1_block_number": 20974661, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9964934916 + }, + "parent_header": { + "excess_mana": 1315136642, + "mana_used": 92935415, + "proving_cost_per_mana_numerator": 706535974, + "fee_asset_price_numerator": 1963428252 + }, + "header": { + "excess_mana": 1308072057, + "mana_used": 6890906, + "proving_cost_per_mana_numerator": 553003059, + "fee_asset_price_numerator": 1708530634 + }, + "oracle_input": { + "proving_cost_modifier": -153532915, + "fee_asset_price_modifier": -254897618 + }, + "outputs": { + "fee_asset_price_at_execution": 10198283027, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33008846, + "proving_cost": 5453754891, + "congestion_cost": 19863342129, + "congestion_multiplier": 4620229170 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336633553, + "proving_cost": 55618935938, + "congestion_cost": 202571984893, + "congestion_multiplier": 4620229170 + } + } + }, + { + "l1_block_number": 20974664, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9868829086 + }, + "parent_header": { + "excess_mana": 1308072057, + "mana_used": 6890906, + "proving_cost_per_mana_numerator": 553003059, + "fee_asset_price_numerator": 1708530634 + }, + "header": { + "excess_mana": 1214962963, + "mana_used": 191542383, + "proving_cost_per_mana_numerator": 649849607, + "fee_asset_price_numerator": 2185828457 + }, + "oracle_input": { + "proving_cost_modifier": 96846548, + "fee_asset_price_modifier": 477297823 + }, + "outputs": { + "fee_asset_price_at_execution": 10172320949, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32690496, + "proving_cost": 5445388007, + "congestion_cost": 17219564100, + "congestion_multiplier": 4143358404 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332538217, + "proving_cost": 55392234499, + "congestion_cost": 175162932627, + "congestion_multiplier": 4143358404 + } + } + }, + { + "l1_block_number": 20974667, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9796157813 + }, + "parent_header": { + "excess_mana": 1214962963, + "mana_used": 191542383, + "proving_cost_per_mana_numerator": 649849607, + "fee_asset_price_numerator": 2185828457 + }, + "header": { + "excess_mana": 1306505346, + "mana_used": 112909870, + "proving_cost_per_mana_numerator": 576325080, + "fee_asset_price_numerator": 2027932310 + }, + "oracle_input": { + "proving_cost_modifier": -73524527, + "fee_asset_price_modifier": -157896147 + }, + "outputs": { + "fee_asset_price_at_execution": 10220989270, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32449772, + "proving_cost": 5450664231, + "congestion_cost": 19803734643, + "congestion_multiplier": 4611767808 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 331668771, + "proving_cost": 55711180619, + "congestion_cost": 202413759292, + "congestion_multiplier": 4611767808 + } + } + }, + { + "l1_block_number": 20974670, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9423895660 + }, + "parent_header": { + "excess_mana": 1306505346, + "mana_used": 112909870, + "proving_cost_per_mana_numerator": 576325080, + "fee_asset_price_numerator": 2027932310 + }, + "header": { + "excess_mana": 1319415216, + "mana_used": 88953936, + "proving_cost_per_mana_numerator": 561262646, + "fee_asset_price_numerator": 2413894340 + }, + "oracle_input": { + "proving_cost_modifier": -15062434, + "fee_asset_price_modifier": 385962030 + }, + "outputs": { + "fee_asset_price_at_execution": 10204863456, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31216654, + "proving_cost": 5446658129, + "congestion_cost": 20169289629, + "congestion_multiplier": 4681955216 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318561691, + "proving_cost": 55582402497, + "congestion_cost": 205824846668, + "congestion_multiplier": 4681955216 + } + } + }, + { + "l1_block_number": 20974673, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8779402628 + }, + "parent_header": { + "excess_mana": 1319415216, + "mana_used": 88953936, + "proving_cost_per_mana_numerator": 561262646, + "fee_asset_price_numerator": 2413894340 + }, + "header": { + "excess_mana": 1308369152, + "mana_used": 108956671, + "proving_cost_per_mana_numerator": 561045656, + "fee_asset_price_numerator": 1553870436 + }, + "oracle_input": { + "proving_cost_modifier": -216990, + "fee_asset_price_modifier": -860023904 + }, + "outputs": { + "fee_asset_price_at_execution": 10244326461, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29081771, + "proving_cost": 5445837792, + "congestion_cost": 19829257737, + "congestion_multiplier": 4621835446 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 297923156, + "proving_cost": 55788940194, + "congestion_cost": 203137389737, + "congestion_multiplier": 4621835446 + } + } + }, + { + "l1_block_number": 20974676, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9296854474 + }, + "parent_header": { + "excess_mana": 1308369152, + "mana_used": 108956671, + "proving_cost_per_mana_numerator": 561045656, + "fee_asset_price_numerator": 1553870436 + }, + "header": { + "excess_mana": 1317325823, + "mana_used": 94389617, + "proving_cost_per_mana_numerator": 550791710, + "fee_asset_price_numerator": 769518212 + }, + "oracle_input": { + "proving_cost_modifier": -10253946, + "fee_asset_price_modifier": -784352224 + }, + "outputs": { + "fee_asset_price_at_execution": 10156600577, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30795830, + "proving_cost": 5445825975, + "congestion_cost": 20102070317, + "congestion_multiplier": 4670523734 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312780944, + "proving_cost": 55311079239, + "congestion_cost": 204168698980, + "congestion_multiplier": 4670523734 + } + } + }, + { + "l1_block_number": 20974679, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9564836737 + }, + "parent_header": { + "excess_mana": 1317325823, + "mana_used": 94389617, + "proving_cost_per_mana_numerator": 550791710, + "fee_asset_price_numerator": 769518212 + }, + "header": { + "excess_mana": 1311715440, + "mana_used": 102928262, + "proving_cost_per_mana_numerator": 576833814, + "fee_asset_price_numerator": 741678651 + }, + "oracle_input": { + "proving_cost_modifier": 26042104, + "fee_asset_price_modifier": -27839561 + }, + "outputs": { + "fee_asset_price_at_execution": 10077248661, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31683521, + "proving_cost": 5445267591, + "congestion_cost": 19935916526, + "congestion_multiplier": 4639966127 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 319282719, + "proving_cost": 54873315540, + "congestion_cost": 200899188117, + "congestion_multiplier": 4639966127 + } + } + }, + { + "l1_block_number": 20974682, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9381667937 + }, + "parent_header": { + "excess_mana": 1311715440, + "mana_used": 102928262, + "proving_cost_per_mana_numerator": 576833814, + "fee_asset_price_numerator": 741678651 + }, + "header": { + "excess_mana": 1314643702, + "mana_used": 108617085, + "proving_cost_per_mana_numerator": 526666518, + "fee_asset_price_numerator": 351476175 + }, + "oracle_input": { + "proving_cost_modifier": -50167296, + "fee_asset_price_modifier": -390202476 + }, + "outputs": { + "fee_asset_price_at_execution": 10074443589, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31076775, + "proving_cost": 5446685838, + "congestion_cost": 20026098775, + "congestion_multiplier": 4655890222 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313081216, + "proving_cost": 54872329221, + "congestion_cost": 201751802416, + "congestion_multiplier": 4655890222 + } + } + }, + { + "l1_block_number": 20974685, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10397713754 + }, + "parent_header": { + "excess_mana": 1314643702, + "mana_used": 108617085, + "proving_cost_per_mana_numerator": 526666518, + "fee_asset_price_numerator": 351476175 + }, + "header": { + "excess_mana": 1323260787, + "mana_used": 31017300, + "proving_cost_per_mana_numerator": 449660495, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -77006023, + "fee_asset_price_modifier": -788587719 + }, + "outputs": { + "fee_asset_price_at_execution": 10035209457, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34442426, + "proving_cost": 5443954069, + "congestion_cost": 20286876302, + "congestion_multiplier": 4703068283 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 345636959, + "proving_cost": 54631219356, + "congestion_cost": 203583052918, + "congestion_multiplier": 4703068283 + } + } + }, + { + "l1_block_number": 20974688, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9445339829 + }, + "parent_header": { + "excess_mana": 1323260787, + "mana_used": 31017300, + "proving_cost_per_mana_numerator": 449660495, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1254278087, + "mana_used": 141703611, + "proving_cost_per_mana_numerator": 494464778, + "fee_asset_price_numerator": 227098236 + }, + "oracle_input": { + "proving_cost_modifier": 44804283, + "fee_asset_price_modifier": 227098236 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31287688, + "proving_cost": 5439763510, + "congestion_cost": 18264551295, + "congestion_multiplier": 4338398899 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312876880, + "proving_cost": 54397635100, + "congestion_cost": 182645512950, + "congestion_multiplier": 4338398899 + } + } + }, + { + "l1_block_number": 20974691, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9351751903 + }, + "parent_header": { + "excess_mana": 1254278087, + "mana_used": 141703611, + "proving_cost_per_mana_numerator": 494464778, + "fee_asset_price_numerator": 227098236 + }, + "header": { + "excess_mana": 1295981698, + "mana_used": 112723984, + "proving_cost_per_mana_numerator": 379373842, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -115090936, + "fee_asset_price_modifier": -707254472 + }, + "outputs": { + "fee_asset_price_at_execution": 10022735629, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30977678, + "proving_cost": 5442201303, + "congestion_cost": 19458972680, + "congestion_multiplier": 4555332787 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 310481076, + "proving_cost": 54545744899, + "congestion_cost": 195032138783, + "congestion_multiplier": 4555332787 + } + } + }, + { + "l1_block_number": 20974694, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9403513294 + }, + "parent_header": { + "excess_mana": 1295981698, + "mana_used": 112723984, + "proving_cost_per_mana_numerator": 379373842, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1308705682, + "mana_used": 106107340, + "proving_cost_per_mana_numerator": 487357271, + "fee_asset_price_numerator": 873296007 + }, + "oracle_input": { + "proving_cost_modifier": 107983429, + "fee_asset_price_modifier": 873296007 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31149137, + "proving_cost": 5435941425, + "congestion_cost": 19810853368, + "congestion_multiplier": 4623655607 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 311491370, + "proving_cost": 54359414250, + "congestion_cost": 198108533680, + "congestion_multiplier": 4623655607 + } + } + }, + { + "l1_block_number": 20974697, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10065091506 + }, + "parent_header": { + "excess_mana": 1308705682, + "mana_used": 106107340, + "proving_cost_per_mana_numerator": 487357271, + "fee_asset_price_numerator": 873296007 + }, + "header": { + "excess_mana": 1314813022, + "mana_used": 102389524, + "proving_cost_per_mana_numerator": 476280958, + "fee_asset_price_numerator": 16767761 + }, + "oracle_input": { + "proving_cost_modifier": -11076313, + "fee_asset_price_modifier": -856528246 + }, + "outputs": { + "fee_asset_price_at_execution": 10087712036, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33340615, + "proving_cost": 5441814512, + "congestion_cost": 20021616616, + "congestion_multiplier": 4656812666 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336330523, + "proving_cost": 54895457750, + "congestion_cost": 201972302917, + "congestion_multiplier": 4656812666 + } + } + }, + { + "l1_block_number": 20974700, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9772465608 + }, + "parent_header": { + "excess_mana": 1314813022, + "mana_used": 102389524, + "proving_cost_per_mana_numerator": 476280958, + "fee_asset_price_numerator": 16767761 + }, + "header": { + "excess_mana": 1317202546, + "mana_used": 106334484, + "proving_cost_per_mana_numerator": 284814652, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -191466306, + "fee_asset_price_modifier": -345823326 + }, + "outputs": { + "fee_asset_price_at_execution": 10001676916, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32371292, + "proving_cost": 5441211793, + "congestion_cost": 20087229617, + "congestion_multiplier": 4669850134 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 323767203, + "proving_cost": 54421242385, + "congestion_cost": 200905980766, + "congestion_multiplier": 4669850134 + } + } + }, + { + "l1_block_number": 20974703, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10113104790 + }, + "parent_header": { + "excess_mana": 1317202546, + "mana_used": 106334484, + "proving_cost_per_mana_numerator": 284814652, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1323537030, + "mana_used": 106033158, + "proving_cost_per_mana_numerator": 315246449, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": 30431797, + "fee_asset_price_modifier": -538742087 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33499659, + "proving_cost": 5430803673, + "congestion_cost": 20242995726, + "congestion_multiplier": 4704588581 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334996590, + "proving_cost": 54308036730, + "congestion_cost": 202429957260, + "congestion_multiplier": 4704588581 + } + } + }, + { + "l1_block_number": 20974706, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9897877678 + }, + "parent_header": { + "excess_mana": 1323537030, + "mana_used": 106033158, + "proving_cost_per_mana_numerator": 315246449, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1329570188, + "mana_used": 100781150, + "proving_cost_per_mana_numerator": 210183547, + "fee_asset_price_numerator": 0 + }, + "oracle_input": { + "proving_cost_modifier": -105062902, + "fee_asset_price_modifier": -356469643 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32786719, + "proving_cost": 5432456615, + "congestion_cost": 20428613889, + "congestion_multiplier": 4737914790 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 327867190, + "proving_cost": 54324566150, + "congestion_cost": 204286138890, + "congestion_multiplier": 4737914790 + } + } + }, + { + "l1_block_number": 20974709, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9638505207 + }, + "parent_header": { + "excess_mana": 1329570188, + "mana_used": 100781150, + "proving_cost_per_mana_numerator": 210183547, + "fee_asset_price_numerator": 0 + }, + "header": { + "excess_mana": 1330351338, + "mana_used": 90026211, + "proving_cost_per_mana_numerator": 216028422, + "fee_asset_price_numerator": 889353403 + }, + "oracle_input": { + "proving_cost_modifier": 5844875, + "fee_asset_price_modifier": 889353403 + }, + "outputs": { + "fee_asset_price_at_execution": 10000000000, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31927548, + "proving_cost": 5426752116, + "congestion_cost": 20427727405, + "congestion_multiplier": 4742246965 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 319275480, + "proving_cost": 54267521160, + "congestion_cost": 204277274050, + "congestion_multiplier": 4742246965 + } + } + }, + { + "l1_block_number": 20974712, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9788093852 + }, + "parent_header": { + "excess_mana": 1330351338, + "mana_used": 90026211, + "proving_cost_per_mana_numerator": 216028422, + "fee_asset_price_numerator": 889353403 + }, + "header": { + "excess_mana": 1320377549, + "mana_used": 96281835, + "proving_cost_per_mana_numerator": 90907125, + "fee_asset_price_numerator": 874788918 + }, + "oracle_input": { + "proving_cost_modifier": -125121297, + "fee_asset_price_modifier": -14564485 + }, + "outputs": { + "fee_asset_price_at_execution": 10089331990, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32423060, + "proving_cost": 5427069312, + "congestion_cost": 20130402622, + "congestion_multiplier": 4687229737 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 327127016, + "proving_cost": 54755504021, + "congestion_cost": 203102315145, + "congestion_multiplier": 4687229737 + } + } + }, + { + "l1_block_number": 20974715, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9591156391 + }, + "parent_header": { + "excess_mana": 1320377549, + "mana_used": 96281835, + "proving_cost_per_mana_numerator": 90907125, + "fee_asset_price_numerator": 874788918 + }, + "header": { + "excess_mana": 1316659384, + "mana_used": 98802156, + "proving_cost_per_mana_numerator": 226700020, + "fee_asset_price_numerator": 1227720857 + }, + "oracle_input": { + "proving_cost_modifier": 135792895, + "fee_asset_price_modifier": 352931939 + }, + "outputs": { + "fee_asset_price_at_execution": 10087862637, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31770705, + "proving_cost": 5420283139, + "congestion_cost": 19992045676, + "congestion_multiplier": 4666883389 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 320498507, + "proving_cost": 54679071759, + "congestion_cost": 201677010612, + "congestion_multiplier": 4666883389 + } + } + }, + { + "l1_block_number": 20974718, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10060943500 + }, + "parent_header": { + "excess_mana": 1316659384, + "mana_used": 98802156, + "proving_cost_per_mana_numerator": 226700020, + "fee_asset_price_numerator": 1227720857 + }, + "header": { + "excess_mana": 1315461540, + "mana_used": 103467904, + "proving_cost_per_mana_numerator": 177575230, + "fee_asset_price_numerator": 1609108682 + }, + "oracle_input": { + "proving_cost_modifier": -49124790, + "fee_asset_price_modifier": 381387825 + }, + "outputs": { + "fee_asset_price_at_execution": 10123528828, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33326875, + "proving_cost": 5427648498, + "congestion_cost": 19989067215, + "congestion_multiplier": 4660347438 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 337385579, + "proving_cost": 54946956037, + "congestion_cost": 202359898195, + "congestion_multiplier": 4660347438 + } + } + }, + { + "l1_block_number": 20974721, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9931038619 + }, + "parent_header": { + "excess_mana": 1315461540, + "mana_used": 103467904, + "proving_cost_per_mana_numerator": 177575230, + "fee_asset_price_numerator": 1609108682 + }, + "header": { + "excess_mana": 1318929444, + "mana_used": 93820858, + "proving_cost_per_mana_numerator": 132035391, + "fee_asset_price_numerator": 1963088223 + }, + "oracle_input": { + "proving_cost_modifier": -45539839, + "fee_asset_price_modifier": 353979541 + }, + "outputs": { + "fee_asset_price_at_execution": 10162212455, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32896565, + "proving_cost": 5424982832, + "congestion_cost": 20081148201, + "congestion_multiplier": 4679294968 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334301882, + "proving_cost": 55129828103, + "congestion_cost": 204068894358, + "congestion_multiplier": 4679294968 + } + } + }, + { + "l1_block_number": 20974724, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9547223674 + }, + "parent_header": { + "excess_mana": 1318929444, + "mana_used": 93820858, + "proving_cost_per_mana_numerator": 132035391, + "fee_asset_price_numerator": 1963088223 + }, + "header": { + "excess_mana": 1312750302, + "mana_used": 102433545, + "proving_cost_per_mana_numerator": 272099285, + "fee_asset_price_numerator": 2000138379 + }, + "oracle_input": { + "proving_cost_modifier": 140063894, + "fee_asset_price_modifier": 37050156 + }, + "outputs": { + "fee_asset_price_at_execution": 10198248350, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31625178, + "proving_cost": 5422512866, + "congestion_cost": 19883537732, + "congestion_multiplier": 4645587547 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 322521419, + "proving_cost": 55300132888, + "congestion_cost": 202777255867, + "congestion_multiplier": 4645587547 + } + } + }, + { + "l1_block_number": 20974727, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9057659802 + }, + "parent_header": { + "excess_mana": 1312750302, + "mana_used": 102433545, + "proving_cost_per_mana_numerator": 272099285, + "fee_asset_price_numerator": 2000138379 + }, + "header": { + "excess_mana": 1315183847, + "mana_used": 91742261, + "proving_cost_per_mana_numerator": 216089885, + "fee_asset_price_numerator": 2258197541 + }, + "oracle_input": { + "proving_cost_modifier": -56009400, + "fee_asset_price_modifier": 258059162 + }, + "outputs": { + "fee_asset_price_at_execution": 10202027517, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30003498, + "proving_cost": 5430113170, + "congestion_cost": 19977657964, + "congestion_multiplier": 4658833534 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 306096512, + "proving_cost": 55398163980, + "congestion_cost": 203812616273, + "congestion_multiplier": 4658833534 + } + } + }, + { + "l1_block_number": 20974730, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9445297033 + }, + "parent_header": { + "excess_mana": 1315183847, + "mana_used": 91742261, + "proving_cost_per_mana_numerator": 216089885, + "fee_asset_price_numerator": 2258197541 + }, + "header": { + "excess_mana": 1306926108, + "mana_used": 120537598, + "proving_cost_per_mana_numerator": 134913303, + "fee_asset_price_numerator": 1887680484 + }, + "oracle_input": { + "proving_cost_modifier": -81176582, + "fee_asset_price_modifier": -370517057 + }, + "outputs": { + "fee_asset_price_at_execution": 10228388783, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31287546, + "proving_cost": 5427072648, + "congestion_cost": 19726724985, + "congestion_multiplier": 4614038701 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 320021184, + "proving_cost": 55510208997, + "congestion_cost": 201772612561, + "congestion_multiplier": 4614038701 + } + } + }, + { + "l1_block_number": 20974733, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9930049927 + }, + "parent_header": { + "excess_mana": 1306926108, + "mana_used": 120537598, + "proving_cost_per_mana_numerator": 134913303, + "fee_asset_price_numerator": 1887680484 + }, + "header": { + "excess_mana": 1327463706, + "mana_used": 92120356, + "proving_cost_per_mana_numerator": 293230435, + "fee_asset_price_numerator": 1227976553 + }, + "oracle_input": { + "proving_cost_modifier": 158317132, + "fee_asset_price_modifier": -659703931 + }, + "outputs": { + "fee_asset_price_at_execution": 10190560981, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32893290, + "proving_cost": 5422668923, + "congestion_cost": 20328800583, + "congestion_multiplier": 4726252179 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 335201077, + "proving_cost": 55260038339, + "congestion_cost": 207161882011, + "congestion_multiplier": 4726252179 + } + } + }, + { + "l1_block_number": 20974736, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10365019463 + }, + "parent_header": { + "excess_mana": 1327463706, + "mana_used": 92120356, + "proving_cost_per_mana_numerator": 293230435, + "fee_asset_price_numerator": 1227976553 + }, + "header": { + "excess_mana": 1319584062, + "mana_used": 86406893, + "proving_cost_per_mana_numerator": 237640787, + "fee_asset_price_numerator": 1832755996 + }, + "oracle_input": { + "proving_cost_modifier": -55589648, + "fee_asset_price_modifier": 604779443 + }, + "outputs": { + "fee_asset_price_at_execution": 10123554714, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34334126, + "proving_cost": 5431260737, + "congestion_cost": 20129131249, + "congestion_multiplier": 4682880227 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 347583403, + "proving_cost": 54983665237, + "congestion_cost": 203778361544, + "congestion_multiplier": 4682880227 + } + } + }, + { + "l1_block_number": 20974739, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10874452459 + }, + "parent_header": { + "excess_mana": 1319584062, + "mana_used": 86406893, + "proving_cost_per_mana_numerator": 237640787, + "fee_asset_price_numerator": 1832755996 + }, + "header": { + "excess_mana": 1305990955, + "mana_used": 112381644, + "proving_cost_per_mana_numerator": 221200969, + "fee_asset_price_numerator": 1631151271 + }, + "oracle_input": { + "proving_cost_modifier": -16439818, + "fee_asset_price_modifier": -201604725 + }, + "outputs": { + "fee_asset_price_at_execution": 10184965404, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36021623, + "proving_cost": 5428242357, + "congestion_cost": 19720491044, + "congestion_multiplier": 4608993108 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 366878984, + "proving_cost": 55286460610, + "congestion_cost": 200852519033, + "congestion_multiplier": 4608993108 + } + } + }, + { + "l1_block_number": 20974742, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10537462271 + }, + "parent_header": { + "excess_mana": 1305990955, + "mana_used": 112381644, + "proving_cost_per_mana_numerator": 221200969, + "fee_asset_price_numerator": 1631151271 + }, + "header": { + "excess_mana": 1318372599, + "mana_used": 104606734, + "proving_cost_per_mana_numerator": 153703284, + "fee_asset_price_numerator": 1141096092 + }, + "oracle_input": { + "proving_cost_modifier": -67497685, + "fee_asset_price_modifier": -490055179 + }, + "outputs": { + "fee_asset_price_at_execution": 10164452717, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34905343, + "proving_cost": 5427350037, + "congestion_cost": 20080601914, + "congestion_multiplier": 4676247359 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 354793708, + "proving_cost": 55166042829, + "congestion_cost": 204108328683, + "congestion_multiplier": 4676247359 + } + } + }, + { + "l1_block_number": 20974745, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10500204149 + }, + "parent_header": { + "excess_mana": 1318372599, + "mana_used": 104606734, + "proving_cost_per_mana_numerator": 153703284, + "fee_asset_price_numerator": 1141096092 + }, + "header": { + "excess_mana": 1322979333, + "mana_used": 98393903, + "proving_cost_per_mana_numerator": 125449892, + "fee_asset_price_numerator": 692530653 + }, + "oracle_input": { + "proving_cost_modifier": -28253392, + "fee_asset_price_modifier": -448565439 + }, + "outputs": { + "fee_asset_price_at_execution": 10114763142, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34781926, + "proving_cost": 5423687938, + "congestion_cost": 20204634344, + "congestion_multiplier": 4701519812 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 351810943, + "proving_cost": 54859318848, + "congestion_cost": 204365090760, + "congestion_multiplier": 4701519812 + } + } + }, + { + "l1_block_number": 20974748, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10424404293 + }, + "parent_header": { + "excess_mana": 1322979333, + "mana_used": 98393903, + "proving_cost_per_mana_numerator": 125449892, + "fee_asset_price_numerator": 692530653 + }, + "header": { + "excess_mana": 1321373236, + "mana_used": 101125648, + "proving_cost_per_mana_numerator": 116545291, + "fee_asset_price_numerator": 1221606111 + }, + "oracle_input": { + "proving_cost_modifier": -8904601, + "fee_asset_price_modifier": 529075458 + }, + "outputs": { + "fee_asset_price_at_execution": 10069493419, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34530839, + "proving_cost": 5422155778, + "congestion_cost": 20149870247, + "congestion_multiplier": 4692693325 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 347708056, + "proving_cost": 54598361923, + "congestion_cost": 202898985845, + "congestion_multiplier": 4692693325 + } + } + }, + { + "l1_block_number": 20974751, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9876371928 + }, + "parent_header": { + "excess_mana": 1321373236, + "mana_used": 101125648, + "proving_cost_per_mana_numerator": 116545291, + "fee_asset_price_numerator": 1221606111 + }, + "header": { + "excess_mana": 1322498884, + "mana_used": 106231316, + "proving_cost_per_mana_numerator": 116068701, + "fee_asset_price_numerator": 783842434 + }, + "oracle_input": { + "proving_cost_modifier": -476590, + "fee_asset_price_modifier": -437763677 + }, + "outputs": { + "fee_asset_price_at_execution": 10122909819, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32715482, + "proving_cost": 5421672978, + "congestion_cost": 20175115907, + "congestion_multiplier": 4698877712 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 331175873, + "proving_cost": 54883106624, + "congestion_cost": 204230878914, + "congestion_multiplier": 4698877712 + } + } + }, + { + "l1_block_number": 20974754, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9360570144 + }, + "parent_header": { + "excess_mana": 1322498884, + "mana_used": 106231316, + "proving_cost_per_mana_numerator": 116068701, + "fee_asset_price_numerator": 783842434 + }, + "header": { + "excess_mana": 1328730200, + "mana_used": 94599253, + "proving_cost_per_mana_numerator": 195742672, + "fee_asset_price_numerator": 1332901608 + }, + "oracle_input": { + "proving_cost_modifier": 79673971, + "fee_asset_price_modifier": 549059174 + }, + "outputs": { + "fee_asset_price_at_execution": 10078692252, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31006888, + "proving_cost": 5421647139, + "congestion_cost": 20356179104, + "congestion_multiplier": 4733260721 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312508881, + "proving_cost": 54643113012, + "congestion_cost": 205163664615, + "congestion_multiplier": 4733260721 + } + } + }, + { + "l1_block_number": 20974757, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9824724225 + }, + "parent_header": { + "excess_mana": 1328730200, + "mana_used": 94599253, + "proving_cost_per_mana_numerator": 195742672, + "fee_asset_price_numerator": 1332901608 + }, + "header": { + "excess_mana": 1323329453, + "mana_used": 104810216, + "proving_cost_per_mana_numerator": 91244335, + "fee_asset_price_numerator": 1328557093 + }, + "oracle_input": { + "proving_cost_modifier": -104498337, + "fee_asset_price_modifier": -4344515 + }, + "outputs": { + "fee_asset_price_at_execution": 10134182434, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32544398, + "proving_cost": 5425968502, + "congestion_cost": 20215308524, + "congestion_multiplier": 4703446139 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 329810866, + "proving_cost": 54987754680, + "congestion_cost": 204865624541, + "congestion_multiplier": 4703446139 + } + } + }, + { + "l1_block_number": 20974760, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9304831062 + }, + "parent_header": { + "excess_mana": 1323329453, + "mana_used": 104810216, + "proving_cost_per_mana_numerator": 91244335, + "fee_asset_price_numerator": 1328557093 + }, + "header": { + "excess_mana": 1328139669, + "mana_used": 22463541, + "proving_cost_per_mana_numerator": 70172623, + "fee_asset_price_numerator": 846061293 + }, + "oracle_input": { + "proving_cost_modifier": -21071712, + "fee_asset_price_modifier": -482495800 + }, + "outputs": { + "fee_asset_price_at_execution": 10133742162, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30822252, + "proving_cost": 5420301417, + "congestion_cost": 20332645168, + "congestion_multiplier": 4729991540 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 312344754, + "proving_cost": 54927937000, + "congestion_cost": 206045783603, + "congestion_multiplier": 4729991540 + } + } + }, + { + "l1_block_number": 20974763, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9375115776 + }, + "parent_header": { + "excess_mana": 1328139669, + "mana_used": 22463541, + "proving_cost_per_mana_numerator": 70172623, + "fee_asset_price_numerator": 846061293 + }, + "header": { + "excess_mana": 1250603210, + "mana_used": 150785033, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1599723314 + }, + "oracle_input": { + "proving_cost_modifier": -176951960, + "fee_asset_price_modifier": 753662021 + }, + "outputs": { + "fee_asset_price_at_execution": 10084965050, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31055071, + "proving_cost": 5419159387, + "congestion_cost": 18093543131, + "congestion_multiplier": 4319785537 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313189305, + "proving_cost": 54652033018, + "congestion_cost": 182472750106, + "congestion_multiplier": 4319785537 + } + } + }, + { + "l1_block_number": 20974766, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9355897486 + }, + "parent_header": { + "excess_mana": 1250603210, + "mana_used": 150785033, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 1599723314 + }, + "header": { + "excess_mana": 1301388243, + "mana_used": 115685651, + "proving_cost_per_mana_numerator": 73707425, + "fee_asset_price_numerator": 2586358676 + }, + "oracle_input": { + "proving_cost_modifier": 73707425, + "fee_asset_price_modifier": 986635362 + }, + "outputs": { + "fee_asset_price_at_execution": 10161258739, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30991410, + "proving_cost": 5415357955, + "congestion_cost": 19521021036, + "congestion_multiplier": 4584239594 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 314911735, + "proving_cost": 55026853345, + "congestion_cost": 198358145596, + "congestion_multiplier": 4584239594 + } + } + }, + { + "l1_block_number": 20974769, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9794644343 + }, + "parent_header": { + "excess_mana": 1301388243, + "mana_used": 115685651, + "proving_cost_per_mana_numerator": 73707425, + "fee_asset_price_numerator": 2586358676 + }, + "header": { + "excess_mana": 1317073894, + "mana_used": 107028096, + "proving_cost_per_mana_numerator": 10009116, + "fee_asset_price_numerator": 3372692979 + }, + "oracle_input": { + "proving_cost_modifier": -63698309, + "fee_asset_price_modifier": 786334303 + }, + "outputs": { + "fee_asset_price_at_execution": 10262009515, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32444759, + "proving_cost": 5419350947, + "congestion_cost": 20003441320, + "congestion_multiplier": 4669147268 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332948425, + "proving_cost": 55613430983, + "congestion_cost": 205275505158, + "congestion_multiplier": 4669147268 + } + } + }, + { + "l1_block_number": 20974772, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10009442615 + }, + "parent_header": { + "excess_mana": 1317073894, + "mana_used": 107028096, + "proving_cost_per_mana_numerator": 10009116, + "fee_asset_price_numerator": 3372692979 + }, + "header": { + "excess_mana": 1324101990, + "mana_used": 104043606, + "proving_cost_per_mana_numerator": 166033820, + "fee_asset_price_numerator": 3617525919 + }, + "oracle_input": { + "proving_cost_modifier": 156024704, + "fee_asset_price_modifier": 244832940 + }, + "outputs": { + "fee_asset_price_at_execution": 10343021310, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33156278, + "proving_cost": 5415900011, + "congestion_cost": 20203462498, + "congestion_multiplier": 4707699357 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 342936089, + "proving_cost": 56016769226, + "congestion_cost": 208964843152, + "congestion_multiplier": 4707699357 + } + } + }, + { + "l1_block_number": 20974775, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9694844373 + }, + "parent_header": { + "excess_mana": 1324101990, + "mana_used": 104043606, + "proving_cost_per_mana_numerator": 166033820, + "fee_asset_price_numerator": 3617525919 + }, + "header": { + "excess_mana": 1328145596, + "mana_used": 99506947, + "proving_cost_per_mana_numerator": 47176936, + "fee_asset_price_numerator": 3843644767 + }, + "oracle_input": { + "proving_cost_modifier": -118856884, + "fee_asset_price_modifier": 226118848 + }, + "outputs": { + "fee_asset_price_at_execution": 10368375458, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32114171, + "proving_cost": 5424356749, + "congestion_cost": 20352769347, + "congestion_multiplier": 4730024341 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332971782, + "proving_cost": 56241767391, + "congestion_cost": 211025154199, + "congestion_multiplier": 4730024341 + } + } + }, + { + "l1_block_number": 20974778, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9325354066 + }, + "parent_header": { + "excess_mana": 1328145596, + "mana_used": 99506947, + "proving_cost_per_mana_numerator": 47176936, + "fee_asset_price_numerator": 3843644767 + }, + "header": { + "excess_mana": 1327652543, + "mana_used": 95115604, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4394437425 + }, + "oracle_input": { + "proving_cost_modifier": -70276183, + "fee_asset_price_modifier": 550792658 + }, + "outputs": { + "fee_asset_price_at_execution": 10391846836, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30890235, + "proving_cost": 5417913357, + "congestion_cost": 20309306606, + "congestion_multiplier": 4727296509 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 321006590, + "proving_cost": 56302125776, + "congestion_cost": 211051203594, + "congestion_multiplier": 4727296509 + } + } + }, + { + "l1_block_number": 20974781, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8890810110 + }, + "parent_header": { + "excess_mana": 1327652543, + "mana_used": 95115604, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 4394437425 + }, + "header": { + "excess_mana": 1322768147, + "mana_used": 105577993, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3884670042 + }, + "oracle_input": { + "proving_cost_modifier": -89581950, + "fee_asset_price_modifier": -509767383 + }, + "outputs": { + "fee_asset_price_at_execution": 10449242285, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29450808, + "proving_cost": 5415357955, + "congestion_cost": 20147743129, + "congestion_multiplier": 4700358269 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 307738628, + "proving_cost": 56586387331, + "congestion_cost": 210528649450, + "congestion_multiplier": 4700358269 + } + } + }, + { + "l1_block_number": 20974784, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9245683543 + }, + "parent_header": { + "excess_mana": 1322768147, + "mana_used": 105577993, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 3884670042 + }, + "header": { + "excess_mana": 1328346140, + "mana_used": 94255340, + "proving_cost_per_mana_numerator": 151704970, + "fee_asset_price_numerator": 4074038287 + }, + "oracle_input": { + "proving_cost_modifier": 151704970, + "fee_asset_price_modifier": 189368245 + }, + "outputs": { + "fee_asset_price_at_execution": 10396110994, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30626326, + "proving_cost": 5415357955, + "congestion_cost": 20319698786, + "congestion_multiplier": 4731134307 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318394684, + "proving_cost": 56298662372, + "congestion_cost": 211245843943, + "congestion_multiplier": 4731134307 + } + } + }, + { + "l1_block_number": 20974787, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9301265399 + }, + "parent_header": { + "excess_mana": 1328346140, + "mana_used": 94255340, + "proving_cost_per_mana_numerator": 151704970, + "fee_asset_price_numerator": 4074038287 + }, + "header": { + "excess_mana": 1322601480, + "mana_used": 92317269, + "proving_cost_per_mana_numerator": 150396703, + "fee_asset_price_numerator": 4412849079 + }, + "oracle_input": { + "proving_cost_modifier": -1308267, + "fee_asset_price_modifier": 338810792 + }, + "outputs": { + "fee_asset_price_at_execution": 10415816579, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30810441, + "proving_cost": 5423579556, + "congestion_cost": 20178198272, + "congestion_multiplier": 4699441786 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 320915902, + "proving_cost": 56491009856, + "congestion_cost": 210172412095, + "congestion_multiplier": 4699441786 + } + } + }, + { + "l1_block_number": 20974790, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10338672585 + }, + "parent_header": { + "excess_mana": 1322601480, + "mana_used": 92317269, + "proving_cost_per_mana_numerator": 150396703, + "fee_asset_price_numerator": 4412849079 + }, + "header": { + "excess_mana": 1314918749, + "mana_used": 101125366, + "proving_cost_per_mana_numerator": 195716802, + "fee_asset_price_numerator": 3855190737 + }, + "oracle_input": { + "proving_cost_modifier": 45320099, + "fee_asset_price_modifier": -557658342 + }, + "outputs": { + "fee_asset_price_at_execution": 10451166341, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34246852, + "proving_cost": 5423508602, + "congestion_cost": 19961133408, + "congestion_multiplier": 4657388752 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 357919546, + "proving_cost": 56681990551, + "congestion_cost": 208617125601, + "congestion_multiplier": 4657388752 + } + } + }, + { + "l1_block_number": 20974793, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10696471973 + }, + "parent_header": { + "excess_mana": 1314918749, + "mana_used": 101125366, + "proving_cost_per_mana_numerator": 195716802, + "fee_asset_price_numerator": 3855190737 + }, + "header": { + "excess_mana": 1316044115, + "mana_used": 78651739, + "proving_cost_per_mana_numerator": 281864500, + "fee_asset_price_numerator": 4486558706 + }, + "oracle_input": { + "proving_cost_modifier": 86147698, + "fee_asset_price_modifier": 631367969 + }, + "outputs": { + "fee_asset_price_at_execution": 10393046745, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35432063, + "proving_cost": 5425967098, + "congestion_cost": 20007972759, + "congestion_multiplier": 4663525073 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 368247087, + "proving_cost": 56392329686, + "congestion_cost": 207943796156, + "congestion_multiplier": 4663525073 + } + } + }, + { + "l1_block_number": 20974796, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10676042346 + }, + "parent_header": { + "excess_mana": 1316044115, + "mana_used": 78651739, + "proving_cost_per_mana_numerator": 281864500, + "fee_asset_price_numerator": 4486558706 + }, + "header": { + "excess_mana": 1294695854, + "mana_used": 104253914, + "proving_cost_per_mana_numerator": 205325868, + "fee_asset_price_numerator": 4626061500 + }, + "oracle_input": { + "proving_cost_modifier": -76538632, + "fee_asset_price_modifier": 139502794 + }, + "outputs": { + "fee_asset_price_at_execution": 10458872696, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35364390, + "proving_cost": 5430643458, + "congestion_cost": 19396045360, + "congestion_multiplier": 4548484726 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 369871652, + "proving_cost": 56798408584, + "congestion_cost": 202860769226, + "congestion_multiplier": 4548484726 + } + } + }, + { + "l1_block_number": 20974799, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11427276933 + }, + "parent_header": { + "excess_mana": 1294695854, + "mana_used": 104253914, + "proving_cost_per_mana_numerator": 205325868, + "fee_asset_price_numerator": 4626061500 + }, + "header": { + "excess_mana": 1298949768, + "mana_used": 121554216, + "proving_cost_per_mana_numerator": 194135492, + "fee_asset_price_numerator": 4492379499 + }, + "oracle_input": { + "proving_cost_modifier": -11190376, + "fee_asset_price_modifier": -133682001 + }, + "outputs": { + "fee_asset_price_at_execution": 10473473298, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37852854, + "proving_cost": 5426488508, + "congestion_cost": 19514142896, + "congestion_multiplier": 4571179325 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 396450855, + "proving_cost": 56834182490, + "congestion_cost": 204380854554, + "congestion_multiplier": 4571179325 + } + } + }, + { + "l1_block_number": 20974802, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11491823317 + }, + "parent_header": { + "excess_mana": 1298949768, + "mana_used": 121554216, + "proving_cost_per_mana_numerator": 194135492, + "fee_asset_price_numerator": 4492379499 + }, + "header": { + "excess_mana": 1320503984, + "mana_used": 69392636, + "proving_cost_per_mana_numerator": 202298936, + "fee_asset_price_numerator": 4437308775 + }, + "oracle_input": { + "proving_cost_modifier": 8163444, + "fee_asset_price_modifier": -55070724 + }, + "outputs": { + "fee_asset_price_at_execution": 10459481503, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38066664, + "proving_cost": 5425881298, + "congestion_cost": 20150620261, + "congestion_multiplier": 4687923165 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 398157567, + "proving_cost": 56751905073, + "congestion_cost": 210765039893, + "congestion_multiplier": 4687923165 + } + } + }, + { + "l1_block_number": 20974805, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10811344431 + }, + "parent_header": { + "excess_mana": 1320503984, + "mana_used": 69392636, + "proving_cost_per_mana_numerator": 202298936, + "fee_asset_price_numerator": 4437308775 + }, + "header": { + "excess_mana": 1289896620, + "mana_used": 123033670, + "proving_cost_per_mana_numerator": 292978465, + "fee_asset_price_numerator": 4662820355 + }, + "oracle_input": { + "proving_cost_modifier": 90679529, + "fee_asset_price_modifier": 225511580 + }, + "outputs": { + "fee_asset_price_at_execution": 10453722977, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35812578, + "proving_cost": 5426324255, + "congestion_cost": 19243195915, + "congestion_multiplier": 4523016084 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 374374769, + "proving_cost": 56725290545, + "congestion_cost": 201163039287, + "congestion_multiplier": 4523016084 + } + } + }, + { + "l1_block_number": 20974808, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11312462913 + }, + "parent_header": { + "excess_mana": 1289896620, + "mana_used": 123033670, + "proving_cost_per_mana_numerator": 292978465, + "fee_asset_price_numerator": 4662820355 + }, + "header": { + "excess_mana": 1312930290, + "mana_used": 104485851, + "proving_cost_per_mana_numerator": 338949112, + "fee_asset_price_numerator": 5084899225 + }, + "oracle_input": { + "proving_cost_modifier": 45970647, + "fee_asset_price_modifier": 422078870 + }, + "outputs": { + "fee_asset_price_at_execution": 10477323934, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37472533, + "proving_cost": 5431247052, + "congestion_cost": 19942046606, + "congestion_multiplier": 4646565946 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 392611866, + "proving_cost": 56904934729, + "congestion_cost": 208939282197, + "congestion_multiplier": 4646565946 + } + } + }, + { + "l1_block_number": 20974811, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10662810216 + }, + "parent_header": { + "excess_mana": 1312930290, + "mana_used": 104485851, + "proving_cost_per_mana_numerator": 338949112, + "fee_asset_price_numerator": 5084899225 + }, + "header": { + "excess_mana": 1317416141, + "mana_used": 95457884, + "proving_cost_per_mana_numerator": 410205539, + "fee_asset_price_numerator": 4421489069 + }, + "oracle_input": { + "proving_cost_modifier": 71256427, + "fee_asset_price_modifier": -663410156 + }, + "outputs": { + "fee_asset_price_at_execution": 10521639963, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35320558, + "proving_cost": 5433744405, + "congestion_cost": 20077032115, + "congestion_multiplier": 4671017304 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 371630194, + "proving_cost": 57171902280, + "congestion_cost": 211243303439, + "congestion_multiplier": 4671017304 + } + } + }, + { + "l1_block_number": 20974814, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10452820038 + }, + "parent_header": { + "excess_mana": 1317416141, + "mana_used": 95457884, + "proving_cost_per_mana_numerator": 410205539, + "fee_asset_price_numerator": 4421489069 + }, + "header": { + "excess_mana": 1312874025, + "mana_used": 101125688, + "proving_cost_per_mana_numerator": 392508919, + "fee_asset_price_numerator": 5338461220 + }, + "oracle_input": { + "proving_cost_modifier": -17696620, + "fee_asset_price_modifier": 916972151 + }, + "outputs": { + "fee_asset_price_at_execution": 10452069359, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34624966, + "proving_cost": 5437617677, + "congestion_cost": 19953219853, + "congestion_multiplier": 4646260072 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 361902546, + "proving_cost": 56834357107, + "congestion_cost": 208552437838, + "congestion_multiplier": 4646260072 + } + } + }, + { + "l1_block_number": 20974817, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10494444894 + }, + "parent_header": { + "excess_mana": 1312874025, + "mana_used": 101125688, + "proving_cost_per_mana_numerator": 392508919, + "fee_asset_price_numerator": 5338461220 + }, + "header": { + "excess_mana": 1313999713, + "mana_used": 113120937, + "proving_cost_per_mana_numerator": 440009576, + "fee_asset_price_numerator": 5678935638 + }, + "oracle_input": { + "proving_cost_modifier": 47500657, + "fee_asset_price_modifier": 340474418 + }, + "outputs": { + "fee_asset_price_at_execution": 10548352696, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34762848, + "proving_cost": 5436655487, + "congestion_cost": 19983717955, + "congestion_multiplier": 4652383483 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 366690781, + "proving_cost": 57347759563, + "congestion_cost": 210795305166, + "congestion_multiplier": 4652383483 + } + } + }, + { + "l1_block_number": 20974820, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11441672423 + }, + "parent_header": { + "excess_mana": 1313999713, + "mana_used": 113120937, + "proving_cost_per_mana_numerator": 440009576, + "fee_asset_price_numerator": 5678935638 + }, + "header": { + "excess_mana": 1327120650, + "mana_used": 93614567, + "proving_cost_per_mana_numerator": 652994890, + "fee_asset_price_numerator": 5682136233 + }, + "oracle_input": { + "proving_cost_modifier": 212985314, + "fee_asset_price_modifier": 3200595 + }, + "outputs": { + "fee_asset_price_at_execution": 10584328347, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37900539, + "proving_cost": 5439238548, + "congestion_cost": 20398813395, + "congestion_multiplier": 4724355557 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 401151749, + "proving_cost": 57570686749, + "congestion_cost": 215907738861, + "congestion_multiplier": 4724355557 + } + } + }, + { + "l1_block_number": 20974823, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10436948017 + }, + "parent_header": { + "excess_mana": 1327120650, + "mana_used": 93614567, + "proving_cost_per_mana_numerator": 652994890, + "fee_asset_price_numerator": 5682136233 + }, + "header": { + "excess_mana": 1320735217, + "mana_used": 92881828, + "proving_cost_per_mana_numerator": 643450673, + "fee_asset_price_numerator": 5750089006 + }, + "oracle_input": { + "proving_cost_modifier": -9544217, + "fee_asset_price_modifier": 67952773 + }, + "outputs": { + "fee_asset_price_at_execution": 10584667114, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34572390, + "proving_cost": 5450835673, + "congestion_cost": 20236721458, + "congestion_multiplier": 4689191620 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 365937239, + "proving_cost": 57695281091, + "congestion_cost": 214198960111, + "congestion_multiplier": 4689191620 + } + } + }, + { + "l1_block_number": 20974826, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12544299201 + }, + "parent_header": { + "excess_mana": 1320735217, + "mana_used": 92881828, + "proving_cost_per_mana_numerator": 643450673, + "fee_asset_price_numerator": 5750089006 + }, + "header": { + "excess_mana": 1313617045, + "mana_used": 89289918, + "proving_cost_per_mana_numerator": 462121778, + "fee_asset_price_numerator": 5871915980 + }, + "oracle_input": { + "proving_cost_modifier": -181328895, + "fee_asset_price_modifier": 121826974 + }, + "outputs": { + "fee_asset_price_at_execution": 10591862133, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41552991, + "proving_cost": 5450315458, + "congestion_cost": 20046972764, + "congestion_multiplier": 4650300977 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 440123551, + "proving_cost": 57728989912, + "congestion_cost": 212334771700, + "congestion_multiplier": 4650300977 + } + } + }, + { + "l1_block_number": 20974829, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12400332753 + }, + "parent_header": { + "excess_mana": 1313617045, + "mana_used": 89289918, + "proving_cost_per_mana_numerator": 462121778, + "fee_asset_price_numerator": 5871915980 + }, + "header": { + "excess_mana": 1302906963, + "mana_used": 111424450, + "proving_cost_per_mana_numerator": 557448177, + "fee_asset_price_numerator": 5446763525 + }, + "oracle_input": { + "proving_cost_modifier": 95326399, + "fee_asset_price_modifier": -425152455 + }, + "outputs": { + "fee_asset_price_at_execution": 10604773742, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41076102, + "proving_cost": 5440441416, + "congestion_cost": 19691762869, + "congestion_multiplier": 4592392582 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 435602767, + "proving_cost": 57694650273, + "congestion_cost": 208826689806, + "congestion_multiplier": 4592392582 + } + } + }, + { + "l1_block_number": 20974832, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12549492621 + }, + "parent_header": { + "excess_mana": 1302906963, + "mana_used": 111424450, + "proving_cost_per_mana_numerator": 557448177, + "fee_asset_price_numerator": 5446763525 + }, + "header": { + "excess_mana": 1314331413, + "mana_used": 90490628, + "proving_cost_per_mana_numerator": 449359153, + "fee_asset_price_numerator": 5218321344 + }, + "oracle_input": { + "proving_cost_modifier": -108089024, + "fee_asset_price_modifier": -228442181 + }, + "outputs": { + "fee_asset_price_at_execution": 10559782993, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41570194, + "proving_cost": 5445630066, + "congestion_cost": 20051268877, + "congestion_multiplier": 4654189373 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 438972227, + "proving_cost": 57504671757, + "congestion_cost": 211737048075, + "congestion_multiplier": 4654189373 + } + } + }, + { + "l1_block_number": 20974835, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12247487967 + }, + "parent_header": { + "excess_mana": 1314331413, + "mana_used": 90490628, + "proving_cost_per_mana_numerator": 449359153, + "fee_asset_price_numerator": 5218321344 + }, + "header": { + "excess_mana": 1304822041, + "mana_used": 113679240, + "proving_cost_per_mana_numerator": 514902665, + "fee_asset_price_numerator": 5674843125 + }, + "oracle_input": { + "proving_cost_modifier": 65543512, + "fee_asset_price_modifier": 456521781 + }, + "outputs": { + "fee_asset_price_at_execution": 10535687527, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 40569803, + "proving_cost": 5439747118, + "congestion_cost": 19743905009, + "congestion_multiplier": 4602694022 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 427430767, + "proving_cost": 57311475861, + "congestion_cost": 208015613737, + "congestion_multiplier": 4602694022 + } + } + }, + { + "l1_block_number": 20974838, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12279164524 + }, + "parent_header": { + "excess_mana": 1304822041, + "mana_used": 113679240, + "proving_cost_per_mana_numerator": 514902665, + "fee_asset_price_numerator": 5674843125 + }, + "header": { + "excess_mana": 1318501281, + "mana_used": 94816566, + "proving_cost_per_mana_numerator": 713358368, + "fee_asset_price_numerator": 6674843125 + }, + "oracle_input": { + "proving_cost_modifier": 198455703, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10583895191, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 40674732, + "proving_cost": 5443313688, + "congestion_cost": 20164359222, + "congestion_multiplier": 4676951459 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 430497100, + "proving_cost": 57611461565, + "congestion_cost": 213417464599, + "congestion_multiplier": 4676951459 + } + } + }, + { + "l1_block_number": 20974841, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10902675660 + }, + "parent_header": { + "excess_mana": 1318501281, + "mana_used": 94816566, + "proving_cost_per_mana_numerator": 713358368, + "fee_asset_price_numerator": 6674843125 + }, + "header": { + "excess_mana": 1313317847, + "mana_used": 107663248, + "proving_cost_per_mana_numerator": 748402866, + "fee_asset_price_numerator": 7610408635 + }, + "oracle_input": { + "proving_cost_modifier": 35044498, + "fee_asset_price_modifier": 935565510 + }, + "outputs": { + "fee_asset_price_at_execution": 10690265106, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36115113, + "proving_cost": 5454126980, + "congestion_cost": 20032100119, + "congestion_multiplier": 4648673370 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 386080132, + "proving_cost": 58306063337, + "congestion_cost": 214148460902, + "congestion_multiplier": 4648673370 + } + } + }, + { + "l1_block_number": 20974844, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11748014686 + }, + "parent_header": { + "excess_mana": 1313317847, + "mana_used": 107663248, + "proving_cost_per_mana_numerator": 748402866, + "fee_asset_price_numerator": 7610408635 + }, + "header": { + "excess_mana": 1320981095, + "mana_used": 113716102, + "proving_cost_per_mana_numerator": 644992713, + "fee_asset_price_numerator": 8106950703 + }, + "oracle_input": { + "proving_cost_modifier": -103410153, + "fee_asset_price_modifier": 496542068 + }, + "outputs": { + "fee_asset_price_at_execution": 10790748852, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38915298, + "proving_cost": 5456038687, + "congestion_cost": 20279351804, + "congestion_multiplier": 4690540787 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 419925207, + "proving_cost": 58874743198, + "congestion_cost": 218829392198, + "congestion_multiplier": 4690540787 + } + } + }, + { + "l1_block_number": 20974847, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11555866445 + }, + "parent_header": { + "excess_mana": 1320981095, + "mana_used": 113716102, + "proving_cost_per_mana_numerator": 644992713, + "fee_asset_price_numerator": 8106950703 + }, + "header": { + "excess_mana": 1334697197, + "mana_used": 77154125, + "proving_cost_per_mana_numerator": 630470577, + "fee_asset_price_numerator": 8256440326 + }, + "oracle_input": { + "proving_cost_modifier": -14522136, + "fee_asset_price_modifier": 149489623 + }, + "outputs": { + "fee_asset_price_at_execution": 10844462705, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38278807, + "proving_cost": 5450399505, + "congestion_cost": 20672673591, + "congestion_multiplier": 4766421061 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 415113094, + "proving_cost": 59106654159, + "congestion_cost": 224184037770, + "congestion_multiplier": 4766421061 + } + } + }, + { + "l1_block_number": 20974850, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11216225347 + }, + "parent_header": { + "excess_mana": 1334697197, + "mana_used": 77154125, + "proving_cost_per_mana_numerator": 630470577, + "fee_asset_price_numerator": 8256440326 + }, + "header": { + "excess_mana": 1311851322, + "mana_used": 120250559, + "proving_cost_per_mana_numerator": 559447502, + "fee_asset_price_numerator": 8337804903 + }, + "oracle_input": { + "proving_cost_modifier": -71023075, + "fee_asset_price_modifier": 81364577 + }, + "outputs": { + "fee_asset_price_at_execution": 10860686175, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37153746, + "proving_cost": 5449608048, + "congestion_cost": 19975674820, + "congestion_multiplier": 4640703856 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 403515175, + "proving_cost": 59186482786, + "congestion_cost": 216949535353, + "congestion_multiplier": 4640703856 + } + } + }, + { + "l1_block_number": 20974853, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11547959457 + }, + "parent_header": { + "excess_mana": 1311851322, + "mana_used": 120250559, + "proving_cost_per_mana_numerator": 559447502, + "fee_asset_price_numerator": 8337804903 + }, + "header": { + "excess_mana": 1332101881, + "mana_used": 95609882, + "proving_cost_per_mana_numerator": 658973526, + "fee_asset_price_numerator": 9010707806 + }, + "oracle_input": { + "proving_cost_modifier": 99526024, + "fee_asset_price_modifier": 672902903 + }, + "outputs": { + "fee_asset_price_at_execution": 10869526522, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38252615, + "proving_cost": 5445738943, + "congestion_cost": 20575770061, + "congestion_multiplier": 4751969682 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 415787813, + "proving_cost": 59192603872, + "congestion_cost": 223648878388, + "congestion_multiplier": 4751969682 + } + } + }, + { + "l1_block_number": 20974856, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11536198807 + }, + "parent_header": { + "excess_mana": 1332101881, + "mana_used": 95609882, + "proving_cost_per_mana_numerator": 658973526, + "fee_asset_price_numerator": 9010707806 + }, + "header": { + "excess_mana": 1327711763, + "mana_used": 82020204, + "proving_cost_per_mana_numerator": 837434640, + "fee_asset_price_numerator": 8643670869 + }, + "oracle_input": { + "proving_cost_modifier": 178461114, + "fee_asset_price_modifier": -367036937 + }, + "outputs": { + "fee_asset_price_at_execution": 10942914520, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38213658, + "proving_cost": 5451161568, + "congestion_cost": 20462327177, + "congestion_multiplier": 4727624062 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 418168792, + "proving_cost": 59651595073, + "congestion_cost": 223917497178, + "congestion_multiplier": 4727624062 + } + } + }, + { + "l1_block_number": 20974859, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12543844247 + }, + "parent_header": { + "excess_mana": 1327711763, + "mana_used": 82020204, + "proving_cost_per_mana_numerator": 837434640, + "fee_asset_price_numerator": 8643670869 + }, + "header": { + "excess_mana": 1309731967, + "mana_used": 122961211, + "proving_cost_per_mana_numerator": 914286965, + "fee_asset_price_numerator": 8589826773 + }, + "oracle_input": { + "proving_cost_modifier": 76852325, + "fee_asset_price_modifier": -53844096 + }, + "outputs": { + "fee_asset_price_at_execution": 10902823601, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41551484, + "proving_cost": 5460898458, + "congestion_cost": 19969550821, + "congestion_multiplier": 4629210812 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 453028500, + "proving_cost": 59539212590, + "congestion_cost": 217724489992, + "congestion_multiplier": 4629210812 + } + } + }, + { + "l1_block_number": 20974862, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11467196389 + }, + "parent_header": { + "excess_mana": 1309731967, + "mana_used": 122961211, + "proving_cost_per_mana_numerator": 914286965, + "fee_asset_price_numerator": 8589826773 + }, + "header": { + "excess_mana": 1332693178, + "mana_used": 88377634, + "proving_cost_per_mana_numerator": 888132222, + "fee_asset_price_numerator": 7731360299 + }, + "oracle_input": { + "proving_cost_modifier": -26154743, + "fee_asset_price_modifier": -858466474 + }, + "outputs": { + "fee_asset_price_at_execution": 10896954654, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37985088, + "proving_cost": 5465096898, + "congestion_cost": 20665494386, + "congestion_multiplier": 4755258315 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 413921781, + "proving_cost": 59552913077, + "congestion_cost": 225190955226, + "congestion_multiplier": 4755258315 + } + } + }, + { + "l1_block_number": 20974865, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11847593532 + }, + "parent_header": { + "excess_mana": 1332693178, + "mana_used": 88377634, + "proving_cost_per_mana_numerator": 888132222, + "fee_asset_price_numerator": 7731360299 + }, + "header": { + "excess_mana": 1321070812, + "mana_used": 105628168, + "proving_cost_per_mana_numerator": 1011353411, + "fee_asset_price_numerator": 8653928406 + }, + "oracle_input": { + "proving_cost_modifier": 123221189, + "fee_asset_price_modifier": 922568107 + }, + "outputs": { + "fee_asset_price_at_execution": 10803808339, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 39245153, + "proving_cost": 5463667703, + "congestion_cost": 20311433905, + "congestion_multiplier": 4691033174 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 423997111, + "proving_cost": 59028418691, + "congestion_cost": 219440838999, + "congestion_multiplier": 4691033174 + } + } + }, + { + "l1_block_number": 20974868, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11328194124 + }, + "parent_header": { + "excess_mana": 1321070812, + "mana_used": 105628168, + "proving_cost_per_mana_numerator": 1011353411, + "fee_asset_price_numerator": 8653928406 + }, + "header": { + "excess_mana": 1326698980, + "mana_used": 112426897, + "proving_cost_per_mana_numerator": 922374234, + "fee_asset_price_numerator": 8952196191 + }, + "oracle_input": { + "proving_cost_modifier": -88979177, + "fee_asset_price_modifier": 298267785 + }, + "outputs": { + "fee_asset_price_at_execution": 10903942019, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37524643, + "proving_cost": 5470404249, + "congestion_cost": 20500650978, + "congestion_multiplier": 4722025353 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 409166531, + "proving_cost": 59648970751, + "congestion_cost": 223537909615, + "congestion_multiplier": 4722025353 + } + } + }, + { + "l1_block_number": 20974871, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10326551989 + }, + "parent_header": { + "excess_mana": 1326698980, + "mana_used": 112426897, + "proving_cost_per_mana_numerator": 922374234, + "fee_asset_price_numerator": 8952196191 + }, + "header": { + "excess_mana": 1339125877, + "mana_used": 93159165, + "proving_cost_per_mana_numerator": 1096301212, + "fee_asset_price_numerator": 8922067968 + }, + "oracle_input": { + "proving_cost_modifier": 173926978, + "fee_asset_price_modifier": -30128223 + }, + "outputs": { + "fee_asset_price_at_execution": 10936513517, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34206703, + "proving_cost": 5465538893, + "congestion_cost": 20850539989, + "congestion_multiplier": 4791182633 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 374102069, + "proving_cost": 59773939980, + "congestion_cost": 228032212426, + "congestion_multiplier": 4791182633 + } + } + }, + { + "l1_block_number": 20974874, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10644013577 + }, + "parent_header": { + "excess_mana": 1339125877, + "mana_used": 93159165, + "proving_cost_per_mana_numerator": 1096301212, + "fee_asset_price_numerator": 8922067968 + }, + "header": { + "excess_mana": 1332285042, + "mana_used": 95153977, + "proving_cost_per_mana_numerator": 1124499162, + "fee_asset_price_numerator": 9123995500 + }, + "oracle_input": { + "proving_cost_modifier": 28197950, + "fee_asset_price_modifier": 201927532 + }, + "outputs": { + "fee_asset_price_at_execution": 10933219036, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35258294, + "proving_cost": 5475053211, + "congestion_cost": 20680133670, + "congestion_multiplier": 4752988130 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 385486651, + "proving_cost": 59859955989, + "congestion_cost": 226100431107, + "congestion_multiplier": 4752988130 + } + } + }, + { + "l1_block_number": 20974877, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10075447620 + }, + "parent_header": { + "excess_mana": 1332285042, + "mana_used": 95153977, + "proving_cost_per_mana_numerator": 1124499162, + "fee_asset_price_numerator": 9123995500 + }, + "header": { + "excess_mana": 1327439019, + "mana_used": 100954563, + "proving_cost_per_mana_numerator": 1154447316, + "fee_asset_price_numerator": 9066858318 + }, + "oracle_input": { + "proving_cost_modifier": 29948154, + "fee_asset_price_modifier": -57137182 + }, + "outputs": { + "fee_asset_price_at_execution": 10955318520, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33374920, + "proving_cost": 5476597282, + "congestion_cost": 20530793757, + "congestion_multiplier": 4726115669 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 365632879, + "proving_cost": 59997867630, + "congestion_cost": 224921385076, + "congestion_multiplier": 4726115669 + } + } + }, + { + "l1_block_number": 20974880, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9763461789 + }, + "parent_header": { + "excess_mana": 1327439019, + "mana_used": 100954563, + "proving_cost_per_mana_numerator": 1154447316, + "fee_asset_price_numerator": 9066858318 + }, + "header": { + "excess_mana": 1328393582, + "mana_used": 86609776, + "proving_cost_per_mana_numerator": 1082851492, + "fee_asset_price_numerator": 8765287529 + }, + "oracle_input": { + "proving_cost_modifier": -71595824, + "fee_asset_price_modifier": -301570789 + }, + "outputs": { + "fee_asset_price_at_execution": 10949060748, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32341467, + "proving_cost": 5478237667, + "congestion_cost": 20562158041, + "congestion_multiplier": 4731396926 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 354108686, + "proving_cost": 59981557007, + "congestion_cost": 225136317500, + "congestion_multiplier": 4731396926 + } + } + }, + { + "l1_block_number": 20974883, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10100174423 + }, + "parent_header": { + "excess_mana": 1328393582, + "mana_used": 86609776, + "proving_cost_per_mana_numerator": 1082851492, + "fee_asset_price_numerator": 8765287529 + }, + "header": { + "excess_mana": 1315003358, + "mana_used": 101994370, + "proving_cost_per_mana_numerator": 1293341291, + "fee_asset_price_numerator": 8005697334 + }, + "oracle_input": { + "proving_cost_modifier": 210489799, + "fee_asset_price_modifier": -759590195 + }, + "outputs": { + "fee_asset_price_at_execution": 10916091317, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33456827, + "proving_cost": 5474316882, + "congestion_cost": 20146609081, + "congestion_multiplier": 4657849822 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 365217778, + "proving_cost": 59758142982, + "congestion_cost": 219922224456, + "congestion_multiplier": 4657849822 + } + } + }, + { + "l1_block_number": 20974886, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9861299092 + }, + "parent_header": { + "excess_mana": 1315003358, + "mana_used": 101994370, + "proving_cost_per_mana_numerator": 1293341291, + "fee_asset_price_numerator": 8005697334 + }, + "header": { + "excess_mana": 1316997728, + "mana_used": 100770495, + "proving_cost_per_mana_numerator": 1274750290, + "fee_asset_price_numerator": 7879332404 + }, + "oracle_input": { + "proving_cost_modifier": -18591001, + "fee_asset_price_modifier": -126364930 + }, + "outputs": { + "fee_asset_price_at_execution": 10833487879, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32665553, + "proving_cost": 5485851896, + "congestion_cost": 20245957137, + "congestion_multiplier": 4668731199 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 353881872, + "proving_cost": 59430910021, + "congestion_cost": 219334331242, + "congestion_multiplier": 4668731199 + } + } + }, + { + "l1_block_number": 20974889, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9769056260 + }, + "parent_header": { + "excess_mana": 1316997728, + "mana_used": 100770495, + "proving_cost_per_mana_numerator": 1274750290, + "fee_asset_price_numerator": 7879332404 + }, + "header": { + "excess_mana": 1317768223, + "mana_used": 93740114, + "proving_cost_per_mana_numerator": 1134591213, + "fee_asset_price_numerator": 8058266347 + }, + "oracle_input": { + "proving_cost_modifier": -140159077, + "fee_asset_price_modifier": 178933943 + }, + "outputs": { + "fee_asset_price_at_execution": 10819806795, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32359998, + "proving_cost": 5484832116, + "congestion_cost": 20264325870, + "congestion_multiplier": 4672941861 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 350128926, + "proving_cost": 59344823798, + "congestion_cost": 219256090744, + "congestion_multiplier": 4672941861 + } + } + }, + { + "l1_block_number": 20974892, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9623430979 + }, + "parent_header": { + "excess_mana": 1317768223, + "mana_used": 93740114, + "proving_cost_per_mana_numerator": 1134591213, + "fee_asset_price_numerator": 8058266347 + }, + "header": { + "excess_mana": 1311508337, + "mana_used": 108023757, + "proving_cost_per_mana_numerator": 1392064986, + "fee_asset_price_numerator": 7449911189 + }, + "oracle_input": { + "proving_cost_modifier": 257473773, + "fee_asset_price_modifier": -608355158 + }, + "outputs": { + "fee_asset_price_at_execution": 10839184433, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31877615, + "proving_cost": 5477150011, + "congestion_cost": 20046480829, + "congestion_multiplier": 4638841950 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 345527348, + "proving_cost": 59367839136, + "congestion_cost": 217287502938, + "congestion_multiplier": 4638841950 + } + } + }, + { + "l1_block_number": 20974895, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9512609521 + }, + "parent_header": { + "excess_mana": 1311508337, + "mana_used": 108023757, + "proving_cost_per_mana_numerator": 1392064986, + "fee_asset_price_numerator": 7449911189 + }, + "header": { + "excess_mana": 1319532094, + "mana_used": 94907192, + "proving_cost_per_mana_numerator": 1301384261, + "fee_asset_price_numerator": 7256716944 + }, + "oracle_input": { + "proving_cost_modifier": -90680725, + "fee_asset_price_modifier": -193194245 + }, + "outputs": { + "fee_asset_price_at_execution": 10773443867, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31510519, + "proving_cost": 5491270406, + "congestion_cost": 20338168203, + "congestion_multiplier": 4682595504 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 339476807, + "proving_cost": 59159893477, + "congestion_cost": 219112113492, + "congestion_multiplier": 4682595504 + } + } + }, + { + "l1_block_number": 20974898, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10044576348 + }, + "parent_header": { + "excess_mana": 1319532094, + "mana_used": 94907192, + "proving_cost_per_mana_numerator": 1301384261, + "fee_asset_price_numerator": 7256716944 + }, + "header": { + "excess_mana": 1314439286, + "mana_used": 107252047, + "proving_cost_per_mana_numerator": 1319569211, + "fee_asset_price_numerator": 6585416524 + }, + "oracle_input": { + "proving_cost_modifier": 18184950, + "fee_asset_price_modifier": -671300420 + }, + "outputs": { + "fee_asset_price_at_execution": 10752650286, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33272659, + "proving_cost": 5486293139, + "congestion_cost": 20172781146, + "congestion_multiplier": 4654776822 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 357769266, + "proving_cost": 58992191490, + "congestion_cost": 216910860958, + "congestion_multiplier": 4654776822 + } + } + }, + { + "l1_block_number": 20974901, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10070103513 + }, + "parent_header": { + "excess_mana": 1314439286, + "mana_used": 107252047, + "proving_cost_per_mana_numerator": 1319569211, + "fee_asset_price_numerator": 6585416524 + }, + "header": { + "excess_mana": 1321691333, + "mana_used": 121405371, + "proving_cost_per_mana_numerator": 1304115838, + "fee_asset_price_numerator": 6808203349 + }, + "oracle_input": { + "proving_cost_modifier": -15453373, + "fee_asset_price_modifier": 222786825 + }, + "outputs": { + "fee_asset_price_at_execution": 10680709439, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33357217, + "proving_cost": 5487290910, + "congestion_cost": 20395704072, + "congestion_multiplier": 4694440146 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 356278742, + "proving_cost": 58608159816, + "congestion_cost": 217840588996, + "congestion_multiplier": 4694440146 + } + } + }, + { + "l1_block_number": 20974904, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10137549634 + }, + "parent_header": { + "excess_mana": 1321691333, + "mana_used": 121405371, + "proving_cost_per_mana_numerator": 1304115838, + "fee_asset_price_numerator": 6808203349 + }, + "header": { + "excess_mana": 1343096704, + "mana_used": 90671800, + "proving_cost_per_mana_numerator": 1172290607, + "fee_asset_price_numerator": 6521145587 + }, + "oracle_input": { + "proving_cost_modifier": -131825231, + "fee_asset_price_modifier": -287057762 + }, + "outputs": { + "fee_asset_price_at_execution": 10704531178, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33580633, + "proving_cost": 5486443004, + "congestion_cost": 21050574921, + "congestion_multiplier": 4813493620 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 359464932, + "proving_cost": 58729800192, + "congestion_cost": 225336535556, + "congestion_multiplier": 4813493620 + } + } + }, + { + "l1_block_number": 20974907, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9517302233 + }, + "parent_header": { + "excess_mana": 1343096704, + "mana_used": 90671800, + "proving_cost_per_mana_numerator": 1172290607, + "fee_asset_price_numerator": 6521145587 + }, + "header": { + "excess_mana": 1333768504, + "mana_used": 111628561, + "proving_cost_per_mana_numerator": 1241261106, + "fee_asset_price_numerator": 7094785441 + }, + "oracle_input": { + "proving_cost_modifier": 68970499, + "fee_asset_price_modifier": 573639854 + }, + "outputs": { + "fee_asset_price_at_execution": 10673847052, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31526063, + "proving_cost": 5479215252, + "congestion_cost": 20727247225, + "congestion_multiplier": 4761244820 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336504374, + "proving_cost": 58484305564, + "congestion_cost": 221239466688, + "congestion_multiplier": 4761244820 + } + } + }, + { + "l1_block_number": 20974910, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9424484397 + }, + "parent_header": { + "excess_mana": 1333768504, + "mana_used": 111628561, + "proving_cost_per_mana_numerator": 1241261106, + "fee_asset_price_numerator": 7094785441 + }, + "header": { + "excess_mana": 1345397065, + "mana_used": 76010152, + "proving_cost_per_mana_numerator": 1123733641, + "fee_asset_price_numerator": 7441702780 + }, + "oracle_input": { + "proving_cost_modifier": -117527465, + "fee_asset_price_modifier": 346917339 + }, + "outputs": { + "fee_asset_price_at_execution": 10735252448, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31218604, + "proving_cost": 5482995598, + "congestion_cost": 21099954340, + "congestion_multiplier": 4826466214 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 335139595, + "proving_cost": 58861341915, + "congestion_cost": 226513336481, + "congestion_multiplier": 4826466214 + } + } + }, + { + "l1_block_number": 20974913, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9284979161 + }, + "parent_header": { + "excess_mana": 1345397065, + "mana_used": 76010152, + "proving_cost_per_mana_numerator": 1123733641, + "fee_asset_price_numerator": 7441702780 + }, + "header": { + "excess_mana": 1321407217, + "mana_used": 102379463, + "proving_cost_per_mana_numerator": 1087220094, + "fee_asset_price_numerator": 7782300821 + }, + "oracle_input": { + "proving_cost_modifier": -36513547, + "fee_asset_price_modifier": 340598041 + }, + "outputs": { + "fee_asset_price_at_execution": 10772559575, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30756493, + "proving_cost": 5476555358, + "congestion_cost": 20337841232, + "congestion_multiplier": 4692879899 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 331326153, + "proving_cost": 58996518859, + "congestion_cost": 219090606298, + "congestion_multiplier": 4692879899 + } + } + }, + { + "l1_block_number": 20974916, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9349531035 + }, + "parent_header": { + "excess_mana": 1321407217, + "mana_used": 102379463, + "proving_cost_per_mana_numerator": 1087220094, + "fee_asset_price_numerator": 7782300821 + }, + "header": { + "excess_mana": 1323786680, + "mana_used": 97560775, + "proving_cost_per_mana_numerator": 975214132, + "fee_asset_price_numerator": 7994655497 + }, + "oracle_input": { + "proving_cost_modifier": -112005962, + "fee_asset_price_modifier": 212354676 + }, + "outputs": { + "fee_asset_price_at_execution": 10809313257, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30970321, + "proving_cost": 5474556038, + "congestion_cost": 20403276690, + "congestion_multiplier": 4705962947 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334767901, + "proving_cost": 59176191157, + "congestion_cost": 220545409211, + "congestion_multiplier": 4705962947 + } + } + }, + { + "l1_block_number": 20974919, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9390478247 + }, + "parent_header": { + "excess_mana": 1323786680, + "mana_used": 97560775, + "proving_cost_per_mana_numerator": 975214132, + "fee_asset_price_numerator": 7994655497 + }, + "header": { + "excess_mana": 1321347455, + "mana_used": 99274649, + "proving_cost_per_mana_numerator": 937389994, + "fee_asset_price_numerator": 7861276742 + }, + "oracle_input": { + "proving_cost_modifier": -37824138, + "fee_asset_price_modifier": -133378755 + }, + "outputs": { + "fee_asset_price_at_execution": 10832291729, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31105959, + "proving_cost": 5468427642, + "congestion_cost": 20307312571, + "congestion_multiplier": 4692551777 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 336948822, + "proving_cost": 59235603517, + "congestion_cost": 219974734001, + "congestion_multiplier": 4692551777 + } + } + }, + { + "l1_block_number": 20974922, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9142314696 + }, + "parent_header": { + "excess_mana": 1321347455, + "mana_used": 99274649, + "proving_cost_per_mana_numerator": 937389994, + "fee_asset_price_numerator": 7861276742 + }, + "header": { + "excess_mana": 1320622104, + "mana_used": 100673187, + "proving_cost_per_mana_numerator": 971394804, + "fee_asset_price_numerator": 8578845048 + }, + "oracle_input": { + "proving_cost_modifier": 34004810, + "fee_asset_price_modifier": 717568306 + }, + "outputs": { + "fee_asset_price_at_execution": 10817853384, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30283917, + "proving_cost": 5466359647, + "congestion_cost": 20274760503, + "congestion_multiplier": 4688571083 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 327606973, + "proving_cost": 59134277205, + "congestion_cost": 219329386517, + "congestion_multiplier": 4688571083 + } + } + }, + { + "l1_block_number": 20974925, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9969641609 + }, + "parent_header": { + "excess_mana": 1320622104, + "mana_used": 100673187, + "proving_cost_per_mana_numerator": 971394804, + "fee_asset_price_numerator": 8578845048 + }, + "header": { + "excess_mana": 1321295291, + "mana_used": 102820127, + "proving_cost_per_mana_numerator": 1013995161, + "fee_asset_price_numerator": 9578845048 + }, + "oracle_input": { + "proving_cost_modifier": 42600357, + "fee_asset_price_modifier": 1000000000 + }, + "outputs": { + "fee_asset_price_at_execution": 10895758046, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33024437, + "proving_cost": 5468218788, + "congestion_cost": 20312049967, + "congestion_multiplier": 4692265391 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 359826275, + "proving_cost": 59580388856, + "congestion_cost": 221315181858, + "congestion_multiplier": 4692265391 + } + } + }, + { + "l1_block_number": 20974928, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9852702429 + }, + "parent_header": { + "excess_mana": 1321295291, + "mana_used": 102820127, + "proving_cost_per_mana_numerator": 1013995161, + "fee_asset_price_numerator": 9578845048 + }, + "header": { + "excess_mana": 1324115418, + "mana_used": 98269123, + "proving_cost_per_mana_numerator": 919091259, + "fee_asset_price_numerator": 9292279788 + }, + "oracle_input": { + "proving_cost_modifier": -94903902, + "fee_asset_price_modifier": -286565260 + }, + "outputs": { + "fee_asset_price_at_execution": 11005262235, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32637076, + "proving_cost": 5470548765, + "congestion_cost": 20404565630, + "congestion_multiplier": 4707773319 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 359179579, + "proving_cost": 60204823728, + "congestion_cost": 224557595549, + "congestion_multiplier": 4707773319 + } + } + }, + { + "l1_block_number": 20974931, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9051667803 + }, + "parent_header": { + "excess_mana": 1324115418, + "mana_used": 98269123, + "proving_cost_per_mana_numerator": 919091259, + "fee_asset_price_numerator": 9292279788 + }, + "header": { + "excess_mana": 1322384541, + "mana_used": 97911435, + "proving_cost_per_mana_numerator": 728383216, + "fee_asset_price_numerator": 9763078118 + }, + "oracle_input": { + "proving_cost_modifier": -190708043, + "fee_asset_price_modifier": 470798330 + }, + "outputs": { + "fee_asset_price_at_execution": 10973770121, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29983649, + "proving_cost": 5465359464, + "congestion_cost": 20323147897, + "congestion_multiplier": 4698249132 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 329033671, + "proving_cost": 59975598386, + "congestion_cost": 223021553156, + "congestion_multiplier": 4698249132 + } + } + }, + { + "l1_block_number": 20974934, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9177771259 + }, + "parent_header": { + "excess_mana": 1322384541, + "mana_used": 97911435, + "proving_cost_per_mana_numerator": 728383216, + "fee_asset_price_numerator": 9763078118 + }, + "header": { + "excess_mana": 1320295976, + "mana_used": 99481176, + "proving_cost_per_mana_numerator": 580576659, + "fee_asset_price_numerator": 9915158567 + }, + "oracle_input": { + "proving_cost_modifier": -147806557, + "fee_asset_price_modifier": 152080449 + }, + "outputs": { + "fee_asset_price_at_execution": 11025556256, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30401367, + "proving_cost": 5454946516, + "congestion_cost": 20223284071, + "congestion_multiplier": 4686782407 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 335191982, + "proving_cost": 60143819685, + "congestion_cost": 222972956205, + "congestion_multiplier": 4686782407 + } + } + }, + { + "l1_block_number": 20974937, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9151655035 + }, + "parent_header": { + "excess_mana": 1320295976, + "mana_used": 99481176, + "proving_cost_per_mana_numerator": 580576659, + "fee_asset_price_numerator": 9915158567 + }, + "header": { + "excess_mana": 1319777152, + "mana_used": 102737449, + "proving_cost_per_mana_numerator": 599954471, + "fee_asset_price_numerator": 9619014183 + }, + "oracle_input": { + "proving_cost_modifier": 19377812, + "fee_asset_price_modifier": -296144384 + }, + "outputs": { + "fee_asset_price_at_execution": 11042336728, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30314857, + "proving_cost": 5446889703, + "congestion_cost": 20177683551, + "congestion_multiplier": 4683938281 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 334746858, + "proving_cost": 60146390220, + "congestion_cost": 222808776161, + "congestion_multiplier": 4683938281 + } + } + }, + { + "l1_block_number": 20974940, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10111441008 + }, + "parent_header": { + "excess_mana": 1319777152, + "mana_used": 102737449, + "proving_cost_per_mana_numerator": 599954471, + "fee_asset_price_numerator": 9619014183 + }, + "header": { + "excess_mana": 1322514601, + "mana_used": 116287303, + "proving_cost_per_mana_numerator": 559406423, + "fee_asset_price_numerator": 9289033428 + }, + "oracle_input": { + "proving_cost_modifier": -40548048, + "fee_asset_price_modifier": -329980755 + }, + "outputs": { + "fee_asset_price_at_execution": 11009683842, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33494148, + "proving_cost": 5447945294, + "congestion_cost": 20275647821, + "congestion_multiplier": 4698964120 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 368759980, + "proving_cost": 59980155275, + "congestion_cost": 223228472200, + "congestion_multiplier": 4698964120 + } + } + }, + { + "l1_block_number": 20974943, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9743090500 + }, + "parent_header": { + "excess_mana": 1322514601, + "mana_used": 116287303, + "proving_cost_per_mana_numerator": 559406423, + "fee_asset_price_numerator": 9289033428 + }, + "header": { + "excess_mana": 1338801904, + "mana_used": 92831721, + "proving_cost_per_mana_numerator": 522669976, + "fee_asset_price_numerator": 9057063136 + }, + "oracle_input": { + "proving_cost_modifier": -36736447, + "fee_asset_price_modifier": -231970292 + }, + "outputs": { + "fee_asset_price_at_execution": 10973413879, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32273987, + "proving_cost": 5445736706, + "congestion_cost": 20758192326, + "congestion_multiplier": 4789366887 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 354155816, + "proving_cost": 59758322751, + "congestion_cost": 227788235773, + "congestion_multiplier": 4789366887 + } + } + }, + { + "l1_block_number": 20974946, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9439894878 + }, + "parent_header": { + "excess_mana": 1338801904, + "mana_used": 92831721, + "proving_cost_per_mana_numerator": 522669976, + "fee_asset_price_numerator": 9057063136 + }, + "header": { + "excess_mana": 1331633625, + "mana_used": 77640995, + "proving_cost_per_mana_numerator": 580693964, + "fee_asset_price_numerator": 9091408259 + }, + "oracle_input": { + "proving_cost_modifier": 58023988, + "fee_asset_price_modifier": 34345123 + }, + "outputs": { + "fee_asset_price_at_execution": 10947988320, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31269651, + "proving_cost": 5443736503, + "congestion_cost": 20527807305, + "congestion_multiplier": 4749366983 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 342339773, + "proving_cost": 59597963652, + "congestion_cost": 224738194610, + "congestion_multiplier": 4749366983 + } + } + }, + { + "l1_block_number": 20974949, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9405583805 + }, + "parent_header": { + "excess_mana": 1331633625, + "mana_used": 77640995, + "proving_cost_per_mana_numerator": 580693964, + "fee_asset_price_numerator": 9091408259 + }, + "header": { + "excess_mana": 1309274620, + "mana_used": 119848095, + "proving_cost_per_mana_numerator": 400210010, + "fee_asset_price_numerator": 8805169513 + }, + "oracle_input": { + "proving_cost_modifier": -180483954, + "fee_asset_price_modifier": -286238746 + }, + "outputs": { + "fee_asset_price_at_execution": 10951749066, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31155996, + "proving_cost": 5446896093, + "congestion_cost": 19867439967, + "congestion_multiplier": 4626734402 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 341212650, + "proving_cost": 59653039199, + "congestion_cost": 217583217102, + "congestion_multiplier": 4626734402 + } + } + }, + { + "l1_block_number": 20974952, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9725564097 + }, + "parent_header": { + "excess_mana": 1309274620, + "mana_used": 119848095, + "proving_cost_per_mana_numerator": 400210010, + "fee_asset_price_numerator": 8805169513 + }, + "header": { + "excess_mana": 1329122715, + "mana_used": 104571961, + "proving_cost_per_mana_numerator": 389834369, + "fee_asset_price_numerator": 8101281380 + }, + "oracle_input": { + "proving_cost_modifier": -10375641, + "fee_asset_price_modifier": -703888133 + }, + "outputs": { + "fee_asset_price_at_execution": 10920445739, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32215931, + "proving_cost": 5437074185, + "congestion_cost": 20430177368, + "congestion_multiplier": 4735434935 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 351812326, + "proving_cost": 59375273616, + "congestion_cost": 223106643385, + "congestion_multiplier": 4735434935 + } + } + }, + { + "l1_block_number": 20974955, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9211947631 + }, + "parent_header": { + "excess_mana": 1329122715, + "mana_used": 104571961, + "proving_cost_per_mana_numerator": 389834369, + "fee_asset_price_numerator": 8101281380 + }, + "header": { + "excess_mana": 1333694676, + "mana_used": 101810527, + "proving_cost_per_mana_numerator": 427108560, + "fee_asset_price_numerator": 8211979675 + }, + "oracle_input": { + "proving_cost_modifier": 37274191, + "fee_asset_price_modifier": 110698295 + }, + "outputs": { + "fee_asset_price_at_execution": 10843847915, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30514576, + "proving_cost": 5436510083, + "congestion_cost": 20560569849, + "congestion_multiplier": 4760833567 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 330895421, + "proving_cost": 58952688528, + "congestion_cost": 222955692488, + "congestion_multiplier": 4760833567 + } + } + }, + { + "l1_block_number": 20974958, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9168730681 + }, + "parent_header": { + "excess_mana": 1333694676, + "mana_used": 101810527, + "proving_cost_per_mana_numerator": 427108560, + "fee_asset_price_numerator": 8211979675 + }, + "header": { + "excess_mana": 1335505203, + "mana_used": 95686443, + "proving_cost_per_mana_numerator": 441651375, + "fee_asset_price_numerator": 7634681671 + }, + "oracle_input": { + "proving_cost_modifier": 14542815, + "fee_asset_price_modifier": -577298004 + }, + "outputs": { + "fee_asset_price_at_execution": 10855858516, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30371420, + "proving_cost": 5438536876, + "congestion_cost": 20622866034, + "congestion_multiplier": 4770929209 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 329707838, + "proving_cost": 59039986859, + "congestion_cost": 223878915859, + "congestion_multiplier": 4770929209 + } + } + }, + { + "l1_block_number": 20974961, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9071304225 + }, + "parent_header": { + "excess_mana": 1335505203, + "mana_used": 95686443, + "proving_cost_per_mana_numerator": 441651375, + "fee_asset_price_numerator": 7634681671 + }, + "header": { + "excess_mana": 1331191646, + "mana_used": 87209194, + "proving_cost_per_mana_numerator": 252255241, + "fee_asset_price_numerator": 7846156025 + }, + "oracle_input": { + "proving_cost_modifier": -189396134, + "fee_asset_price_modifier": 211474354 + }, + "outputs": { + "fee_asset_price_at_execution": 10793368413, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30048695, + "proving_cost": 5439327850, + "congestion_cost": 20493270678, + "congestion_multiplier": 4746911647 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 324326635, + "proving_cost": 58708669404, + "congestion_cost": 221191420414, + "congestion_multiplier": 4746911647 + } + } + }, + { + "l1_block_number": 20974964, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8301086454 + }, + "parent_header": { + "excess_mana": 1331191646, + "mana_used": 87209194, + "proving_cost_per_mana_numerator": 252255241, + "fee_asset_price_numerator": 7846156025 + }, + "header": { + "excess_mana": 1318400840, + "mana_used": 103763183, + "proving_cost_per_mana_numerator": 370929871, + "fee_asset_price_numerator": 7994895828 + }, + "oracle_input": { + "proving_cost_modifier": 118674630, + "fee_asset_price_modifier": 148739803 + }, + "outputs": { + "fee_asset_price_at_execution": 10816217770, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 27497348, + "proving_cost": 5429035723, + "congestion_cost": 20060408407, + "congestion_multiplier": 4676401874 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 297417304, + "proving_cost": 58721632661, + "congestion_cost": 216977745885, + "congestion_multiplier": 4676401874 + } + } + }, + { + "l1_block_number": 20974967, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8897960618 + }, + "parent_header": { + "excess_mana": 1318400840, + "mana_used": 103763183, + "proving_cost_per_mana_numerator": 370929871, + "fee_asset_price_numerator": 7994895828 + }, + "header": { + "excess_mana": 1322164023, + "mana_used": 96243533, + "proving_cost_per_mana_numerator": 435025193, + "fee_asset_price_numerator": 8064434274 + }, + "oracle_input": { + "proving_cost_modifier": 64095322, + "fee_asset_price_modifier": 69538446 + }, + "outputs": { + "fee_asset_price_at_execution": 10832317762, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29474494, + "proving_cost": 5435482436, + "congestion_cost": 20204148580, + "congestion_multiplier": 4697037111 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 319277084, + "proving_cost": 58878872936, + "congestion_cost": 218857757529, + "congestion_multiplier": 4697037111 + } + } + }, + { + "l1_block_number": 20974970, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8878052220 + }, + "parent_header": { + "excess_mana": 1322164023, + "mana_used": 96243533, + "proving_cost_per_mana_numerator": 435025193, + "fee_asset_price_numerator": 8064434274 + }, + "header": { + "excess_mana": 1318407556, + "mana_used": 108984685, + "proving_cost_per_mana_numerator": 460258625, + "fee_asset_price_numerator": 7922857959 + }, + "oracle_input": { + "proving_cost_modifier": 25233432, + "fee_asset_price_modifier": -141576315 + }, + "outputs": { + "fee_asset_price_at_execution": 10839853007, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29408547, + "proving_cost": 5438967442, + "congestion_cost": 20104148674, + "congestion_multiplier": 4676438620 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 318784326, + "proving_cost": 58957607581, + "congestion_cost": 217926016457, + "congestion_multiplier": 4676438620 + } + } + }, + { + "l1_block_number": 20974973, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8944979149 + }, + "parent_header": { + "excess_mana": 1318407556, + "mana_used": 108984685, + "proving_cost_per_mana_numerator": 460258625, + "fee_asset_price_numerator": 7922857959 + }, + "header": { + "excess_mana": 1327392241, + "mana_used": 79765363, + "proving_cost_per_mana_numerator": 534368547, + "fee_asset_price_numerator": 8870191059 + }, + "oracle_input": { + "proving_cost_modifier": 74109922, + "fee_asset_price_modifier": 947333100 + }, + "outputs": { + "fee_asset_price_at_execution": 10824517201, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29630243, + "proving_cost": 5440340054, + "congestion_cost": 20380327197, + "congestion_multiplier": 4725857014 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 320733075, + "proving_cost": 58889054493, + "congestion_cost": 220607202305, + "congestion_multiplier": 4725857014 + } + } + }, + { + "l1_block_number": 20974976, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8661304425 + }, + "parent_header": { + "excess_mana": 1327392241, + "mana_used": 79765363, + "proving_cost_per_mana_numerator": 534368547, + "fee_asset_price_numerator": 8870191059 + }, + "header": { + "excess_mana": 1307157604, + "mana_used": 111586525, + "proving_cost_per_mana_numerator": 631784323, + "fee_asset_price_numerator": 8097895451 + }, + "oracle_input": { + "proving_cost_modifier": 97415776, + "fee_asset_price_modifier": -772295608 + }, + "outputs": { + "fee_asset_price_at_execution": 10927548691, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28690570, + "proving_cost": 5444373380, + "congestion_cost": 19786705617, + "congestion_multiplier": 4615288584 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313517600, + "proving_cost": 59493655201, + "congestion_cost": 216220189064, + "congestion_multiplier": 4615288584 + } + } + }, + { + "l1_block_number": 20974979, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8725503529 + }, + "parent_header": { + "excess_mana": 1307157604, + "mana_used": 111586525, + "proving_cost_per_mana_numerator": 631784323, + "fee_asset_price_numerator": 8097895451 + }, + "header": { + "excess_mana": 1318744129, + "mana_used": 89963278, + "proving_cost_per_mana_numerator": 528282288, + "fee_asset_price_numerator": 7833069405 + }, + "oracle_input": { + "proving_cost_modifier": -103502035, + "fee_asset_price_modifier": -264826046 + }, + "outputs": { + "fee_asset_price_at_execution": 10843480756, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28903230, + "proving_cost": 5449679642, + "congestion_cost": 20151764655, + "congestion_multiplier": 4678280520 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 313411618, + "proving_cost": 59093496324, + "congestion_cost": 218515272235, + "congestion_multiplier": 4678280520 + } + } + }, + { + "l1_block_number": 20974982, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8635480789 + }, + "parent_header": { + "excess_mana": 1318744129, + "mana_used": 89963278, + "proving_cost_per_mana_numerator": 528282288, + "fee_asset_price_numerator": 7833069405 + }, + "header": { + "excess_mana": 1308707407, + "mana_used": 105050231, + "proving_cost_per_mana_numerator": 534505171, + "fee_asset_price_numerator": 8001097969 + }, + "oracle_input": { + "proving_cost_modifier": 6222883, + "fee_asset_price_modifier": 168028564 + }, + "outputs": { + "fee_asset_price_at_execution": 10814802386, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 28605030, + "proving_cost": 5444042031, + "congestion_cost": 19831039272, + "congestion_multiplier": 4623664938 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 309357746, + "proving_cost": 58876238746, + "congestion_cost": 214468770835, + "congestion_multiplier": 4623664938 + } + } + }, + { + "l1_block_number": 20974985, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9253198960 + }, + "parent_header": { + "excess_mana": 1308707407, + "mana_used": 105050231, + "proving_cost_per_mana_numerator": 534505171, + "fee_asset_price_numerator": 8001097969 + }, + "header": { + "excess_mana": 1313757638, + "mana_used": 91611611, + "proving_cost_per_mana_numerator": 559614429, + "fee_asset_price_numerator": 8101746392 + }, + "oracle_input": { + "proving_cost_modifier": 25109258, + "fee_asset_price_modifier": 100648423 + }, + "outputs": { + "fee_asset_price_at_execution": 10832989618, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 30651221, + "proving_cost": 5444380818, + "congestion_cost": 19989703249, + "congestion_multiplier": 4651065986 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 332044358, + "proving_cost": 58978920877, + "congestion_cost": 216548247763, + "congestion_multiplier": 4651065986 + } + } + }, + { + "l1_block_number": 20974988, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8772488689 + }, + "parent_header": { + "excess_mana": 1313757638, + "mana_used": 91611611, + "proving_cost_per_mana_numerator": 559614429, + "fee_asset_price_numerator": 8101746392 + }, + "header": { + "excess_mana": 1305369249, + "mana_used": 113252671, + "proving_cost_per_mana_numerator": 417177712, + "fee_asset_price_numerator": 8070934001 + }, + "oracle_input": { + "proving_cost_modifier": -142436717, + "fee_asset_price_modifier": -30812391 + }, + "outputs": { + "fee_asset_price_at_execution": 10843898340, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29058868, + "proving_cost": 5445748033, + "congestion_cost": 19740192412, + "congestion_multiplier": 4605641764 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 315111410, + "proving_cost": 59053138055, + "congestion_cost": 214060639727, + "congestion_multiplier": 4605641764 + } + } + }, + { + "l1_block_number": 20974991, + "l1_fees": { + "blob_fee": 1, + "base_fee": 8898215086 + }, + "parent_header": { + "excess_mana": 1305369249, + "mana_used": 113252671, + "proving_cost_per_mana_numerator": 417177712, + "fee_asset_price_numerator": 8070934001 + }, + "header": { + "excess_mana": 1318621920, + "mana_used": 90250478, + "proving_cost_per_mana_numerator": 245435262, + "fee_asset_price_numerator": 7785208408 + }, + "oracle_input": { + "proving_cost_modifier": -171742450, + "fee_asset_price_modifier": -285725593 + }, + "outputs": { + "fee_asset_price_at_execution": 10840557591, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 29475337, + "proving_cost": 5437996810, + "congestion_cost": 20107239241, + "congestion_multiplier": 4677611646 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 319529088, + "proving_cost": 58950917598, + "congestion_cost": 217973684988, + "congestion_multiplier": 4677611646 + } + } + }, + { + "l1_block_number": 20974994, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9375929800 + }, + "parent_header": { + "excess_mana": 1318621920, + "mana_used": 90250478, + "proving_cost_per_mana_numerator": 245435262, + "fee_asset_price_numerator": 7785208408 + }, + "header": { + "excess_mana": 1308872398, + "mana_used": 95210532, + "proving_cost_per_mana_numerator": 318267081, + "fee_asset_price_numerator": 8018327579 + }, + "oracle_input": { + "proving_cost_modifier": 72831819, + "fee_asset_price_modifier": 233119171 + }, + "outputs": { + "fee_asset_price_at_execution": 10809627552, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 31057767, + "proving_cost": 5428665476, + "congestion_cost": 19789081232, + "congestion_multiplier": 4624557574 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 335722893, + "proving_cost": 58681851899, + "congestion_cost": 213912597714, + "congestion_multiplier": 4624557574 + } + } + }, + { + "l1_block_number": 20974997, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9712139037 + }, + "parent_header": { + "excess_mana": 1308872398, + "mana_used": 95210532, + "proving_cost_per_mana_numerator": 318267081, + "fee_asset_price_numerator": 8018327579 + }, + "header": { + "excess_mana": 1304082930, + "mana_used": 57474297, + "proving_cost_per_mana_numerator": 377674874, + "fee_asset_price_numerator": 8058999714 + }, + "oracle_input": { + "proving_cost_modifier": 59407793, + "fee_asset_price_modifier": 40672135 + }, + "outputs": { + "fee_asset_price_at_execution": 10834856261, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32171460, + "proving_cost": 5432620712, + "congestion_cost": 19666232392, + "congestion_multiplier": 4598715518 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 348573144, + "proving_cost": 58861664535, + "congestion_cost": 213080801162, + "congestion_multiplier": 4598715518 + } + } + }, + { + "l1_block_number": 20975000, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10320266532 + }, + "parent_header": { + "excess_mana": 1304082930, + "mana_used": 57474297, + "proving_cost_per_mana_numerator": 377674874, + "fee_asset_price_numerator": 8058999714 + }, + "header": { + "excess_mana": 1261557227, + "mana_used": 135729420, + "proving_cost_per_mana_numerator": 417528624, + "fee_asset_price_numerator": 7594293458 + }, + "oracle_input": { + "proving_cost_modifier": 39853750, + "fee_asset_price_modifier": -464706256 + }, + "outputs": { + "fee_asset_price_at_execution": 10839263925, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34185882, + "proving_cost": 5435849071, + "congestion_cost": 18464130689, + "congestion_multiplier": 4375505065 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 370549797, + "proving_cost": 58920602737, + "congestion_cost": 200137585683, + "congestion_multiplier": 4375505065 + } + } + }, + { + "l1_block_number": 20975003, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10168459328 + }, + "parent_header": { + "excess_mana": 1261557227, + "mana_used": 135729420, + "proving_cost_per_mana_numerator": 417528624, + "fee_asset_price_numerator": 7594293458 + }, + "header": { + "excess_mana": 1297286647, + "mana_used": 112984877, + "proving_cost_per_mana_numerator": 524867736, + "fee_asset_price_numerator": 7779610709 + }, + "oracle_input": { + "proving_cost_modifier": 107339112, + "fee_asset_price_modifier": 185317251 + }, + "outputs": { + "fee_asset_price_at_execution": 10789010044, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 33683021, + "proving_cost": 5438015893, + "congestion_cost": 19491795489, + "congestion_multiplier": 4562293137 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 363406451, + "proving_cost": 58670808089, + "congestion_cost": 210297177306, + "congestion_multiplier": 4562293137 + } + } + }, + { + "l1_block_number": 20975006, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10401786820 + }, + "parent_header": { + "excess_mana": 1297286647, + "mana_used": 112984877, + "proving_cost_per_mana_numerator": 524867736, + "fee_asset_price_numerator": 7779610709 + }, + "header": { + "excess_mana": 1310271524, + "mana_used": 110485095, + "proving_cost_per_mana_numerator": 519626542, + "fee_asset_price_numerator": 8264827175 + }, + "oracle_input": { + "proving_cost_modifier": -5241194, + "fee_asset_price_modifier": 485216466 + }, + "outputs": { + "fee_asset_price_at_execution": 10809022478, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 34455918, + "proving_cost": 5443856145, + "congestion_cost": 19897963890, + "congestion_multiplier": 4632134070 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 372434792, + "proving_cost": 58842763438, + "congestion_cost": 215077538953, + "congestion_multiplier": 4632134070 + } + } + }, + { + "l1_block_number": 20975009, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10702980460 + }, + "parent_header": { + "excess_mana": 1310271524, + "mana_used": 110485095, + "proving_cost_per_mana_numerator": 519626542, + "fee_asset_price_numerator": 8264827175 + }, + "header": { + "excess_mana": 1320756619, + "mana_used": 102141151, + "proving_cost_per_mana_numerator": 478575697, + "fee_asset_price_numerator": 7482690588 + }, + "oracle_input": { + "proving_cost_modifier": -41050845, + "fee_asset_price_modifier": -782136587 + }, + "outputs": { + "fee_asset_price_at_execution": 10861597083, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35453622, + "proving_cost": 5443570829, + "congestion_cost": 20213814437, + "congestion_multiplier": 4689309040 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 385082957, + "proving_cost": 59125873037, + "congestion_cost": 219554307925, + "congestion_multiplier": 4689309040 + } + } + }, + { + "l1_block_number": 20975012, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11536948339 + }, + "parent_header": { + "excess_mana": 1320756619, + "mana_used": 102141151, + "proving_cost_per_mana_numerator": 478575697, + "fee_asset_price_numerator": 7482690588 + }, + "header": { + "excess_mana": 1322897770, + "mana_used": 95947526, + "proving_cost_per_mana_numerator": 556287357, + "fee_asset_price_numerator": 7910988307 + }, + "oracle_input": { + "proving_cost_modifier": 77711660, + "fee_asset_price_modifier": 428297719 + }, + "outputs": { + "fee_asset_price_at_execution": 10776975916, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38216141, + "proving_cost": 5441336656, + "congestion_cost": 20280214903, + "congestion_multiplier": 4701071174 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 411854431, + "proving_cost": 58641154092, + "congestion_cost": 218559387580, + "congestion_multiplier": 4701071174 + } + } + }, + { + "l1_block_number": 20975015, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11359031521 + }, + "parent_header": { + "excess_mana": 1322897770, + "mana_used": 95947526, + "proving_cost_per_mana_numerator": 556287357, + "fee_asset_price_numerator": 7910988307 + }, + "header": { + "excess_mana": 1318845296, + "mana_used": 92861285, + "proving_cost_per_mana_numerator": 577567345, + "fee_asset_price_numerator": 8043579839 + }, + "oracle_input": { + "proving_cost_modifier": 21279988, + "fee_asset_price_modifier": 132591532 + }, + "outputs": { + "fee_asset_price_at_execution": 10823232445, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37626791, + "proving_cost": 5445566852, + "congestion_cost": 20171760841, + "congestion_multiplier": 4678834299 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 407243505, + "proving_cost": 58938635833, + "congestion_cost": 218323656407, + "congestion_multiplier": 4678834299 + } + } + }, + { + "l1_block_number": 20975018, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11201567819 + }, + "parent_header": { + "excess_mana": 1318845296, + "mana_used": 92861285, + "proving_cost_per_mana_numerator": 577567345, + "fee_asset_price_numerator": 8043579839 + }, + "header": { + "excess_mana": 1311706581, + "mana_used": 107725422, + "proving_cost_per_mana_numerator": 576270642, + "fee_asset_price_numerator": 8673737845 + }, + "oracle_input": { + "proving_cost_modifier": -1296703, + "fee_asset_price_modifier": 630158006 + }, + "outputs": { + "fee_asset_price_at_execution": 10837592653, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37105193, + "proving_cost": 5446725792, + "congestion_cost": 19960695297, + "congestion_multiplier": 4639918034 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 402130967, + "proving_cost": 59029395426, + "congestion_cost": 216325884699, + "congestion_multiplier": 4639918034 + } + } + }, + { + "l1_block_number": 20975021, + "l1_fees": { + "blob_fee": 1, + "base_fee": 9913252976 + }, + "parent_header": { + "excess_mana": 1311706581, + "mana_used": 107725422, + "proving_cost_per_mana_numerator": 576270642, + "fee_asset_price_numerator": 8673737845 + }, + "header": { + "excess_mana": 1319432003, + "mana_used": 114906142, + "proving_cost_per_mana_numerator": 589826202, + "fee_asset_price_numerator": 9223117112 + }, + "oracle_input": { + "proving_cost_modifier": 13555560, + "fee_asset_price_modifier": 549379267 + }, + "outputs": { + "fee_asset_price_at_execution": 10906102243, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 32837650, + "proving_cost": 5446655164, + "congestion_cost": 20175751030, + "congestion_multiplier": 4682047174 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 358130768, + "proving_cost": 59401778100, + "congestion_cost": 220038803562, + "congestion_multiplier": 4682047174 + } + } + }, + { + "l1_block_number": 20975024, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10599983896 + }, + "parent_header": { + "excess_mana": 1319432003, + "mana_used": 114906142, + "proving_cost_per_mana_numerator": 589826202, + "fee_asset_price_numerator": 9223117112 + }, + "header": { + "excess_mana": 1334338145, + "mana_used": 94649328, + "proving_cost_per_mana_numerator": 551090117, + "fee_asset_price_numerator": 9243600887 + }, + "oracle_input": { + "proving_cost_modifier": -38736085, + "fee_asset_price_modifier": 20483775 + }, + "outputs": { + "fee_asset_price_at_execution": 10966182992, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35112446, + "proving_cost": 5447393539, + "congestion_cost": 20638450530, + "congestion_multiplier": 4764419152 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 385049508, + "proving_cost": 59737114378, + "congestion_cost": 226325025183, + "congestion_multiplier": 4764419152 + } + } + }, + { + "l1_block_number": 20975027, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11446110527 + }, + "parent_header": { + "excess_mana": 1334338145, + "mana_used": 94649328, + "proving_cost_per_mana_numerator": 551090117, + "fee_asset_price_numerator": 9243600887 + }, + "header": { + "excess_mana": 1328987473, + "mana_used": 92306873, + "proving_cost_per_mana_numerator": 580816426, + "fee_asset_price_numerator": 8644364312 + }, + "oracle_input": { + "proving_cost_modifier": 29726309, + "fee_asset_price_modifier": -599236575 + }, + "outputs": { + "fee_asset_price_at_execution": 10968429510, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37915241, + "proving_cost": 5445283841, + "congestion_cost": 20478025152, + "congestion_multiplier": 4734685691 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 415870648, + "proving_cost": 59726211971, + "congestion_cost": 224611775383, + "congestion_multiplier": 4734685691 + } + } + }, + { + "l1_block_number": 20975030, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11076948971 + }, + "parent_header": { + "excess_mana": 1328987473, + "mana_used": 92306873, + "proving_cost_per_mana_numerator": 580816426, + "fee_asset_price_numerator": 8644364312 + }, + "header": { + "excess_mana": 1321294346, + "mana_used": 101265912, + "proving_cost_per_mana_numerator": 620609103, + "fee_asset_price_numerator": 8736960733 + }, + "oracle_input": { + "proving_cost_modifier": 39792677, + "fee_asset_price_modifier": 92596421 + }, + "outputs": { + "fee_asset_price_at_execution": 10902899206, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36692393, + "proving_cost": 5446902763, + "congestion_cost": 20246860163, + "congestion_multiplier": 4692260203 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 400053462, + "proving_cost": 59387031809, + "congestion_cost": 220749475595, + "congestion_multiplier": 4692260203 + } + } + }, + { + "l1_block_number": 20975033, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11283306741 + }, + "parent_header": { + "excess_mana": 1321294346, + "mana_used": 101265912, + "proving_cost_per_mana_numerator": 620609103, + "fee_asset_price_numerator": 8736960733 + }, + "header": { + "excess_mana": 1322560258, + "mana_used": 100901498, + "proving_cost_per_mana_numerator": 595189786, + "fee_asset_price_numerator": 9164105855 + }, + "oracle_input": { + "proving_cost_modifier": -25419317, + "fee_asset_price_modifier": 427145122 + }, + "outputs": { + "fee_asset_price_at_execution": 10912999576, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37375953, + "proving_cost": 5449070663, + "congestion_cost": 20295546381, + "congestion_multiplier": 4699215139 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 407883759, + "proving_cost": 59465705834, + "congestion_cost": 221485289050, + "congestion_multiplier": 4699215139 + } + } + }, + { + "l1_block_number": 20975036, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10860587186 + }, + "parent_header": { + "excess_mana": 1322560258, + "mana_used": 100901498, + "proving_cost_per_mana_numerator": 595189786, + "fee_asset_price_numerator": 9164105855 + }, + "header": { + "excess_mana": 1323461756, + "mana_used": 97604527, + "proving_cost_per_mana_numerator": 652162855, + "fee_asset_price_numerator": 8932035693 + }, + "oracle_input": { + "proving_cost_modifier": 56973069, + "fee_asset_price_modifier": -232070162 + }, + "outputs": { + "fee_asset_price_at_execution": 10959713619, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35975695, + "proving_cost": 5447685722, + "congestion_cost": 20312437487, + "congestion_multiplier": 4704174263 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 394283314, + "proving_cost": 59705075399, + "congestion_cost": 222618497761, + "congestion_multiplier": 4704174263 + } + } + }, + { + "l1_block_number": 20975039, + "l1_fees": { + "blob_fee": 1, + "base_fee": 10866970943 + }, + "parent_header": { + "excess_mana": 1323461756, + "mana_used": 97604527, + "proving_cost_per_mana_numerator": 652162855, + "fee_asset_price_numerator": 8932035693 + }, + "header": { + "excess_mana": 1321066283, + "mana_used": 90323102, + "proving_cost_per_mana_numerator": 633173688, + "fee_asset_price_numerator": 8577437773 + }, + "oracle_input": { + "proving_cost_modifier": -18989167, + "fee_asset_price_modifier": -354597920 + }, + "outputs": { + "fee_asset_price_at_execution": 10934308883, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 35996841, + "proving_cost": 5450790320, + "congestion_cost": 20251777044, + "congestion_multiplier": 4691008317 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 393600578, + "proving_cost": 59600625015, + "congestion_cost": 221439185628, + "congestion_multiplier": 4691008317 + } + } + }, + { + "l1_block_number": 20975042, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11041792448 + }, + "parent_header": { + "excess_mana": 1321066283, + "mana_used": 90323102, + "proving_cost_per_mana_numerator": 633173688, + "fee_asset_price_numerator": 8577437773 + }, + "header": { + "excess_mana": 1311389385, + "mana_used": 90949554, + "proving_cost_per_mana_numerator": 529914617, + "fee_asset_price_numerator": 8467260121 + }, + "oracle_input": { + "proving_cost_modifier": -103259071, + "fee_asset_price_modifier": -110177652 + }, + "outputs": { + "fee_asset_price_at_execution": 10895604714, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 36575937, + "proving_cost": 5449755359, + "congestion_cost": 19960350715, + "congestion_multiplier": 4638196390 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 398516951, + "proving_cost": 59378380179, + "congestion_cost": 217480091343, + "congestion_multiplier": 4638196390 + } + } + }, + { + "l1_block_number": 20975045, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11833006757 + }, + "parent_header": { + "excess_mana": 1311389385, + "mana_used": 90949554, + "proving_cost_per_mana_numerator": 529914617, + "fee_asset_price_numerator": 8467260121 + }, + "header": { + "excess_mana": 1302338939, + "mana_used": 112229615, + "proving_cost_per_mana_numerator": 474886245, + "fee_asset_price_numerator": 8426877839 + }, + "oracle_input": { + "proving_cost_modifier": -55028372, + "fee_asset_price_modifier": -40382282 + }, + "outputs": { + "fee_asset_price_at_execution": 10883606803, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 39196834, + "proving_cost": 5444130897, + "congestion_cost": 19681536035, + "congestion_multiplier": 4589341546 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 426602929, + "proving_cost": 59251780067, + "congestion_cost": 214206099484, + "congestion_multiplier": 4589341546 + } + } + }, + { + "l1_block_number": 20975048, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11691009725 + }, + "parent_header": { + "excess_mana": 1302338939, + "mana_used": 112229615, + "proving_cost_per_mana_numerator": 474886245, + "fee_asset_price_numerator": 8426877839 + }, + "header": { + "excess_mana": 1314568554, + "mana_used": 101270628, + "proving_cost_per_mana_numerator": 632296174, + "fee_asset_price_numerator": 8794436593 + }, + "oracle_input": { + "proving_cost_modifier": 157409929, + "fee_asset_price_modifier": 367558754 + }, + "outputs": { + "fee_asset_price_at_execution": 10879212642, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 38726469, + "proving_cost": 5441135904, + "congestion_cost": 20031532129, + "congestion_multiplier": 4655480880 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 421313491, + "proving_cost": 59195274513, + "congestion_cost": 217927297576, + "congestion_multiplier": 4655480880 + } + } + }, + { + "l1_block_number": 20975051, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11981504880 + }, + "parent_header": { + "excess_mana": 1314568554, + "mana_used": 101270628, + "proving_cost_per_mana_numerator": 632296174, + "fee_asset_price_numerator": 8794436593 + }, + "header": { + "excess_mana": 1315839182, + "mana_used": 95222710, + "proving_cost_per_mana_numerator": 423476750, + "fee_asset_price_numerator": 9220027633 + }, + "oracle_input": { + "proving_cost_modifier": -208819424, + "fee_asset_price_modifier": 425591040 + }, + "outputs": { + "fee_asset_price_at_execution": 10919273719, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 39688734, + "proving_cost": 5449707537, + "congestion_cost": 20104403476, + "congestion_multiplier": 4662407027 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 433372150, + "proving_cost": 59506848285, + "congestion_cost": 219525484511, + "congestion_multiplier": 4662407027 + } + } + }, + { + "l1_block_number": 20975054, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12160928021 + }, + "parent_header": { + "excess_mana": 1315839182, + "mana_used": 95222710, + "proving_cost_per_mana_numerator": 423476750, + "fee_asset_price_numerator": 9220027633 + }, + "header": { + "excess_mana": 1311061892, + "mana_used": 123820176, + "proving_cost_per_mana_numerator": 348788374, + "fee_asset_price_numerator": 8941079810 + }, + "oracle_input": { + "proving_cost_modifier": -74688376, + "fee_asset_price_modifier": -278947823 + }, + "outputs": { + "fee_asset_price_at_execution": 10965844199, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 40283074, + "proving_cost": 5438339362, + "congestion_cost": 19922569607, + "congestion_multiplier": 4636419527 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 441737913, + "proving_cost": 59635982144, + "congestion_cost": 218467794354, + "congestion_multiplier": 4636419527 + } + } + }, + { + "l1_block_number": 20975057, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12913546101 + }, + "parent_header": { + "excess_mana": 1311061892, + "mana_used": 123820176, + "proving_cost_per_mana_numerator": 348788374, + "fee_asset_price_numerator": 8941079810 + }, + "header": { + "excess_mana": 1334882068, + "mana_used": 93982896, + "proving_cost_per_mana_numerator": 195305836, + "fee_asset_price_numerator": 8870005590 + }, + "oracle_input": { + "proving_cost_modifier": -153482538, + "fee_asset_price_modifier": -71074220 + }, + "outputs": { + "fee_asset_price_at_execution": 10935297840, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 42776121, + "proving_cost": 5434279072, + "congestion_cost": 20634543335, + "congestion_multiplier": 4767452145 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 467769623, + "proving_cost": 59425460197, + "congestion_cost": 225644877160, + "congestion_multiplier": 4767452145 + } + } + }, + { + "l1_block_number": 20975060, + "l1_fees": { + "blob_fee": 1, + "base_fee": 14539177654 + }, + "parent_header": { + "excess_mana": 1334882068, + "mana_used": 93982896, + "proving_cost_per_mana_numerator": 195305836, + "fee_asset_price_numerator": 8870005590 + }, + "header": { + "excess_mana": 1328864964, + "mana_used": 90824690, + "proving_cost_per_mana_numerator": 122449014, + "fee_asset_price_numerator": 9650640266 + }, + "oracle_input": { + "proving_cost_modifier": -72856822, + "fee_asset_price_modifier": 780634676 + }, + "outputs": { + "fee_asset_price_at_execution": 10927528423, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 48161025, + "proving_cost": 5425944800, + "congestion_cost": 20440349967, + "congestion_multiplier": 4734007091 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 526280969, + "proving_cost": 59292166023, + "congestion_cost": 223362505240, + "congestion_multiplier": 4734007091 + } + } + }, + { + "l1_block_number": 20975063, + "l1_fees": { + "blob_fee": 1, + "base_fee": 16652594433 + }, + "parent_header": { + "excess_mana": 1328864964, + "mana_used": 90824690, + "proving_cost_per_mana_numerator": 122449014, + "fee_asset_price_numerator": 9650640266 + }, + "header": { + "excess_mana": 1319689654, + "mana_used": 105117350, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 9709646324 + }, + "oracle_input": { + "proving_cost_modifier": -141123043, + "fee_asset_price_modifier": 59006058 + }, + "outputs": { + "fee_asset_price_at_execution": 11013166324, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 55161719, + "proving_cost": 5421993068, + "congestion_cost": 20174873988, + "congestion_multiplier": 4683458798 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 607505186, + "proving_cost": 59713311465, + "congestion_cost": 222189242795, + "congestion_multiplier": 4683458798 + } + } + }, + { + "l1_block_number": 20975066, + "l1_fees": { + "blob_fee": 1, + "base_fee": 18249319128 + }, + "parent_header": { + "excess_mana": 1319689654, + "mana_used": 105117350, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 9709646324 + }, + "header": { + "excess_mana": 1324807004, + "mana_used": 101364337, + "proving_cost_per_mana_numerator": 128284611, + "fee_asset_price_numerator": 9289510144 + }, + "oracle_input": { + "proving_cost_modifier": 128284611, + "fee_asset_price_modifier": -420136180 + }, + "outputs": { + "fee_asset_price_at_execution": 11019666677, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 60450869, + "proving_cost": 5415357955, + "congestion_cost": 20323925414, + "congestion_multiplier": 4711584182 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 666148426, + "proving_cost": 59675439600, + "congestion_cost": 223962883630, + "congestion_multiplier": 4711584182 + } + } + }, + { + "l1_block_number": 20975069, + "l1_fees": { + "blob_fee": 1, + "base_fee": 18581711762 + }, + "parent_header": { + "excess_mana": 1324807004, + "mana_used": 101364337, + "proving_cost_per_mana_numerator": 128284611, + "fee_asset_price_numerator": 9289510144 + }, + "header": { + "excess_mana": 1326171341, + "mana_used": 98775140, + "proving_cost_per_mana_numerator": 10819532, + "fee_asset_price_numerator": 9750284946 + }, + "oracle_input": { + "proving_cost_modifier": -117465079, + "fee_asset_price_modifier": 460774802 + }, + "outputs": { + "fee_asset_price_at_execution": 10973466191, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 61551920, + "proving_cost": 5422309483, + "congestion_cost": 20395090193, + "congestion_multiplier": 4719111169 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 675437913, + "proving_cost": 59501529788, + "congestion_cost": 223804832695, + "congestion_multiplier": 4719111169 + } + } + }, + { + "l1_block_number": 20975072, + "l1_fees": { + "blob_fee": 1, + "base_fee": 18508034366 + }, + "parent_header": { + "excess_mana": 1326171341, + "mana_used": 98775140, + "proving_cost_per_mana_numerator": 10819532, + "fee_asset_price_numerator": 9750284946 + }, + "header": { + "excess_mana": 1324946481, + "mana_used": 102197042, + "proving_cost_per_mana_numerator": 26005399, + "fee_asset_price_numerator": 9952218389 + }, + "oracle_input": { + "proving_cost_modifier": 15185867, + "fee_asset_price_modifier": 201933443 + }, + "outputs": { + "fee_asset_price_at_execution": 11024145828, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 61307863, + "proving_cost": 5415943903, + "congestion_cost": 20333492677, + "congestion_multiplier": 4712353119 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 675866822, + "proving_cost": 59706155382, + "congestion_cost": 224159388463, + "congestion_multiplier": 4712353119 + } + } + }, + { + "l1_block_number": 20975075, + "l1_fees": { + "blob_fee": 1, + "base_fee": 16846912203 + }, + "parent_header": { + "excess_mana": 1324946481, + "mana_used": 102197042, + "proving_cost_per_mana_numerator": 26005399, + "fee_asset_price_numerator": 9952218389 + }, + "header": { + "excess_mana": 1327143523, + "mana_used": 88168307, + "proving_cost_per_mana_numerator": 114842777, + "fee_asset_price_numerator": 10106089984 + }, + "oracle_input": { + "proving_cost_modifier": 88837378, + "fee_asset_price_modifier": 153871595 + }, + "outputs": { + "fee_asset_price_at_execution": 11046429757, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 55805396, + "proving_cost": 5416766423, + "congestion_cost": 20382495173, + "congestion_multiplier": 4724481989 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 616450386, + "proving_cost": 59835929801, + "congestion_cost": 225153801200, + "congestion_multiplier": 4724481989 + } + } + }, + { + "l1_block_number": 20975078, + "l1_fees": { + "blob_fee": 1, + "base_fee": 20153470138 + }, + "parent_header": { + "excess_mana": 1327143523, + "mana_used": 88168307, + "proving_cost_per_mana_numerator": 114842777, + "fee_asset_price_numerator": 10106089984 + }, + "header": { + "excess_mana": 1315311830, + "mana_used": 116305637, + "proving_cost_per_mana_numerator": 126735087, + "fee_asset_price_numerator": 10553381925 + }, + "oracle_input": { + "proving_cost_modifier": 11892310, + "fee_asset_price_modifier": 447291941 + }, + "outputs": { + "fee_asset_price_at_execution": 11063440158, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 66758369, + "proving_cost": 5421580674, + "congestion_cost": 20084747964, + "congestion_multiplier": 4659531200 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 738577220, + "proving_cost": 59981333348, + "congestion_cost": 222206407188, + "congestion_multiplier": 4659531200 + } + } + }, + { + "l1_block_number": 20975081, + "l1_fees": { + "blob_fee": 1, + "base_fee": 20365754346 + }, + "parent_header": { + "excess_mana": 1315311830, + "mana_used": 116305637, + "proving_cost_per_mana_numerator": 126735087, + "fee_asset_price_numerator": 10553381925 + }, + "header": { + "excess_mana": 1331617467, + "mana_used": 83202142, + "proving_cost_per_mana_numerator": 5960869, + "fee_asset_price_numerator": 10576638721 + }, + "oracle_input": { + "proving_cost_modifier": -120774218, + "fee_asset_price_modifier": 23256796 + }, + "outputs": { + "fee_asset_price_at_execution": 11113036873, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 67461561, + "proving_cost": 5422225464, + "congestion_cost": 20582358386, + "congestion_multiplier": 4749277198 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 749702814, + "proving_cost": 60257391515, + "congestion_cost": 228732507676, + "congestion_multiplier": 4749277198 + } + } + }, + { + "l1_block_number": 20975084, + "l1_fees": { + "blob_fee": 1, + "base_fee": 19718960848 + }, + "parent_header": { + "excess_mana": 1331617467, + "mana_used": 83202142, + "proving_cost_per_mana_numerator": 5960869, + "fee_asset_price_numerator": 10576638721 + }, + "header": { + "excess_mana": 1314819609, + "mana_used": 104175730, + "proving_cost_per_mana_numerator": 14836989, + "fee_asset_price_numerator": 10419130569 + }, + "oracle_input": { + "proving_cost_modifier": 8876120, + "fee_asset_price_modifier": -157508152 + }, + "outputs": { + "fee_asset_price_at_execution": 11115621710, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 65319057, + "proving_cost": 5415680767, + "congestion_cost": 20043186286, + "congestion_multiplier": 4656848555 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 726061928, + "proving_cost": 60198658708, + "congestion_cost": 222792476618, + "congestion_multiplier": 4656848555 + } + } + }, + { + "l1_block_number": 20975087, + "l1_fees": { + "blob_fee": 1, + "base_fee": 18161430857 + }, + "parent_header": { + "excess_mana": 1314819609, + "mana_used": 104175730, + "proving_cost_per_mana_numerator": 14836989, + "fee_asset_price_numerator": 10419130569 + }, + "header": { + "excess_mana": 1318995339, + "mana_used": 81358527, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10344089503 + }, + "oracle_input": { + "proving_cost_modifier": -21425270, + "fee_asset_price_modifier": -75041066 + }, + "outputs": { + "fee_asset_price_at_execution": 11098127481, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 60159739, + "proving_cost": 5416161490, + "congestion_cost": 20150976855, + "congestion_multiplier": 4679655742 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 667660452, + "proving_cost": 60109250673, + "congestion_cost": 223638110003, + "congestion_multiplier": 4679655742 + } + } + }, + { + "l1_block_number": 20975090, + "l1_fees": { + "blob_fee": 1, + "base_fee": 19301653207 + }, + "parent_header": { + "excess_mana": 1318995339, + "mana_used": 81358527, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10344089503 + }, + "header": { + "excess_mana": 1300353866, + "mana_used": 120465579, + "proving_cost_per_mana_numerator": 92323832, + "fee_asset_price_numerator": 9546868216 + }, + "oracle_input": { + "proving_cost_modifier": 92323832, + "fee_asset_price_modifier": -797221287 + }, + "outputs": { + "fee_asset_price_at_execution": 11089802451, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 63936726, + "proving_cost": 5415357955, + "congestion_cost": 19608724511, + "congestion_multiplier": 4578695006 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 709045660, + "proving_cost": 60055249922, + "congestion_cost": 217456881143, + "congestion_multiplier": 4578695006 + } + } + }, + { + "l1_block_number": 20975093, + "l1_fees": { + "blob_fee": 1, + "base_fee": 19362551866 + }, + "parent_header": { + "excess_mana": 1300353866, + "mana_used": 120465579, + "proving_cost_per_mana_numerator": 92323832, + "fee_asset_price_numerator": 9546868216 + }, + "header": { + "excess_mana": 1320819445, + "mana_used": 103670134, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10053927891 + }, + "oracle_input": { + "proving_cost_modifier": -165526439, + "fee_asset_price_modifier": 507059675 + }, + "outputs": { + "fee_asset_price_at_execution": 11001743664, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 64138453, + "proving_cost": 5420359929, + "congestion_cost": 20235900005, + "congestion_multiplier": 4689653747 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 705634818, + "proving_cost": 59633410505, + "congestion_cost": 222630184665, + "congestion_multiplier": 4689653747 + } + } + }, + { + "l1_block_number": 20975096, + "l1_fees": { + "blob_fee": 1, + "base_fee": 17613864145 + }, + "parent_header": { + "excess_mana": 1320819445, + "mana_used": 103670134, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10053927891 + }, + "header": { + "excess_mana": 1324489579, + "mana_used": 106564847, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 9640848007 + }, + "oracle_input": { + "proving_cost_modifier": -24024628, + "fee_asset_price_modifier": -413079884 + }, + "outputs": { + "fee_asset_price_at_execution": 11057670741, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 58345924, + "proving_cost": 5415357955, + "congestion_cost": 20306536505, + "congestion_multiplier": 4709834685 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 645170016, + "proving_cost": 59881245211, + "congestion_cost": 224542994562, + "congestion_multiplier": 4709834685 + } + } + }, + { + "l1_block_number": 20975099, + "l1_fees": { + "blob_fee": 1, + "base_fee": 18068788476 + }, + "parent_header": { + "excess_mana": 1324489579, + "mana_used": 106564847, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 9640848007 + }, + "header": { + "excess_mana": 1331054426, + "mana_used": 87336617, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10276407143 + }, + "oracle_input": { + "proving_cost_modifier": -75005104, + "fee_asset_price_modifier": 635559136 + }, + "outputs": { + "fee_asset_price_at_execution": 11012087939, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 59852861, + "proving_cost": 5415357955, + "congestion_cost": 20510958830, + "congestion_multiplier": 4746149604 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 659104968, + "proving_cost": 59634398021, + "congestion_cost": 225868482349, + "congestion_multiplier": 4746149604 + } + } + }, + { + "l1_block_number": 20975102, + "l1_fees": { + "blob_fee": 1, + "base_fee": 16794255548 + }, + "parent_header": { + "excess_mana": 1331054426, + "mana_used": 87336617, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10276407143 + }, + "header": { + "excess_mana": 1318391043, + "mana_used": 113102161, + "proving_cost_per_mana_numerator": 113584083, + "fee_asset_price_numerator": 10577915632 + }, + "oracle_input": { + "proving_cost_modifier": 113584083, + "fee_asset_price_modifier": 301508489 + }, + "outputs": { + "fee_asset_price_at_execution": 11082299151, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 55630971, + "proving_cost": 5415357955, + "congestion_cost": 20113260678, + "congestion_multiplier": 4676348271 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 616519062, + "proving_cost": 60014616867, + "congestion_cost": 222901171735, + "congestion_multiplier": 4676348271 + } + } + }, + { + "l1_block_number": 20975105, + "l1_fees": { + "blob_fee": 1, + "base_fee": 17225028163 + }, + "parent_header": { + "excess_mana": 1318391043, + "mana_used": 113102161, + "proving_cost_per_mana_numerator": 113584083, + "fee_asset_price_numerator": 10577915632 + }, + "header": { + "excess_mana": 1331493204, + "mana_used": 101779107, + "proving_cost_per_mana_numerator": 74612133, + "fee_asset_price_numerator": 10778362448 + }, + "oracle_input": { + "proving_cost_modifier": -38971950, + "fee_asset_price_modifier": 200446816 + }, + "outputs": { + "fee_asset_price_at_execution": 11115763647, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 57057905, + "proving_cost": 5421512434, + "congestion_cost": 20536896241, + "congestion_multiplier": 4748586761 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 634242186, + "proving_cost": 60264250825, + "congestion_cost": 228283284657, + "congestion_multiplier": 4748586761 + } + } + }, + { + "l1_block_number": 20975108, + "l1_fees": { + "blob_fee": 1, + "base_fee": 16802177302 + }, + "parent_header": { + "excess_mana": 1331493204, + "mana_used": 101779107, + "proving_cost_per_mana_numerator": 74612133, + "fee_asset_price_numerator": 10778362448 + }, + "header": { + "excess_mana": 1333272311, + "mana_used": 92008465, + "proving_cost_per_mana_numerator": 202382631, + "fee_asset_price_numerator": 11242911350 + }, + "oracle_input": { + "proving_cost_modifier": 127770498, + "fee_asset_price_modifier": 464548902 + }, + "outputs": { + "fee_asset_price_at_execution": 11138067188, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 55657212, + "proving_cost": 5419399976, + "congestion_cost": 20577901158, + "congestion_multiplier": 4758481501 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 619913766, + "proving_cost": 60361641051, + "congestion_cost": 229198045685, + "congestion_multiplier": 4758481501 + } + } + }, + { + "l1_block_number": 20975111, + "l1_fees": { + "blob_fee": 1, + "base_fee": 15985470904 + }, + "parent_header": { + "excess_mana": 1333272311, + "mana_used": 92008465, + "proving_cost_per_mana_numerator": 202382631, + "fee_asset_price_numerator": 11242911350 + }, + "header": { + "excess_mana": 1325280776, + "mana_used": 99264175, + "proving_cost_per_mana_numerator": 152318466, + "fee_asset_price_numerator": 11312887858 + }, + "oracle_input": { + "proving_cost_modifier": -50064165, + "fee_asset_price_modifier": 69976508 + }, + "outputs": { + "fee_asset_price_at_execution": 11189929326, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 52951872, + "proving_cost": 5426328796, + "congestion_cost": 20351125622, + "congestion_multiplier": 4714196599 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 592527705, + "proving_cost": 60720235726, + "congestion_cost": 227727657414, + "congestion_multiplier": 4714196599 + } + } + }, + { + "l1_block_number": 20975114, + "l1_fees": { + "blob_fee": 1, + "base_fee": 15707407969 + }, + "parent_header": { + "excess_mana": 1325280776, + "mana_used": 99264175, + "proving_cost_per_mana_numerator": 152318466, + "fee_asset_price_numerator": 11312887858 + }, + "header": { + "excess_mana": 1324544951, + "mana_used": 105837320, + "proving_cost_per_mana_numerator": 147122574, + "fee_asset_price_numerator": 11397366686 + }, + "oracle_input": { + "proving_cost_modifier": -5195892, + "fee_asset_price_modifier": 84478828 + }, + "outputs": { + "fee_asset_price_at_execution": 11197762388, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 52030788, + "proving_cost": 5423612830, + "congestion_cost": 20315403438, + "congestion_multiplier": 4710139822 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 582628400, + "proving_cost": 60732327754, + "congestion_cost": 227487060515, + "congestion_multiplier": 4710139822 + } + } + }, + { + "l1_block_number": 20975117, + "l1_fees": { + "blob_fee": 1, + "base_fee": 14997613813 + }, + "parent_header": { + "excess_mana": 1324544951, + "mana_used": 105837320, + "proving_cost_per_mana_numerator": 147122574, + "fee_asset_price_numerator": 11397366686 + }, + "header": { + "excess_mana": 1330382271, + "mana_used": 90145608, + "proving_cost_per_mana_numerator": 75063816, + "fee_asset_price_numerator": 11723591217 + }, + "oracle_input": { + "proving_cost_modifier": -72058758, + "fee_asset_price_modifier": 326224531 + }, + "outputs": { + "fee_asset_price_at_execution": 11207226123, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 49679595, + "proving_cost": 5423331032, + "congestion_cost": 20482296757, + "congestion_multiplier": 4742418598 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 556770454, + "proving_cost": 60780497215, + "congestion_cost": 229549731274, + "congestion_multiplier": 4742418598 + } + } + }, + { + "l1_block_number": 20975120, + "l1_fees": { + "blob_fee": 1, + "base_fee": 14135639349 + }, + "parent_header": { + "excess_mana": 1330382271, + "mana_used": 90145608, + "proving_cost_per_mana_numerator": 75063816, + "fee_asset_price_numerator": 11723591217 + }, + "header": { + "excess_mana": 1320527879, + "mana_used": 90915825, + "proving_cost_per_mana_numerator": 27208757, + "fee_asset_price_numerator": 10969222287 + }, + "oracle_input": { + "proving_cost_modifier": -47855059, + "fee_asset_price_modifier": -754368930 + }, + "outputs": { + "fee_asset_price_at_execution": 11243846544, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 46824305, + "proving_cost": 5419424455, + "congestion_cost": 20159821850, + "congestion_multiplier": 4688054228 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 526485299, + "proving_cost": 60935176928, + "congestion_cost": 226673943235, + "congestion_multiplier": 4688054228 + } + } + }, + { + "l1_block_number": 20975123, + "l1_fees": { + "blob_fee": 1, + "base_fee": 13793046280 + }, + "parent_header": { + "excess_mana": 1320527879, + "mana_used": 90915825, + "proving_cost_per_mana_numerator": 27208757, + "fee_asset_price_numerator": 10969222287 + }, + "header": { + "excess_mana": 1311443704, + "mana_used": 101140231, + "proving_cost_per_mana_numerator": 179746030, + "fee_asset_price_numerator": 10987035599 + }, + "oracle_input": { + "proving_cost_modifier": 152537273, + "fee_asset_price_modifier": 17813312 + }, + "outputs": { + "fee_asset_price_at_execution": 11159345584, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 45689465, + "proving_cost": 5416831607, + "congestion_cost": 19875334697, + "congestion_multiplier": 4638491172 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 509864529, + "proving_cost": 60448295872, + "congestion_cost": 221795728481, + "congestion_multiplier": 4638491172 + } + } + }, + { + "l1_block_number": 20975126, + "l1_fees": { + "blob_fee": 1, + "base_fee": 13713634735 + }, + "parent_header": { + "excess_mana": 1311443704, + "mana_used": 101140231, + "proving_cost_per_mana_numerator": 179746030, + "fee_asset_price_numerator": 10987035599 + }, + "header": { + "excess_mana": 1312583935, + "mana_used": 95308047, + "proving_cost_per_mana_numerator": 186248322, + "fee_asset_price_numerator": 10453873707 + }, + "oracle_input": { + "proving_cost_modifier": 6502292, + "fee_asset_price_modifier": -533161892 + }, + "outputs": { + "fee_asset_price_at_execution": 11161333610, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 45426415, + "proving_cost": 5425100599, + "congestion_cost": 19938338854, + "congestion_multiplier": 4644683374 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 507019372, + "proving_cost": 60551357653, + "congestion_cost": 222538451578, + "congestion_multiplier": 4644683374 + } + } + }, + { + "l1_block_number": 20975129, + "l1_fees": { + "blob_fee": 1, + "base_fee": 13219632519 + }, + "parent_header": { + "excess_mana": 1312583935, + "mana_used": 95308047, + "proving_cost_per_mana_numerator": 186248322, + "fee_asset_price_numerator": 10453873707 + }, + "header": { + "excess_mana": 1307891982, + "mana_used": 93623516, + "proving_cost_per_mana_numerator": 135139372, + "fee_asset_price_numerator": 10080607623 + }, + "oracle_input": { + "proving_cost_modifier": -51108950, + "fee_asset_price_modifier": -373266084 + }, + "outputs": { + "fee_asset_price_at_execution": 11101983988, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 43790032, + "proving_cost": 5425453366, + "congestion_cost": 19794591146, + "congestion_multiplier": 4619255847 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 486156234, + "proving_cost": 60233296396, + "congestion_cost": 219759233951, + "congestion_multiplier": 4619255847 + } + } + }, + { + "l1_block_number": 20975132, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12935777298 + }, + "parent_header": { + "excess_mana": 1307891982, + "mana_used": 93623516, + "proving_cost_per_mana_numerator": 135139372, + "fee_asset_price_numerator": 10080607623 + }, + "header": { + "excess_mana": 1301515498, + "mana_used": 110330450, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10211821717 + }, + "oracle_input": { + "proving_cost_modifier": -240364208, + "fee_asset_price_modifier": 131214094 + }, + "outputs": { + "fee_asset_price_at_execution": 11060621292, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 42849762, + "proving_cost": 5422681182, + "congestion_cost": 19593503128, + "congestion_multiplier": 4584922184 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 473944989, + "proving_cost": 59978222941, + "congestion_cost": 216716317882, + "congestion_multiplier": 4584922184 + } + } + }, + { + "l1_block_number": 20975135, + "l1_fees": { + "blob_fee": 1, + "base_fee": 13008513572 + }, + "parent_header": { + "excess_mana": 1301515498, + "mana_used": 110330450, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10211821717 + }, + "header": { + "excess_mana": 1311845948, + "mana_used": 90935667, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10435521602 + }, + "oracle_input": { + "proving_cost_modifier": -124659637, + "fee_asset_price_modifier": 223699885 + }, + "outputs": { + "fee_asset_price_at_execution": 11075143912, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 43090701, + "proving_cost": 5415357955, + "congestion_cost": 19872435803, + "congestion_multiplier": 4640674678 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 477235714, + "proving_cost": 59975868686, + "congestion_cost": 220090086400, + "congestion_multiplier": 4640674678 + } + } + }, + { + "l1_block_number": 20975138, + "l1_fees": { + "blob_fee": 1, + "base_fee": 13141320281 + }, + "parent_header": { + "excess_mana": 1311845948, + "mana_used": 90935667, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10435521602 + }, + "header": { + "excess_mana": 1302781615, + "mana_used": 119918223, + "proving_cost_per_mana_numerator": 157775447, + "fee_asset_price_numerator": 10260006113 + }, + "oracle_input": { + "proving_cost_modifier": 157775447, + "fee_asset_price_modifier": -175515489 + }, + "outputs": { + "fee_asset_price_at_execution": 11099946727, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 43530623, + "proving_cost": 5415357955, + "congestion_cost": 19606794501, + "congestion_multiplier": 4591719124 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 483187596, + "proving_cost": 60110184808, + "congestion_cost": 217634374448, + "congestion_multiplier": 4591719124 + } + } + }, + { + "l1_block_number": 20975141, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12955542361 + }, + "parent_header": { + "excess_mana": 1302781615, + "mana_used": 119918223, + "proving_cost_per_mana_numerator": 157775447, + "fee_asset_price_numerator": 10260006113 + }, + "header": { + "excess_mana": 1322699838, + "mana_used": 90906414, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10929680429 + }, + "oracle_input": { + "proving_cost_modifier": -166691750, + "fee_asset_price_modifier": 669674316 + }, + "outputs": { + "fee_asset_price_at_execution": 11080481689, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 42915234, + "proving_cost": 5423908804, + "congestion_cost": 20227153949, + "congestion_multiplier": 4699982624 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 475521464, + "proving_cost": 60099522185, + "congestion_cost": 224126608952, + "congestion_multiplier": 4699982624 + } + } + }, + { + "l1_block_number": 20975144, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12711944992 + }, + "parent_header": { + "excess_mana": 1322699838, + "mana_used": 90906414, + "proving_cost_per_mana_numerator": 0, + "fee_asset_price_numerator": 10929680429 + }, + "header": { + "excess_mana": 1313606252, + "mana_used": 109329982, + "proving_cost_per_mana_numerator": 27373813, + "fee_asset_price_numerator": 11439057352 + }, + "oracle_input": { + "proving_cost_modifier": 27373813, + "fee_asset_price_modifier": 509376923 + }, + "outputs": { + "fee_asset_price_at_execution": 11154933844, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 42108317, + "proving_cost": 5415357955, + "congestion_cost": 19921073991, + "congestion_multiplier": 4650242255 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 469715490, + "proving_cost": 60407959729, + "congestion_cost": 222218262471, + "congestion_multiplier": 4650242255 + } + } + }, + { + "l1_block_number": 20975147, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12647455153 + }, + "parent_header": { + "excess_mana": 1313606252, + "mana_used": 109329982, + "proving_cost_per_mana_numerator": 27373813, + "fee_asset_price_numerator": 11439057352 + }, + "header": { + "excess_mana": 1322936234, + "mana_used": 112778076, + "proving_cost_per_mana_numerator": 49560232, + "fee_asset_price_numerator": 11250716091 + }, + "oracle_input": { + "proving_cost_modifier": 22186419, + "fee_asset_price_modifier": -188341261 + }, + "outputs": { + "fee_asset_price_at_execution": 11211899464, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41894695, + "proving_cost": 5416840547, + "congestion_cost": 20204322533, + "congestion_multiplier": 4701282740 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 469719108, + "proving_cost": 60733071625, + "congestion_cost": 226528832978, + "congestion_multiplier": 4701282740 + } + } + }, + { + "l1_block_number": 20975150, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12756925909 + }, + "parent_header": { + "excess_mana": 1322936234, + "mana_used": 112778076, + "proving_cost_per_mana_numerator": 49560232, + "fee_asset_price_numerator": 11250716091 + }, + "header": { + "excess_mana": 1335714310, + "mana_used": 85860560, + "proving_cost_per_mana_numerator": 72408886, + "fee_asset_price_numerator": 11664879860 + }, + "oracle_input": { + "proving_cost_modifier": 22848654, + "fee_asset_price_modifier": 414163769 + }, + "outputs": { + "fee_asset_price_at_execution": 11190802705, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 42257317, + "proving_cost": 5418042484, + "congestion_cost": 20596778232, + "congestion_multiplier": 4772096585 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 472893297, + "proving_cost": 60632244485, + "congestion_cost": 230494481552, + "congestion_multiplier": 4772096585 + } + } + }, + { + "l1_block_number": 20975153, + "l1_fees": { + "blob_fee": 1, + "base_fee": 11185568066 + }, + "parent_header": { + "excess_mana": 1335714310, + "mana_used": 85860560, + "proving_cost_per_mana_numerator": 72408886, + "fee_asset_price_numerator": 11664879860 + }, + "header": { + "excess_mana": 1321574870, + "mana_used": 96504708, + "proving_cost_per_mana_numerator": 97425002, + "fee_asset_price_numerator": 12050972543 + }, + "oracle_input": { + "proving_cost_modifier": 25016116, + "fee_asset_price_modifier": 386092683 + }, + "outputs": { + "fee_asset_price_at_execution": 11237247066, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 37052194, + "proving_cost": 5419280575, + "congestion_cost": 20154604803, + "congestion_multiplier": 4693800517 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 416364658, + "proving_cost": 60897794741, + "congestion_cost": 226482273688, + "congestion_multiplier": 4693800517 + } + } + }, + { + "l1_block_number": 20975156, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12473704501 + }, + "parent_header": { + "excess_mana": 1321574870, + "mana_used": 96504708, + "proving_cost_per_mana_numerator": 97425002, + "fee_asset_price_numerator": 12050972543 + }, + "header": { + "excess_mana": 1318079578, + "mana_used": 92818286, + "proving_cost_per_mana_numerator": 97491349, + "fee_asset_price_numerator": 11679832926 + }, + "oracle_input": { + "proving_cost_modifier": 66347, + "fee_asset_price_modifier": -371139617 + }, + "outputs": { + "fee_asset_price_at_execution": 11280717118, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41319146, + "proving_cost": 5420636438, + "congestion_cost": 20070744800, + "congestion_multiplier": 4674644455 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 466109597, + "proving_cost": 61148666256, + "congestion_cost": 226412394436, + "congestion_multiplier": 4674644455 + } + } + }, + { + "l1_block_number": 20975159, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12501243261 + }, + "parent_header": { + "excess_mana": 1318079578, + "mana_used": 92818286, + "proving_cost_per_mana_numerator": 97491349, + "fee_asset_price_numerator": 11679832926 + }, + "header": { + "excess_mana": 1310897864, + "mana_used": 109584810, + "proving_cost_per_mana_numerator": 263701092, + "fee_asset_price_numerator": 11377695280 + }, + "oracle_input": { + "proving_cost_modifier": 166209743, + "fee_asset_price_modifier": -302137646 + }, + "outputs": { + "fee_asset_price_at_execution": 11238927505, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41410368, + "proving_cost": 5420640034, + "congestion_cost": 19857447142, + "congestion_multiplier": 4635529825 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 465408123, + "proving_cost": 60922180372, + "congestion_cost": 223176408863, + "congestion_multiplier": 4635529825 + } + } + }, + { + "l1_block_number": 20975162, + "l1_fees": { + "blob_fee": 1, + "base_fee": 12443066368 + }, + "parent_header": { + "excess_mana": 1310897864, + "mana_used": 109584810, + "proving_cost_per_mana_numerator": 263701092, + "fee_asset_price_numerator": 11377695280 + }, + "header": { + "excess_mana": 1320482674, + "mana_used": 99018256, + "proving_cost_per_mana_numerator": 466096273, + "fee_asset_price_numerator": 11454742859 + }, + "oracle_input": { + "proving_cost_modifier": 202395181, + "fee_asset_price_modifier": 77047579 + }, + "outputs": { + "fee_asset_price_at_execution": 11205021721, + "mana_base_fee_components_in_wei": { + "data_cost": 0, + "gas_cost": 41217657, + "proving_cost": 5429657158, + "congestion_cost": 20175526521, + "congestion_multiplier": 4687806284 + }, + "mana_base_fee_components_in_fee_asset": { + "data_cost": 0, + "gas_cost": 461844741, + "proving_cost": 60839426392, + "congestion_cost": 226067212900, + "congestion_multiplier": 4687806284 + } + } + } +] \ No newline at end of file diff --git a/l1-contracts/test/fixtures/mixed_block_1.json b/l1-contracts/test/fixtures/mixed_block_1.json index 6306d467706d..e3a5c4cceb9e 100644 --- a/l1-contracts/test/fixtures/mixed_block_1.json +++ b/l1-contracts/test/fixtures/mixed_block_1.json @@ -58,25 +58,25 @@ ] }, "block": { - "archive": "0x0f5694321be22526e5a7e857ed9fc4afc006c5bc9052bea6449ec3adee9a2ba9", - "blockHash": "0x2627d91f0126444fb419a457900030879b28203c085aa6eb86415e2c57e84d06", - "body": "0x00000004000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000004100100000000000000000000000000000000000000000000000000000000000410020000000000000000000000000000000000000000000000000000000000041003000000000000000000000000000000000000000000000000000000000004100400000000000000000000000000000000000000000000000000000000000410050000000000000000000000000000000000000000000000000000000000041006000000000000000000000000000000000000000000000000000000000004100700000000000000000000000000000000000000000000000000000000000410080000000000000000000000000000000000000000000000000000000000041009000000000000000000000000000000000000000000000000000000000004100a000000000000000000000000000000000000000000000000000000000004100b000000000000000000000000000000000000000000000000000000000004100c000000000000000000000000000000000000000000000000000000000004100d000000000000000000000000000000000000000000000000000000000004100e000000000000000000000000000000000000000000000000000000000004100f0000000000000000000000000000000000000000000000000000000000041010000000000000000000000000000000000000000000000000000000000004101100000000000000000000000000000000000000000000000000000000000410120000000000000000000000000000000000000000000000000000000000041013000000000000000000000000000000000000000000000000000000000004101400000000000000000000000000000000000000000000000000000000000410150000000000000000000000000000000000000000000000000000000000041016000000000000000000000000000000000000000000000000000000000004101700000000000000000000000000000000000000000000000000000000000410180000000000000000000000000000000000000000000000000000000000041019000000000000000000000000000000000000000000000000000000000004101a000000000000000000000000000000000000000000000000000000000004101b000000000000000000000000000000000000000000000000000000000004101c000000000000000000000000000000000000000000000000000000000004101d000000000000000000000000000000000000000000000000000000000004101e000000000000000000000000000000000000000000000000000000000004101f0000000000000000000000000000000000000000000000000000000000041020000000000000000000000000000000000000000000000000000000000004102100000000000000000000000000000000000000000000000000000000000410220000000000000000000000000000000000000000000000000000000000041023000000000000000000000000000000000000000000000000000000000004102400000000000000000000000000000000000000000000000000000000000410250000000000000000000000000000000000000000000000000000000000041026000000000000000000000000000000000000000000000000000000000004102700000000000000000000000000000000000000000000000000000000000410280000000000000000000000000000000000000000000000000000000000041029000000000000000000000000000000000000000000000000000000000004102a000000000000000000000000000000000000000000000000000000000004102b000000000000000000000000000000000000000000000000000000000004102c000000000000000000000000000000000000000000000000000000000004102d000000000000000000000000000000000000000000000000000000000004102e000000000000000000000000000000000000000000000000000000000004102f0000000000000000000000000000000000000000000000000000000000041030000000000000000000000000000000000000000000000000000000000004103100000000000000000000000000000000000000000000000000000000000410320000000000000000000000000000000000000000000000000000000000041033000000000000000000000000000000000000000000000000000000000004103400000000000000000000000000000000000000000000000000000000000410350000000000000000000000000000000000000000000000000000000000041036000000000000000000000000000000000000000000000000000000000004103700000000000000000000000000000000000000000000000000000000000410380000000000000000000000000000000000000000000000000000000000041039000000000000000000000000000000000000000000000000000000000004103a000000000000000000000000000000000000000000000000000000000004103b000000000000000000000000000000000000000000000000000000000004103c000000000000000000000000000000000000000000000000000000000004103d000000000000000000000000000000000000000000000000000000000004103e000000000000000000000000000000000000000000000000000000000004103f3f0000000000000000000000000000000000000000000000000000000000041100000000000000000000000000000000000000000000000000000000000004110100000000000000000000000000000000000000000000000000000000000411020000000000000000000000000000000000000000000000000000000000041103000000000000000000000000000000000000000000000000000000000004110400000000000000000000000000000000000000000000000000000000000411050000000000000000000000000000000000000000000000000000000000041106000000000000000000000000000000000000000000000000000000000004110700000000000000000000000000000000000000000000000000000000000411080000000000000000000000000000000000000000000000000000000000041109000000000000000000000000000000000000000000000000000000000004110a000000000000000000000000000000000000000000000000000000000004110b000000000000000000000000000000000000000000000000000000000004110c000000000000000000000000000000000000000000000000000000000004110d000000000000000000000000000000000000000000000000000000000004110e000000000000000000000000000000000000000000000000000000000004110f0000000000000000000000000000000000000000000000000000000000041110000000000000000000000000000000000000000000000000000000000004111100000000000000000000000000000000000000000000000000000000000411120000000000000000000000000000000000000000000000000000000000041113000000000000000000000000000000000000000000000000000000000004111400000000000000000000000000000000000000000000000000000000000411150000000000000000000000000000000000000000000000000000000000041116000000000000000000000000000000000000000000000000000000000004111700000000000000000000000000000000000000000000000000000000000411180000000000000000000000000000000000000000000000000000000000041119000000000000000000000000000000000000000000000000000000000004111a000000000000000000000000000000000000000000000000000000000004111b000000000000000000000000000000000000000000000000000000000004111c000000000000000000000000000000000000000000000000000000000004111d000000000000000000000000000000000000000000000000000000000004111e000000000000000000000000000000000000000000000000000000000004111f0000000000000000000000000000000000000000000000000000000000041120000000000000000000000000000000000000000000000000000000000004112100000000000000000000000000000000000000000000000000000000000411220000000000000000000000000000000000000000000000000000000000041123000000000000000000000000000000000000000000000000000000000004112400000000000000000000000000000000000000000000000000000000000411250000000000000000000000000000000000000000000000000000000000041126000000000000000000000000000000000000000000000000000000000004112700000000000000000000000000000000000000000000000000000000000411280000000000000000000000000000000000000000000000000000000000041129000000000000000000000000000000000000000000000000000000000004112a000000000000000000000000000000000000000000000000000000000004112b000000000000000000000000000000000000000000000000000000000004112c000000000000000000000000000000000000000000000000000000000004112d000000000000000000000000000000000000000000000000000000000004112e000000000000000000000000000000000000000000000000000000000004112f0000000000000000000000000000000000000000000000000000000000041130000000000000000000000000000000000000000000000000000000000004113100000000000000000000000000000000000000000000000000000000000411320000000000000000000000000000000000000000000000000000000000041133000000000000000000000000000000000000000000000000000000000004113400000000000000000000000000000000000000000000000000000000000411350000000000000000000000000000000000000000000000000000000000041136000000000000000000000000000000000000000000000000000000000004113700000000000000000000000000000000000000000000000000000000000411380000000000000000000000000000000000000000000000000000000000041139000000000000000000000000000000000000000000000000000000000004113a000000000000000000000000000000000000000000000000000000000004113b000000000000000000000000000000000000000000000000000000000004113c000000000000000000000000000000000000000000000000000000000004113d000000000000000000000000000000000000000000000000000000000004113e080097a6ec570e9b8e257647c9c74c5ad3edc57ca5ef6ae44d80b3c30d1d99b9b300ce48ec41d1edde0066fab553a456ae2f380d14fa8f956af1fb0217513a598900619ff12eaf97f63aa2a2311de3b6571a7b880a5247cb33b6a74787bf3f9bd5007854a2fad4e1801c6404394bf3d37ab08c135ea38a1974242e39a21273685f000f55796e72957a819e68a22e8602d73c3ba3718a5a4bd92b80b0aa444b182a00788b6e9874fb040ee679a7fae257190099a605229b948334e54a57739535d4004f1658ee3c1a91627e5d72f5a731f0796299df82ab41e72c88eee0c82fa85e003ee802add96628c693ed71afa9908138ba5a6fbf0a5f29a9c74e4e42aba6713f0000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042001000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042002000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042003000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042004000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042005000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420060000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004200700000000000000000000000000000000000000000000000000000000000420110000000000000000000000000000000000000000000000000000000000042008000000000000000000000000000000000000000000000000000000000004201200000000000000000000000000000000000000000000000000000000000420090000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042016000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042017000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042011000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042012000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420160000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004201700000000000000000000000000000000000000000000000000000000000420210000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004202200000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042026000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042027000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042021000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042022000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420260000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004202700000000000000000000000000000000000000000000000000000000000420310000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004203200000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042036000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042037000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042031000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042032000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004203f00000000000000000000000000000000000000000000000000000000000420360000000000000000000000000000000000000000000000000000000000042040000000000000000000000000000000000000000000000000000000000004203700000000000000000000000000000000000000000000000000000000000420410000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004204200000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042043000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042044000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042045000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042046000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042047000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000081000000000000000000000000000000000000000000000000000000000000008100100000000000000000000000000000000000000000000000000000000000810020000000000000000000000000000000000000000000000000000000000081003000000000000000000000000000000000000000000000000000000000008100400000000000000000000000000000000000000000000000000000000000810050000000000000000000000000000000000000000000000000000000000081006000000000000000000000000000000000000000000000000000000000008100700000000000000000000000000000000000000000000000000000000000810080000000000000000000000000000000000000000000000000000000000081009000000000000000000000000000000000000000000000000000000000008100a000000000000000000000000000000000000000000000000000000000008100b000000000000000000000000000000000000000000000000000000000008100c000000000000000000000000000000000000000000000000000000000008100d000000000000000000000000000000000000000000000000000000000008100e000000000000000000000000000000000000000000000000000000000008100f0000000000000000000000000000000000000000000000000000000000081010000000000000000000000000000000000000000000000000000000000008101100000000000000000000000000000000000000000000000000000000000810120000000000000000000000000000000000000000000000000000000000081013000000000000000000000000000000000000000000000000000000000008101400000000000000000000000000000000000000000000000000000000000810150000000000000000000000000000000000000000000000000000000000081016000000000000000000000000000000000000000000000000000000000008101700000000000000000000000000000000000000000000000000000000000810180000000000000000000000000000000000000000000000000000000000081019000000000000000000000000000000000000000000000000000000000008101a000000000000000000000000000000000000000000000000000000000008101b000000000000000000000000000000000000000000000000000000000008101c000000000000000000000000000000000000000000000000000000000008101d000000000000000000000000000000000000000000000000000000000008101e000000000000000000000000000000000000000000000000000000000008101f0000000000000000000000000000000000000000000000000000000000081020000000000000000000000000000000000000000000000000000000000008102100000000000000000000000000000000000000000000000000000000000810220000000000000000000000000000000000000000000000000000000000081023000000000000000000000000000000000000000000000000000000000008102400000000000000000000000000000000000000000000000000000000000810250000000000000000000000000000000000000000000000000000000000081026000000000000000000000000000000000000000000000000000000000008102700000000000000000000000000000000000000000000000000000000000810280000000000000000000000000000000000000000000000000000000000081029000000000000000000000000000000000000000000000000000000000008102a000000000000000000000000000000000000000000000000000000000008102b000000000000000000000000000000000000000000000000000000000008102c000000000000000000000000000000000000000000000000000000000008102d000000000000000000000000000000000000000000000000000000000008102e000000000000000000000000000000000000000000000000000000000008102f0000000000000000000000000000000000000000000000000000000000081030000000000000000000000000000000000000000000000000000000000008103100000000000000000000000000000000000000000000000000000000000810320000000000000000000000000000000000000000000000000000000000081033000000000000000000000000000000000000000000000000000000000008103400000000000000000000000000000000000000000000000000000000000810350000000000000000000000000000000000000000000000000000000000081036000000000000000000000000000000000000000000000000000000000008103700000000000000000000000000000000000000000000000000000000000810380000000000000000000000000000000000000000000000000000000000081039000000000000000000000000000000000000000000000000000000000008103a000000000000000000000000000000000000000000000000000000000008103b000000000000000000000000000000000000000000000000000000000008103c000000000000000000000000000000000000000000000000000000000008103d000000000000000000000000000000000000000000000000000000000008103e000000000000000000000000000000000000000000000000000000000008103f3f0000000000000000000000000000000000000000000000000000000000081100000000000000000000000000000000000000000000000000000000000008110100000000000000000000000000000000000000000000000000000000000811020000000000000000000000000000000000000000000000000000000000081103000000000000000000000000000000000000000000000000000000000008110400000000000000000000000000000000000000000000000000000000000811050000000000000000000000000000000000000000000000000000000000081106000000000000000000000000000000000000000000000000000000000008110700000000000000000000000000000000000000000000000000000000000811080000000000000000000000000000000000000000000000000000000000081109000000000000000000000000000000000000000000000000000000000008110a000000000000000000000000000000000000000000000000000000000008110b000000000000000000000000000000000000000000000000000000000008110c000000000000000000000000000000000000000000000000000000000008110d000000000000000000000000000000000000000000000000000000000008110e000000000000000000000000000000000000000000000000000000000008110f0000000000000000000000000000000000000000000000000000000000081110000000000000000000000000000000000000000000000000000000000008111100000000000000000000000000000000000000000000000000000000000811120000000000000000000000000000000000000000000000000000000000081113000000000000000000000000000000000000000000000000000000000008111400000000000000000000000000000000000000000000000000000000000811150000000000000000000000000000000000000000000000000000000000081116000000000000000000000000000000000000000000000000000000000008111700000000000000000000000000000000000000000000000000000000000811180000000000000000000000000000000000000000000000000000000000081119000000000000000000000000000000000000000000000000000000000008111a000000000000000000000000000000000000000000000000000000000008111b000000000000000000000000000000000000000000000000000000000008111c000000000000000000000000000000000000000000000000000000000008111d000000000000000000000000000000000000000000000000000000000008111e000000000000000000000000000000000000000000000000000000000008111f0000000000000000000000000000000000000000000000000000000000081120000000000000000000000000000000000000000000000000000000000008112100000000000000000000000000000000000000000000000000000000000811220000000000000000000000000000000000000000000000000000000000081123000000000000000000000000000000000000000000000000000000000008112400000000000000000000000000000000000000000000000000000000000811250000000000000000000000000000000000000000000000000000000000081126000000000000000000000000000000000000000000000000000000000008112700000000000000000000000000000000000000000000000000000000000811280000000000000000000000000000000000000000000000000000000000081129000000000000000000000000000000000000000000000000000000000008112a000000000000000000000000000000000000000000000000000000000008112b000000000000000000000000000000000000000000000000000000000008112c000000000000000000000000000000000000000000000000000000000008112d000000000000000000000000000000000000000000000000000000000008112e000000000000000000000000000000000000000000000000000000000008112f0000000000000000000000000000000000000000000000000000000000081130000000000000000000000000000000000000000000000000000000000008113100000000000000000000000000000000000000000000000000000000000811320000000000000000000000000000000000000000000000000000000000081133000000000000000000000000000000000000000000000000000000000008113400000000000000000000000000000000000000000000000000000000000811350000000000000000000000000000000000000000000000000000000000081136000000000000000000000000000000000000000000000000000000000008113700000000000000000000000000000000000000000000000000000000000811380000000000000000000000000000000000000000000000000000000000081139000000000000000000000000000000000000000000000000000000000008113a000000000000000000000000000000000000000000000000000000000008113b000000000000000000000000000000000000000000000000000000000008113c000000000000000000000000000000000000000000000000000000000008113d000000000000000000000000000000000000000000000000000000000008113e08003c0472260790b0bdfb8ae4dc4d437e7686b73643f2198970d84e1059a5f13500bfd46275a318e438726ff2765ae154b63ab8a0daebcbed668a5f58a0e63dc1007906b9418dc758c6b4f8454c69baa48b7889b6b511d707abe8e2cb8f7c397300aeb60c4d65a44f122e58bf9565dfe2024b3ae654d5cf2e47ecb035d53c927000bf82e8cda20345f37bbb1de3932172324b57f0b98be483392697b168e3bba8000fb4bbad884ef30edf68e45a6cf2733fcf50310c69d7c1432b29af2c0aa8040023e1622d27fee3b4a40ab975ae0eb2e31619ef3dc76eb858f7fddb6a056131004689cd7007daf98dd3218b839b8e6a29f957154347b391fdb376bd0b344be23f0000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082001000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082002000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082003000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082004000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082005000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820060000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008200700000000000000000000000000000000000000000000000000000000000820110000000000000000000000000000000000000000000000000000000000082008000000000000000000000000000000000000000000000000000000000008201200000000000000000000000000000000000000000000000000000000000820090000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082016000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082017000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082011000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082012000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820160000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008201700000000000000000000000000000000000000000000000000000000000820210000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008202200000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082026000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082027000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082021000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082022000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820260000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008202700000000000000000000000000000000000000000000000000000000000820310000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008203200000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082036000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082037000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082031000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082032000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008203e0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008203f00000000000000000000000000000000000000000000000000000000000820360000000000000000000000000000000000000000000000000000000000082040000000000000000000000000000000000000000000000000000000000008203700000000000000000000000000000000000000000000000000000000000820410000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008204200000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082043000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082044000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082045000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082046000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082047000000000000000000000000000000000000000000000000000000000008203e00000000000000000000000000000000000000000000000000000000000820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c100100000000000000000000000000000000000000000000000000000000000c100200000000000000000000000000000000000000000000000000000000000c100300000000000000000000000000000000000000000000000000000000000c100400000000000000000000000000000000000000000000000000000000000c100500000000000000000000000000000000000000000000000000000000000c100600000000000000000000000000000000000000000000000000000000000c100700000000000000000000000000000000000000000000000000000000000c100800000000000000000000000000000000000000000000000000000000000c100900000000000000000000000000000000000000000000000000000000000c100a00000000000000000000000000000000000000000000000000000000000c100b00000000000000000000000000000000000000000000000000000000000c100c00000000000000000000000000000000000000000000000000000000000c100d00000000000000000000000000000000000000000000000000000000000c100e00000000000000000000000000000000000000000000000000000000000c100f00000000000000000000000000000000000000000000000000000000000c101000000000000000000000000000000000000000000000000000000000000c101100000000000000000000000000000000000000000000000000000000000c101200000000000000000000000000000000000000000000000000000000000c101300000000000000000000000000000000000000000000000000000000000c101400000000000000000000000000000000000000000000000000000000000c101500000000000000000000000000000000000000000000000000000000000c101600000000000000000000000000000000000000000000000000000000000c101700000000000000000000000000000000000000000000000000000000000c101800000000000000000000000000000000000000000000000000000000000c101900000000000000000000000000000000000000000000000000000000000c101a00000000000000000000000000000000000000000000000000000000000c101b00000000000000000000000000000000000000000000000000000000000c101c00000000000000000000000000000000000000000000000000000000000c101d00000000000000000000000000000000000000000000000000000000000c101e00000000000000000000000000000000000000000000000000000000000c101f00000000000000000000000000000000000000000000000000000000000c102000000000000000000000000000000000000000000000000000000000000c102100000000000000000000000000000000000000000000000000000000000c102200000000000000000000000000000000000000000000000000000000000c102300000000000000000000000000000000000000000000000000000000000c102400000000000000000000000000000000000000000000000000000000000c102500000000000000000000000000000000000000000000000000000000000c102600000000000000000000000000000000000000000000000000000000000c102700000000000000000000000000000000000000000000000000000000000c102800000000000000000000000000000000000000000000000000000000000c102900000000000000000000000000000000000000000000000000000000000c102a00000000000000000000000000000000000000000000000000000000000c102b00000000000000000000000000000000000000000000000000000000000c102c00000000000000000000000000000000000000000000000000000000000c102d00000000000000000000000000000000000000000000000000000000000c102e00000000000000000000000000000000000000000000000000000000000c102f00000000000000000000000000000000000000000000000000000000000c103000000000000000000000000000000000000000000000000000000000000c103100000000000000000000000000000000000000000000000000000000000c103200000000000000000000000000000000000000000000000000000000000c103300000000000000000000000000000000000000000000000000000000000c103400000000000000000000000000000000000000000000000000000000000c103500000000000000000000000000000000000000000000000000000000000c103600000000000000000000000000000000000000000000000000000000000c103700000000000000000000000000000000000000000000000000000000000c103800000000000000000000000000000000000000000000000000000000000c103900000000000000000000000000000000000000000000000000000000000c103a00000000000000000000000000000000000000000000000000000000000c103b00000000000000000000000000000000000000000000000000000000000c103c00000000000000000000000000000000000000000000000000000000000c103d00000000000000000000000000000000000000000000000000000000000c103e00000000000000000000000000000000000000000000000000000000000c103f3f00000000000000000000000000000000000000000000000000000000000c110000000000000000000000000000000000000000000000000000000000000c110100000000000000000000000000000000000000000000000000000000000c110200000000000000000000000000000000000000000000000000000000000c110300000000000000000000000000000000000000000000000000000000000c110400000000000000000000000000000000000000000000000000000000000c110500000000000000000000000000000000000000000000000000000000000c110600000000000000000000000000000000000000000000000000000000000c110700000000000000000000000000000000000000000000000000000000000c110800000000000000000000000000000000000000000000000000000000000c110900000000000000000000000000000000000000000000000000000000000c110a00000000000000000000000000000000000000000000000000000000000c110b00000000000000000000000000000000000000000000000000000000000c110c00000000000000000000000000000000000000000000000000000000000c110d00000000000000000000000000000000000000000000000000000000000c110e00000000000000000000000000000000000000000000000000000000000c110f00000000000000000000000000000000000000000000000000000000000c111000000000000000000000000000000000000000000000000000000000000c111100000000000000000000000000000000000000000000000000000000000c111200000000000000000000000000000000000000000000000000000000000c111300000000000000000000000000000000000000000000000000000000000c111400000000000000000000000000000000000000000000000000000000000c111500000000000000000000000000000000000000000000000000000000000c111600000000000000000000000000000000000000000000000000000000000c111700000000000000000000000000000000000000000000000000000000000c111800000000000000000000000000000000000000000000000000000000000c111900000000000000000000000000000000000000000000000000000000000c111a00000000000000000000000000000000000000000000000000000000000c111b00000000000000000000000000000000000000000000000000000000000c111c00000000000000000000000000000000000000000000000000000000000c111d00000000000000000000000000000000000000000000000000000000000c111e00000000000000000000000000000000000000000000000000000000000c111f00000000000000000000000000000000000000000000000000000000000c112000000000000000000000000000000000000000000000000000000000000c112100000000000000000000000000000000000000000000000000000000000c112200000000000000000000000000000000000000000000000000000000000c112300000000000000000000000000000000000000000000000000000000000c112400000000000000000000000000000000000000000000000000000000000c112500000000000000000000000000000000000000000000000000000000000c112600000000000000000000000000000000000000000000000000000000000c112700000000000000000000000000000000000000000000000000000000000c112800000000000000000000000000000000000000000000000000000000000c112900000000000000000000000000000000000000000000000000000000000c112a00000000000000000000000000000000000000000000000000000000000c112b00000000000000000000000000000000000000000000000000000000000c112c00000000000000000000000000000000000000000000000000000000000c112d00000000000000000000000000000000000000000000000000000000000c112e00000000000000000000000000000000000000000000000000000000000c112f00000000000000000000000000000000000000000000000000000000000c113000000000000000000000000000000000000000000000000000000000000c113100000000000000000000000000000000000000000000000000000000000c113200000000000000000000000000000000000000000000000000000000000c113300000000000000000000000000000000000000000000000000000000000c113400000000000000000000000000000000000000000000000000000000000c113500000000000000000000000000000000000000000000000000000000000c113600000000000000000000000000000000000000000000000000000000000c113700000000000000000000000000000000000000000000000000000000000c113800000000000000000000000000000000000000000000000000000000000c113900000000000000000000000000000000000000000000000000000000000c113a00000000000000000000000000000000000000000000000000000000000c113b00000000000000000000000000000000000000000000000000000000000c113c00000000000000000000000000000000000000000000000000000000000c113d00000000000000000000000000000000000000000000000000000000000c113e0800f8029be42ec3f25204907ca981fb71e5b357093eb5db10fc01ca98a4e4154c0030e13d351a5bf1d5a040e82a163ca57017f39162693f85c571e441e36d702d00a550ae0f39f977d9473d6de1be3232fc68ed0c4a601d53542148695102cfc9005580bc65e4bff9c8fffa64db02c0fa6af14d9d26fd962f4c5904cbd3ddec2500758c4a0d43dfec788b2f580877c4f473adec8f168ea24424f2600e4eb4916f00342602bf90d10f8ca8e582a894dcc4c02bb89fe458532e0c632b53bae54b4d00ca43ab78ab834337e9964d84a0674c9adabdca140539c5a6bc96e0ba9a51f6004ffbfd91be292a7c6a0e255e50caa156ac2d628b40ad2128c4ab63a92d8a1c3f00000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c200100000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c200200000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c200300000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c200400000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c200500000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c200600000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c200700000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c200800000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c200900000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c203f00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c204000000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c204100000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c204200000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c204300000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c204400000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c204500000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c204600000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c204700000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000010100100000000000000000000000000000000000000000000000000000000001010020000000000000000000000000000000000000000000000000000000000101003000000000000000000000000000000000000000000000000000000000010100400000000000000000000000000000000000000000000000000000000001010050000000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000010100700000000000000000000000000000000000000000000000000000000001010080000000000000000000000000000000000000000000000000000000000101009000000000000000000000000000000000000000000000000000000000010100a000000000000000000000000000000000000000000000000000000000010100b000000000000000000000000000000000000000000000000000000000010100c000000000000000000000000000000000000000000000000000000000010100d000000000000000000000000000000000000000000000000000000000010100e000000000000000000000000000000000000000000000000000000000010100f0000000000000000000000000000000000000000000000000000000000101010000000000000000000000000000000000000000000000000000000000010101100000000000000000000000000000000000000000000000000000000001010120000000000000000000000000000000000000000000000000000000000101013000000000000000000000000000000000000000000000000000000000010101400000000000000000000000000000000000000000000000000000000001010150000000000000000000000000000000000000000000000000000000000101016000000000000000000000000000000000000000000000000000000000010101700000000000000000000000000000000000000000000000000000000001010180000000000000000000000000000000000000000000000000000000000101019000000000000000000000000000000000000000000000000000000000010101a000000000000000000000000000000000000000000000000000000000010101b000000000000000000000000000000000000000000000000000000000010101c000000000000000000000000000000000000000000000000000000000010101d000000000000000000000000000000000000000000000000000000000010101e000000000000000000000000000000000000000000000000000000000010101f0000000000000000000000000000000000000000000000000000000000101020000000000000000000000000000000000000000000000000000000000010102100000000000000000000000000000000000000000000000000000000001010220000000000000000000000000000000000000000000000000000000000101023000000000000000000000000000000000000000000000000000000000010102400000000000000000000000000000000000000000000000000000000001010250000000000000000000000000000000000000000000000000000000000101026000000000000000000000000000000000000000000000000000000000010102700000000000000000000000000000000000000000000000000000000001010280000000000000000000000000000000000000000000000000000000000101029000000000000000000000000000000000000000000000000000000000010102a000000000000000000000000000000000000000000000000000000000010102b000000000000000000000000000000000000000000000000000000000010102c000000000000000000000000000000000000000000000000000000000010102d000000000000000000000000000000000000000000000000000000000010102e000000000000000000000000000000000000000000000000000000000010102f0000000000000000000000000000000000000000000000000000000000101030000000000000000000000000000000000000000000000000000000000010103100000000000000000000000000000000000000000000000000000000001010320000000000000000000000000000000000000000000000000000000000101033000000000000000000000000000000000000000000000000000000000010103400000000000000000000000000000000000000000000000000000000001010350000000000000000000000000000000000000000000000000000000000101036000000000000000000000000000000000000000000000000000000000010103700000000000000000000000000000000000000000000000000000000001010380000000000000000000000000000000000000000000000000000000000101039000000000000000000000000000000000000000000000000000000000010103a000000000000000000000000000000000000000000000000000000000010103b000000000000000000000000000000000000000000000000000000000010103c000000000000000000000000000000000000000000000000000000000010103d000000000000000000000000000000000000000000000000000000000010103e000000000000000000000000000000000000000000000000000000000010103f3f0000000000000000000000000000000000000000000000000000000000101100000000000000000000000000000000000000000000000000000000000010110100000000000000000000000000000000000000000000000000000000001011020000000000000000000000000000000000000000000000000000000000101103000000000000000000000000000000000000000000000000000000000010110400000000000000000000000000000000000000000000000000000000001011050000000000000000000000000000000000000000000000000000000000101106000000000000000000000000000000000000000000000000000000000010110700000000000000000000000000000000000000000000000000000000001011080000000000000000000000000000000000000000000000000000000000101109000000000000000000000000000000000000000000000000000000000010110a000000000000000000000000000000000000000000000000000000000010110b000000000000000000000000000000000000000000000000000000000010110c000000000000000000000000000000000000000000000000000000000010110d000000000000000000000000000000000000000000000000000000000010110e000000000000000000000000000000000000000000000000000000000010110f0000000000000000000000000000000000000000000000000000000000101110000000000000000000000000000000000000000000000000000000000010111100000000000000000000000000000000000000000000000000000000001011120000000000000000000000000000000000000000000000000000000000101113000000000000000000000000000000000000000000000000000000000010111400000000000000000000000000000000000000000000000000000000001011150000000000000000000000000000000000000000000000000000000000101116000000000000000000000000000000000000000000000000000000000010111700000000000000000000000000000000000000000000000000000000001011180000000000000000000000000000000000000000000000000000000000101119000000000000000000000000000000000000000000000000000000000010111a000000000000000000000000000000000000000000000000000000000010111b000000000000000000000000000000000000000000000000000000000010111c000000000000000000000000000000000000000000000000000000000010111d000000000000000000000000000000000000000000000000000000000010111e000000000000000000000000000000000000000000000000000000000010111f0000000000000000000000000000000000000000000000000000000000101120000000000000000000000000000000000000000000000000000000000010112100000000000000000000000000000000000000000000000000000000001011220000000000000000000000000000000000000000000000000000000000101123000000000000000000000000000000000000000000000000000000000010112400000000000000000000000000000000000000000000000000000000001011250000000000000000000000000000000000000000000000000000000000101126000000000000000000000000000000000000000000000000000000000010112700000000000000000000000000000000000000000000000000000000001011280000000000000000000000000000000000000000000000000000000000101129000000000000000000000000000000000000000000000000000000000010112a000000000000000000000000000000000000000000000000000000000010112b000000000000000000000000000000000000000000000000000000000010112c000000000000000000000000000000000000000000000000000000000010112d000000000000000000000000000000000000000000000000000000000010112e000000000000000000000000000000000000000000000000000000000010112f0000000000000000000000000000000000000000000000000000000000101130000000000000000000000000000000000000000000000000000000000010113100000000000000000000000000000000000000000000000000000000001011320000000000000000000000000000000000000000000000000000000000101133000000000000000000000000000000000000000000000000000000000010113400000000000000000000000000000000000000000000000000000000001011350000000000000000000000000000000000000000000000000000000000101136000000000000000000000000000000000000000000000000000000000010113700000000000000000000000000000000000000000000000000000000001011380000000000000000000000000000000000000000000000000000000000101139000000000000000000000000000000000000000000000000000000000010113a000000000000000000000000000000000000000000000000000000000010113b000000000000000000000000000000000000000000000000000000000010113c000000000000000000000000000000000000000000000000000000000010113d000000000000000000000000000000000000000000000000000000000010113e080099145b6c0d32753835121f8b271186d01236948a4622ce78a98347fcfc98390085277a27c6acbd5ffc4c19cd65fc30056999e9bec36998f753132db0ff8e2300f3cf77a7261759ebd5f4149f6ad56746f4499cfcd4adf27a1d373f77da64d5009bc6e0e994a23cde8c95b90c1acc1b4a480c6599d1df2c3f9f6e76f3d1aff200d7a1c4a2700dacaaf07f1f0ff33837bdbabcf0b9ace17efabe0761708c4bb900dbeb8e96d14f21e57d5786b6d6ae7e5ddb1bb35935c0fb246d4bdbca62e02c00fbf12b5e0df6223b801088798e4e04d2a92ffe9a11639b7f0ce314e3412a8000d796e0724de03b796ba77069fcd6cf921e566f3aed15eb3e77258add74e9ff3f0000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102001000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102002000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102003000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102004000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102005000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020060000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010200700000000000000000000000000000000000000000000000000000000001020110000000000000000000000000000000000000000000000000000000000102008000000000000000000000000000000000000000000000000000000000010201200000000000000000000000000000000000000000000000000000000001020090000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102016000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102017000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102011000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102012000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020160000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010201700000000000000000000000000000000000000000000000000000000001020210000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010202200000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102026000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102027000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102021000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102022000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020260000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010202700000000000000000000000000000000000000000000000000000000001020310000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010203200000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102036000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102037000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102031000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102032000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010203f00000000000000000000000000000000000000000000000000000000001020360000000000000000000000000000000000000000000000000000000000102040000000000000000000000000000000000000000000000000000000000010203700000000000000000000000000000000000000000000000000000000001020410000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010204200000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102043000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102044000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102045000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102046000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102047000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "txsEffectsHash": "0x007b27babdf78c8beb8d7a937731158a4422309edacfeb6e2b9c9125a01617a2", + "archive": "0x13232b1c92fcfba5f94aee813d7e454764f93d6292215552b8c973ef42c8e396", + "blockHash": "0x024c7ee2217388b1e45747c7233b2f3993bfc88a8a944ee89a11d9c66c24907d", + "body": "0x00000004000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000004100100000000000000000000000000000000000000000000000000000000000410020000000000000000000000000000000000000000000000000000000000041003000000000000000000000000000000000000000000000000000000000004100400000000000000000000000000000000000000000000000000000000000410050000000000000000000000000000000000000000000000000000000000041006000000000000000000000000000000000000000000000000000000000004100700000000000000000000000000000000000000000000000000000000000410080000000000000000000000000000000000000000000000000000000000041009000000000000000000000000000000000000000000000000000000000004100a000000000000000000000000000000000000000000000000000000000004100b000000000000000000000000000000000000000000000000000000000004100c000000000000000000000000000000000000000000000000000000000004100d000000000000000000000000000000000000000000000000000000000004100e000000000000000000000000000000000000000000000000000000000004100f0000000000000000000000000000000000000000000000000000000000041010000000000000000000000000000000000000000000000000000000000004101100000000000000000000000000000000000000000000000000000000000410120000000000000000000000000000000000000000000000000000000000041013000000000000000000000000000000000000000000000000000000000004101400000000000000000000000000000000000000000000000000000000000410150000000000000000000000000000000000000000000000000000000000041016000000000000000000000000000000000000000000000000000000000004101700000000000000000000000000000000000000000000000000000000000410180000000000000000000000000000000000000000000000000000000000041019000000000000000000000000000000000000000000000000000000000004101a000000000000000000000000000000000000000000000000000000000004101b000000000000000000000000000000000000000000000000000000000004101c000000000000000000000000000000000000000000000000000000000004101d000000000000000000000000000000000000000000000000000000000004101e000000000000000000000000000000000000000000000000000000000004101f0000000000000000000000000000000000000000000000000000000000041020000000000000000000000000000000000000000000000000000000000004102100000000000000000000000000000000000000000000000000000000000410220000000000000000000000000000000000000000000000000000000000041023000000000000000000000000000000000000000000000000000000000004102400000000000000000000000000000000000000000000000000000000000410250000000000000000000000000000000000000000000000000000000000041026000000000000000000000000000000000000000000000000000000000004102700000000000000000000000000000000000000000000000000000000000410280000000000000000000000000000000000000000000000000000000000041029000000000000000000000000000000000000000000000000000000000004102a000000000000000000000000000000000000000000000000000000000004102b000000000000000000000000000000000000000000000000000000000004102c000000000000000000000000000000000000000000000000000000000004102d000000000000000000000000000000000000000000000000000000000004102e000000000000000000000000000000000000000000000000000000000004102f0000000000000000000000000000000000000000000000000000000000041030000000000000000000000000000000000000000000000000000000000004103100000000000000000000000000000000000000000000000000000000000410320000000000000000000000000000000000000000000000000000000000041033000000000000000000000000000000000000000000000000000000000004103400000000000000000000000000000000000000000000000000000000000410350000000000000000000000000000000000000000000000000000000000041036000000000000000000000000000000000000000000000000000000000004103700000000000000000000000000000000000000000000000000000000000410380000000000000000000000000000000000000000000000000000000000041039000000000000000000000000000000000000000000000000000000000004103a000000000000000000000000000000000000000000000000000000000004103b000000000000000000000000000000000000000000000000000000000004103c000000000000000000000000000000000000000000000000000000000004103d000000000000000000000000000000000000000000000000000000000004103e000000000000000000000000000000000000000000000000000000000004103f3f0000000000000000000000000000000000000000000000000000000000041100000000000000000000000000000000000000000000000000000000000004110100000000000000000000000000000000000000000000000000000000000411020000000000000000000000000000000000000000000000000000000000041103000000000000000000000000000000000000000000000000000000000004110400000000000000000000000000000000000000000000000000000000000411050000000000000000000000000000000000000000000000000000000000041106000000000000000000000000000000000000000000000000000000000004110700000000000000000000000000000000000000000000000000000000000411080000000000000000000000000000000000000000000000000000000000041109000000000000000000000000000000000000000000000000000000000004110a000000000000000000000000000000000000000000000000000000000004110b000000000000000000000000000000000000000000000000000000000004110c000000000000000000000000000000000000000000000000000000000004110d000000000000000000000000000000000000000000000000000000000004110e000000000000000000000000000000000000000000000000000000000004110f0000000000000000000000000000000000000000000000000000000000041110000000000000000000000000000000000000000000000000000000000004111100000000000000000000000000000000000000000000000000000000000411120000000000000000000000000000000000000000000000000000000000041113000000000000000000000000000000000000000000000000000000000004111400000000000000000000000000000000000000000000000000000000000411150000000000000000000000000000000000000000000000000000000000041116000000000000000000000000000000000000000000000000000000000004111700000000000000000000000000000000000000000000000000000000000411180000000000000000000000000000000000000000000000000000000000041119000000000000000000000000000000000000000000000000000000000004111a000000000000000000000000000000000000000000000000000000000004111b000000000000000000000000000000000000000000000000000000000004111c000000000000000000000000000000000000000000000000000000000004111d000000000000000000000000000000000000000000000000000000000004111e000000000000000000000000000000000000000000000000000000000004111f0000000000000000000000000000000000000000000000000000000000041120000000000000000000000000000000000000000000000000000000000004112100000000000000000000000000000000000000000000000000000000000411220000000000000000000000000000000000000000000000000000000000041123000000000000000000000000000000000000000000000000000000000004112400000000000000000000000000000000000000000000000000000000000411250000000000000000000000000000000000000000000000000000000000041126000000000000000000000000000000000000000000000000000000000004112700000000000000000000000000000000000000000000000000000000000411280000000000000000000000000000000000000000000000000000000000041129000000000000000000000000000000000000000000000000000000000004112a000000000000000000000000000000000000000000000000000000000004112b000000000000000000000000000000000000000000000000000000000004112c000000000000000000000000000000000000000000000000000000000004112d000000000000000000000000000000000000000000000000000000000004112e000000000000000000000000000000000000000000000000000000000004112f0000000000000000000000000000000000000000000000000000000000041130000000000000000000000000000000000000000000000000000000000004113100000000000000000000000000000000000000000000000000000000000411320000000000000000000000000000000000000000000000000000000000041133000000000000000000000000000000000000000000000000000000000004113400000000000000000000000000000000000000000000000000000000000411350000000000000000000000000000000000000000000000000000000000041136000000000000000000000000000000000000000000000000000000000004113700000000000000000000000000000000000000000000000000000000000411380000000000000000000000000000000000000000000000000000000000041139000000000000000000000000000000000000000000000000000000000004113a000000000000000000000000000000000000000000000000000000000004113b000000000000000000000000000000000000000000000000000000000004113c000000000000000000000000000000000000000000000000000000000004113d000000000000000000000000000000000000000000000000000000000004113e080097a6ec570e9b8e257647c9c74c5ad3edc57ca5ef6ae44d80b3c30d1d99b9b300ce48ec41d1edde0066fab553a456ae2f380d14fa8f956af1fb0217513a598900619ff12eaf97f63aa2a2311de3b6571a7b880a5247cb33b6a74787bf3f9bd5007854a2fad4e1801c6404394bf3d37ab08c135ea38a1974242e39a21273685f000f55796e72957a819e68a22e8602d73c3ba3718a5a4bd92b80b0aa444b182a00788b6e9874fb040ee679a7fae257190099a605229b948334e54a57739535d4004f1658ee3c1a91627e5d72f5a731f0796299df82ab41e72c88eee0c82fa85e003ee802add96628c693ed71afa9908138ba5a6fbf0a5f29a9c74e4e42aba6713f0000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042001000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042002000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042003000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042004000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042005000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420060000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004200700000000000000000000000000000000000000000000000000000000000420110000000000000000000000000000000000000000000000000000000000042008000000000000000000000000000000000000000000000000000000000004201200000000000000000000000000000000000000000000000000000000000420090000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042016000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042017000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042011000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042012000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420160000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004201700000000000000000000000000000000000000000000000000000000000420210000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004202200000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042026000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042027000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042021000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042022000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420260000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004202700000000000000000000000000000000000000000000000000000000000420310000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004203200000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042036000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042037000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042031000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042032000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004203f00000000000000000000000000000000000000000000000000000000000420360000000000000000000000000000000000000000000000000000000000042040000000000000000000000000000000000000000000000000000000000004203700000000000000000000000000000000000000000000000000000000000420410000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004204200000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042043000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042044000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042045000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042046000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042047000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000081000000000000000000000000000000000000000000000000000000000000008100100000000000000000000000000000000000000000000000000000000000810020000000000000000000000000000000000000000000000000000000000081003000000000000000000000000000000000000000000000000000000000008100400000000000000000000000000000000000000000000000000000000000810050000000000000000000000000000000000000000000000000000000000081006000000000000000000000000000000000000000000000000000000000008100700000000000000000000000000000000000000000000000000000000000810080000000000000000000000000000000000000000000000000000000000081009000000000000000000000000000000000000000000000000000000000008100a000000000000000000000000000000000000000000000000000000000008100b000000000000000000000000000000000000000000000000000000000008100c000000000000000000000000000000000000000000000000000000000008100d000000000000000000000000000000000000000000000000000000000008100e000000000000000000000000000000000000000000000000000000000008100f0000000000000000000000000000000000000000000000000000000000081010000000000000000000000000000000000000000000000000000000000008101100000000000000000000000000000000000000000000000000000000000810120000000000000000000000000000000000000000000000000000000000081013000000000000000000000000000000000000000000000000000000000008101400000000000000000000000000000000000000000000000000000000000810150000000000000000000000000000000000000000000000000000000000081016000000000000000000000000000000000000000000000000000000000008101700000000000000000000000000000000000000000000000000000000000810180000000000000000000000000000000000000000000000000000000000081019000000000000000000000000000000000000000000000000000000000008101a000000000000000000000000000000000000000000000000000000000008101b000000000000000000000000000000000000000000000000000000000008101c000000000000000000000000000000000000000000000000000000000008101d000000000000000000000000000000000000000000000000000000000008101e000000000000000000000000000000000000000000000000000000000008101f0000000000000000000000000000000000000000000000000000000000081020000000000000000000000000000000000000000000000000000000000008102100000000000000000000000000000000000000000000000000000000000810220000000000000000000000000000000000000000000000000000000000081023000000000000000000000000000000000000000000000000000000000008102400000000000000000000000000000000000000000000000000000000000810250000000000000000000000000000000000000000000000000000000000081026000000000000000000000000000000000000000000000000000000000008102700000000000000000000000000000000000000000000000000000000000810280000000000000000000000000000000000000000000000000000000000081029000000000000000000000000000000000000000000000000000000000008102a000000000000000000000000000000000000000000000000000000000008102b000000000000000000000000000000000000000000000000000000000008102c000000000000000000000000000000000000000000000000000000000008102d000000000000000000000000000000000000000000000000000000000008102e000000000000000000000000000000000000000000000000000000000008102f0000000000000000000000000000000000000000000000000000000000081030000000000000000000000000000000000000000000000000000000000008103100000000000000000000000000000000000000000000000000000000000810320000000000000000000000000000000000000000000000000000000000081033000000000000000000000000000000000000000000000000000000000008103400000000000000000000000000000000000000000000000000000000000810350000000000000000000000000000000000000000000000000000000000081036000000000000000000000000000000000000000000000000000000000008103700000000000000000000000000000000000000000000000000000000000810380000000000000000000000000000000000000000000000000000000000081039000000000000000000000000000000000000000000000000000000000008103a000000000000000000000000000000000000000000000000000000000008103b000000000000000000000000000000000000000000000000000000000008103c000000000000000000000000000000000000000000000000000000000008103d000000000000000000000000000000000000000000000000000000000008103e000000000000000000000000000000000000000000000000000000000008103f3f0000000000000000000000000000000000000000000000000000000000081100000000000000000000000000000000000000000000000000000000000008110100000000000000000000000000000000000000000000000000000000000811020000000000000000000000000000000000000000000000000000000000081103000000000000000000000000000000000000000000000000000000000008110400000000000000000000000000000000000000000000000000000000000811050000000000000000000000000000000000000000000000000000000000081106000000000000000000000000000000000000000000000000000000000008110700000000000000000000000000000000000000000000000000000000000811080000000000000000000000000000000000000000000000000000000000081109000000000000000000000000000000000000000000000000000000000008110a000000000000000000000000000000000000000000000000000000000008110b000000000000000000000000000000000000000000000000000000000008110c000000000000000000000000000000000000000000000000000000000008110d000000000000000000000000000000000000000000000000000000000008110e000000000000000000000000000000000000000000000000000000000008110f0000000000000000000000000000000000000000000000000000000000081110000000000000000000000000000000000000000000000000000000000008111100000000000000000000000000000000000000000000000000000000000811120000000000000000000000000000000000000000000000000000000000081113000000000000000000000000000000000000000000000000000000000008111400000000000000000000000000000000000000000000000000000000000811150000000000000000000000000000000000000000000000000000000000081116000000000000000000000000000000000000000000000000000000000008111700000000000000000000000000000000000000000000000000000000000811180000000000000000000000000000000000000000000000000000000000081119000000000000000000000000000000000000000000000000000000000008111a000000000000000000000000000000000000000000000000000000000008111b000000000000000000000000000000000000000000000000000000000008111c000000000000000000000000000000000000000000000000000000000008111d000000000000000000000000000000000000000000000000000000000008111e000000000000000000000000000000000000000000000000000000000008111f0000000000000000000000000000000000000000000000000000000000081120000000000000000000000000000000000000000000000000000000000008112100000000000000000000000000000000000000000000000000000000000811220000000000000000000000000000000000000000000000000000000000081123000000000000000000000000000000000000000000000000000000000008112400000000000000000000000000000000000000000000000000000000000811250000000000000000000000000000000000000000000000000000000000081126000000000000000000000000000000000000000000000000000000000008112700000000000000000000000000000000000000000000000000000000000811280000000000000000000000000000000000000000000000000000000000081129000000000000000000000000000000000000000000000000000000000008112a000000000000000000000000000000000000000000000000000000000008112b000000000000000000000000000000000000000000000000000000000008112c000000000000000000000000000000000000000000000000000000000008112d000000000000000000000000000000000000000000000000000000000008112e000000000000000000000000000000000000000000000000000000000008112f0000000000000000000000000000000000000000000000000000000000081130000000000000000000000000000000000000000000000000000000000008113100000000000000000000000000000000000000000000000000000000000811320000000000000000000000000000000000000000000000000000000000081133000000000000000000000000000000000000000000000000000000000008113400000000000000000000000000000000000000000000000000000000000811350000000000000000000000000000000000000000000000000000000000081136000000000000000000000000000000000000000000000000000000000008113700000000000000000000000000000000000000000000000000000000000811380000000000000000000000000000000000000000000000000000000000081139000000000000000000000000000000000000000000000000000000000008113a000000000000000000000000000000000000000000000000000000000008113b000000000000000000000000000000000000000000000000000000000008113c000000000000000000000000000000000000000000000000000000000008113d000000000000000000000000000000000000000000000000000000000008113e08003c0472260790b0bdfb8ae4dc4d437e7686b73643f2198970d84e1059a5f13500bfd46275a318e438726ff2765ae154b63ab8a0daebcbed668a5f58a0e63dc1007906b9418dc758c6b4f8454c69baa48b7889b6b511d707abe8e2cb8f7c397300aeb60c4d65a44f122e58bf9565dfe2024b3ae654d5cf2e47ecb035d53c927000bf82e8cda20345f37bbb1de3932172324b57f0b98be483392697b168e3bba8000fb4bbad884ef30edf68e45a6cf2733fcf50310c69d7c1432b29af2c0aa8040023e1622d27fee3b4a40ab975ae0eb2e31619ef3dc76eb858f7fddb6a056131004689cd7007daf98dd3218b839b8e6a29f957154347b391fdb376bd0b344be23f0000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082001000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082002000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082003000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082004000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082005000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820060000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008200700000000000000000000000000000000000000000000000000000000000820110000000000000000000000000000000000000000000000000000000000082008000000000000000000000000000000000000000000000000000000000008201200000000000000000000000000000000000000000000000000000000000820090000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082016000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082017000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082011000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082012000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820160000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008201700000000000000000000000000000000000000000000000000000000000820210000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008202200000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082026000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082027000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082021000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082022000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820260000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008202700000000000000000000000000000000000000000000000000000000000820310000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008203200000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082036000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082037000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082031000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082032000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008203e0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008203f00000000000000000000000000000000000000000000000000000000000820360000000000000000000000000000000000000000000000000000000000082040000000000000000000000000000000000000000000000000000000000008203700000000000000000000000000000000000000000000000000000000000820410000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008204200000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082043000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082044000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082045000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082046000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082047000000000000000000000000000000000000000000000000000000000008203e00000000000000000000000000000000000000000000000000000000000820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c100100000000000000000000000000000000000000000000000000000000000c100200000000000000000000000000000000000000000000000000000000000c100300000000000000000000000000000000000000000000000000000000000c100400000000000000000000000000000000000000000000000000000000000c100500000000000000000000000000000000000000000000000000000000000c100600000000000000000000000000000000000000000000000000000000000c100700000000000000000000000000000000000000000000000000000000000c100800000000000000000000000000000000000000000000000000000000000c100900000000000000000000000000000000000000000000000000000000000c100a00000000000000000000000000000000000000000000000000000000000c100b00000000000000000000000000000000000000000000000000000000000c100c00000000000000000000000000000000000000000000000000000000000c100d00000000000000000000000000000000000000000000000000000000000c100e00000000000000000000000000000000000000000000000000000000000c100f00000000000000000000000000000000000000000000000000000000000c101000000000000000000000000000000000000000000000000000000000000c101100000000000000000000000000000000000000000000000000000000000c101200000000000000000000000000000000000000000000000000000000000c101300000000000000000000000000000000000000000000000000000000000c101400000000000000000000000000000000000000000000000000000000000c101500000000000000000000000000000000000000000000000000000000000c101600000000000000000000000000000000000000000000000000000000000c101700000000000000000000000000000000000000000000000000000000000c101800000000000000000000000000000000000000000000000000000000000c101900000000000000000000000000000000000000000000000000000000000c101a00000000000000000000000000000000000000000000000000000000000c101b00000000000000000000000000000000000000000000000000000000000c101c00000000000000000000000000000000000000000000000000000000000c101d00000000000000000000000000000000000000000000000000000000000c101e00000000000000000000000000000000000000000000000000000000000c101f00000000000000000000000000000000000000000000000000000000000c102000000000000000000000000000000000000000000000000000000000000c102100000000000000000000000000000000000000000000000000000000000c102200000000000000000000000000000000000000000000000000000000000c102300000000000000000000000000000000000000000000000000000000000c102400000000000000000000000000000000000000000000000000000000000c102500000000000000000000000000000000000000000000000000000000000c102600000000000000000000000000000000000000000000000000000000000c102700000000000000000000000000000000000000000000000000000000000c102800000000000000000000000000000000000000000000000000000000000c102900000000000000000000000000000000000000000000000000000000000c102a00000000000000000000000000000000000000000000000000000000000c102b00000000000000000000000000000000000000000000000000000000000c102c00000000000000000000000000000000000000000000000000000000000c102d00000000000000000000000000000000000000000000000000000000000c102e00000000000000000000000000000000000000000000000000000000000c102f00000000000000000000000000000000000000000000000000000000000c103000000000000000000000000000000000000000000000000000000000000c103100000000000000000000000000000000000000000000000000000000000c103200000000000000000000000000000000000000000000000000000000000c103300000000000000000000000000000000000000000000000000000000000c103400000000000000000000000000000000000000000000000000000000000c103500000000000000000000000000000000000000000000000000000000000c103600000000000000000000000000000000000000000000000000000000000c103700000000000000000000000000000000000000000000000000000000000c103800000000000000000000000000000000000000000000000000000000000c103900000000000000000000000000000000000000000000000000000000000c103a00000000000000000000000000000000000000000000000000000000000c103b00000000000000000000000000000000000000000000000000000000000c103c00000000000000000000000000000000000000000000000000000000000c103d00000000000000000000000000000000000000000000000000000000000c103e00000000000000000000000000000000000000000000000000000000000c103f3f00000000000000000000000000000000000000000000000000000000000c110000000000000000000000000000000000000000000000000000000000000c110100000000000000000000000000000000000000000000000000000000000c110200000000000000000000000000000000000000000000000000000000000c110300000000000000000000000000000000000000000000000000000000000c110400000000000000000000000000000000000000000000000000000000000c110500000000000000000000000000000000000000000000000000000000000c110600000000000000000000000000000000000000000000000000000000000c110700000000000000000000000000000000000000000000000000000000000c110800000000000000000000000000000000000000000000000000000000000c110900000000000000000000000000000000000000000000000000000000000c110a00000000000000000000000000000000000000000000000000000000000c110b00000000000000000000000000000000000000000000000000000000000c110c00000000000000000000000000000000000000000000000000000000000c110d00000000000000000000000000000000000000000000000000000000000c110e00000000000000000000000000000000000000000000000000000000000c110f00000000000000000000000000000000000000000000000000000000000c111000000000000000000000000000000000000000000000000000000000000c111100000000000000000000000000000000000000000000000000000000000c111200000000000000000000000000000000000000000000000000000000000c111300000000000000000000000000000000000000000000000000000000000c111400000000000000000000000000000000000000000000000000000000000c111500000000000000000000000000000000000000000000000000000000000c111600000000000000000000000000000000000000000000000000000000000c111700000000000000000000000000000000000000000000000000000000000c111800000000000000000000000000000000000000000000000000000000000c111900000000000000000000000000000000000000000000000000000000000c111a00000000000000000000000000000000000000000000000000000000000c111b00000000000000000000000000000000000000000000000000000000000c111c00000000000000000000000000000000000000000000000000000000000c111d00000000000000000000000000000000000000000000000000000000000c111e00000000000000000000000000000000000000000000000000000000000c111f00000000000000000000000000000000000000000000000000000000000c112000000000000000000000000000000000000000000000000000000000000c112100000000000000000000000000000000000000000000000000000000000c112200000000000000000000000000000000000000000000000000000000000c112300000000000000000000000000000000000000000000000000000000000c112400000000000000000000000000000000000000000000000000000000000c112500000000000000000000000000000000000000000000000000000000000c112600000000000000000000000000000000000000000000000000000000000c112700000000000000000000000000000000000000000000000000000000000c112800000000000000000000000000000000000000000000000000000000000c112900000000000000000000000000000000000000000000000000000000000c112a00000000000000000000000000000000000000000000000000000000000c112b00000000000000000000000000000000000000000000000000000000000c112c00000000000000000000000000000000000000000000000000000000000c112d00000000000000000000000000000000000000000000000000000000000c112e00000000000000000000000000000000000000000000000000000000000c112f00000000000000000000000000000000000000000000000000000000000c113000000000000000000000000000000000000000000000000000000000000c113100000000000000000000000000000000000000000000000000000000000c113200000000000000000000000000000000000000000000000000000000000c113300000000000000000000000000000000000000000000000000000000000c113400000000000000000000000000000000000000000000000000000000000c113500000000000000000000000000000000000000000000000000000000000c113600000000000000000000000000000000000000000000000000000000000c113700000000000000000000000000000000000000000000000000000000000c113800000000000000000000000000000000000000000000000000000000000c113900000000000000000000000000000000000000000000000000000000000c113a00000000000000000000000000000000000000000000000000000000000c113b00000000000000000000000000000000000000000000000000000000000c113c00000000000000000000000000000000000000000000000000000000000c113d00000000000000000000000000000000000000000000000000000000000c113e0800f8029be42ec3f25204907ca981fb71e5b357093eb5db10fc01ca98a4e4154c0030e13d351a5bf1d5a040e82a163ca57017f39162693f85c571e441e36d702d00a550ae0f39f977d9473d6de1be3232fc68ed0c4a601d53542148695102cfc9005580bc65e4bff9c8fffa64db02c0fa6af14d9d26fd962f4c5904cbd3ddec2500758c4a0d43dfec788b2f580877c4f473adec8f168ea24424f2600e4eb4916f00342602bf90d10f8ca8e582a894dcc4c02bb89fe458532e0c632b53bae54b4d00ca43ab78ab834337e9964d84a0674c9adabdca140539c5a6bc96e0ba9a51f6004ffbfd91be292a7c6a0e255e50caa156ac2d628b40ad2128c4ab63a92d8a1c3f00000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c200100000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c200200000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c200300000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c200400000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c200500000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c200600000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c200700000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c200800000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c200900000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c203f00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c204000000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c204100000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c204200000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c204300000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c204400000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c204500000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c204600000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c204700000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000010100100000000000000000000000000000000000000000000000000000000001010020000000000000000000000000000000000000000000000000000000000101003000000000000000000000000000000000000000000000000000000000010100400000000000000000000000000000000000000000000000000000000001010050000000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000010100700000000000000000000000000000000000000000000000000000000001010080000000000000000000000000000000000000000000000000000000000101009000000000000000000000000000000000000000000000000000000000010100a000000000000000000000000000000000000000000000000000000000010100b000000000000000000000000000000000000000000000000000000000010100c000000000000000000000000000000000000000000000000000000000010100d000000000000000000000000000000000000000000000000000000000010100e000000000000000000000000000000000000000000000000000000000010100f0000000000000000000000000000000000000000000000000000000000101010000000000000000000000000000000000000000000000000000000000010101100000000000000000000000000000000000000000000000000000000001010120000000000000000000000000000000000000000000000000000000000101013000000000000000000000000000000000000000000000000000000000010101400000000000000000000000000000000000000000000000000000000001010150000000000000000000000000000000000000000000000000000000000101016000000000000000000000000000000000000000000000000000000000010101700000000000000000000000000000000000000000000000000000000001010180000000000000000000000000000000000000000000000000000000000101019000000000000000000000000000000000000000000000000000000000010101a000000000000000000000000000000000000000000000000000000000010101b000000000000000000000000000000000000000000000000000000000010101c000000000000000000000000000000000000000000000000000000000010101d000000000000000000000000000000000000000000000000000000000010101e000000000000000000000000000000000000000000000000000000000010101f0000000000000000000000000000000000000000000000000000000000101020000000000000000000000000000000000000000000000000000000000010102100000000000000000000000000000000000000000000000000000000001010220000000000000000000000000000000000000000000000000000000000101023000000000000000000000000000000000000000000000000000000000010102400000000000000000000000000000000000000000000000000000000001010250000000000000000000000000000000000000000000000000000000000101026000000000000000000000000000000000000000000000000000000000010102700000000000000000000000000000000000000000000000000000000001010280000000000000000000000000000000000000000000000000000000000101029000000000000000000000000000000000000000000000000000000000010102a000000000000000000000000000000000000000000000000000000000010102b000000000000000000000000000000000000000000000000000000000010102c000000000000000000000000000000000000000000000000000000000010102d000000000000000000000000000000000000000000000000000000000010102e000000000000000000000000000000000000000000000000000000000010102f0000000000000000000000000000000000000000000000000000000000101030000000000000000000000000000000000000000000000000000000000010103100000000000000000000000000000000000000000000000000000000001010320000000000000000000000000000000000000000000000000000000000101033000000000000000000000000000000000000000000000000000000000010103400000000000000000000000000000000000000000000000000000000001010350000000000000000000000000000000000000000000000000000000000101036000000000000000000000000000000000000000000000000000000000010103700000000000000000000000000000000000000000000000000000000001010380000000000000000000000000000000000000000000000000000000000101039000000000000000000000000000000000000000000000000000000000010103a000000000000000000000000000000000000000000000000000000000010103b000000000000000000000000000000000000000000000000000000000010103c000000000000000000000000000000000000000000000000000000000010103d000000000000000000000000000000000000000000000000000000000010103e000000000000000000000000000000000000000000000000000000000010103f3f0000000000000000000000000000000000000000000000000000000000101100000000000000000000000000000000000000000000000000000000000010110100000000000000000000000000000000000000000000000000000000001011020000000000000000000000000000000000000000000000000000000000101103000000000000000000000000000000000000000000000000000000000010110400000000000000000000000000000000000000000000000000000000001011050000000000000000000000000000000000000000000000000000000000101106000000000000000000000000000000000000000000000000000000000010110700000000000000000000000000000000000000000000000000000000001011080000000000000000000000000000000000000000000000000000000000101109000000000000000000000000000000000000000000000000000000000010110a000000000000000000000000000000000000000000000000000000000010110b000000000000000000000000000000000000000000000000000000000010110c000000000000000000000000000000000000000000000000000000000010110d000000000000000000000000000000000000000000000000000000000010110e000000000000000000000000000000000000000000000000000000000010110f0000000000000000000000000000000000000000000000000000000000101110000000000000000000000000000000000000000000000000000000000010111100000000000000000000000000000000000000000000000000000000001011120000000000000000000000000000000000000000000000000000000000101113000000000000000000000000000000000000000000000000000000000010111400000000000000000000000000000000000000000000000000000000001011150000000000000000000000000000000000000000000000000000000000101116000000000000000000000000000000000000000000000000000000000010111700000000000000000000000000000000000000000000000000000000001011180000000000000000000000000000000000000000000000000000000000101119000000000000000000000000000000000000000000000000000000000010111a000000000000000000000000000000000000000000000000000000000010111b000000000000000000000000000000000000000000000000000000000010111c000000000000000000000000000000000000000000000000000000000010111d000000000000000000000000000000000000000000000000000000000010111e000000000000000000000000000000000000000000000000000000000010111f0000000000000000000000000000000000000000000000000000000000101120000000000000000000000000000000000000000000000000000000000010112100000000000000000000000000000000000000000000000000000000001011220000000000000000000000000000000000000000000000000000000000101123000000000000000000000000000000000000000000000000000000000010112400000000000000000000000000000000000000000000000000000000001011250000000000000000000000000000000000000000000000000000000000101126000000000000000000000000000000000000000000000000000000000010112700000000000000000000000000000000000000000000000000000000001011280000000000000000000000000000000000000000000000000000000000101129000000000000000000000000000000000000000000000000000000000010112a000000000000000000000000000000000000000000000000000000000010112b000000000000000000000000000000000000000000000000000000000010112c000000000000000000000000000000000000000000000000000000000010112d000000000000000000000000000000000000000000000000000000000010112e000000000000000000000000000000000000000000000000000000000010112f0000000000000000000000000000000000000000000000000000000000101130000000000000000000000000000000000000000000000000000000000010113100000000000000000000000000000000000000000000000000000000001011320000000000000000000000000000000000000000000000000000000000101133000000000000000000000000000000000000000000000000000000000010113400000000000000000000000000000000000000000000000000000000001011350000000000000000000000000000000000000000000000000000000000101136000000000000000000000000000000000000000000000000000000000010113700000000000000000000000000000000000000000000000000000000001011380000000000000000000000000000000000000000000000000000000000101139000000000000000000000000000000000000000000000000000000000010113a000000000000000000000000000000000000000000000000000000000010113b000000000000000000000000000000000000000000000000000000000010113c000000000000000000000000000000000000000000000000000000000010113d000000000000000000000000000000000000000000000000000000000010113e080099145b6c0d32753835121f8b271186d01236948a4622ce78a98347fcfc98390085277a27c6acbd5ffc4c19cd65fc30056999e9bec36998f753132db0ff8e2300f3cf77a7261759ebd5f4149f6ad56746f4499cfcd4adf27a1d373f77da64d5009bc6e0e994a23cde8c95b90c1acc1b4a480c6599d1df2c3f9f6e76f3d1aff200d7a1c4a2700dacaaf07f1f0ff33837bdbabcf0b9ace17efabe0761708c4bb900dbeb8e96d14f21e57d5786b6d6ae7e5ddb1bb35935c0fb246d4bdbca62e02c00fbf12b5e0df6223b801088798e4e04d2a92ffe9a11639b7f0ce314e3412a8000d796e0724de03b796ba77069fcd6cf921e566f3aed15eb3e77258add74e9ff3f0000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102001000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102002000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102003000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102004000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102005000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020060000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010200700000000000000000000000000000000000000000000000000000000001020110000000000000000000000000000000000000000000000000000000000102008000000000000000000000000000000000000000000000000000000000010201200000000000000000000000000000000000000000000000000000000001020090000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102016000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102017000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102011000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102012000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020160000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010201700000000000000000000000000000000000000000000000000000000001020210000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010202200000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102026000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102027000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102021000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102022000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020260000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010202700000000000000000000000000000000000000000000000000000000001020310000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010203200000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102036000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102037000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102031000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102032000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010203f00000000000000000000000000000000000000000000000000000000001020360000000000000000000000000000000000000000000000000000000000102040000000000000000000000000000000000000000000000000000000000010203700000000000000000000000000000000000000000000000000000000001020410000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010204200000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102043000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102044000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102045000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102046000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102047000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "txsEffectsHash": "0x00db66b36b24ebccb7543a74620018056cad2f0b08eaf251ad00362551f0a2d0", "decodedHeader": { "contentCommitment": { "inHash": "0x00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c", "outHash": "0x000ca4a4610ad22c97c9161cedcf01faa3619f1b85457f1627d09627b71903a6", "numTxs": 4, - "txsEffectsHash": "0x007b27babdf78c8beb8d7a937731158a4422309edacfeb6e2b9c9125a01617a2" + "txsEffectsHash": "0x00db66b36b24ebccb7543a74620018056cad2f0b08eaf251ad00362551f0a2d0" }, "globalVariables": { "blockNumber": 1, "slotNumber": "0x000000000000000000000000000000000000000000000000000000000000001a", "chainId": 31337, - "timestamp": 1731106419, + "timestamp": 1731434005, "version": 1, - "coinbase": "0xe1b76c7e0eb80841fed024c0470d663250bdd96e", - "feeRecipient": "0x1f1730e56d57b24d909d5eae3094c83900c3fb2fa90e248dfddb825f2e4e55e8", + "coinbase": "0xa8f1a4313bc15dcd3681ed2b6fdd042f1ee1f823", + "feeRecipient": "0x2abdc96d2ec8465dfd2bb7401f90dd3af0db16c3cece57bd5de2b63a3d25140b", "gasFees": { "feePerDaGas": 0, "feePerL2Gas": 0 @@ -107,8 +107,8 @@ } } }, - "header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce1900467779860000000010000000000000000000000000000000000000000000000000000000000000004007b27babdf78c8beb8d7a937731158a4422309edacfeb6e2b9c9125a01617a200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c000ca4a4610ad22c97c9161cedcf01faa3619f1b85457f1627d09627b71903a62e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d60000001000553ea03210e12bf95ed15f0105108f39db784d318cfe9b52cba413618711ce000001001d52eeaaacb445d9193d29e0df8f0ad4bf69bc457fe955b8e05b48ae3fdc3b3f00000180160cf8d0dbcc7b6a69aede9d89adb66554ba8054d9944b6ab5475e155e8f73d4000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000672e9673e1b76c7e0eb80841fed024c0470d663250bdd96e1f1730e56d57b24d909d5eae3094c83900c3fb2fa90e248dfddb825f2e4e55e8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "publicInputsHash": "0x001e9220ab6b62c63ad3086a8a6c9dadffb229804bc6dac30e26403158f02810", + "header": "0x2a05cb8aeefe9b9797f90650eae072f5ab7437807e62f9724ce190046777986000000001000000000000000000000000000000000000000000000000000000000000000400db66b36b24ebccb7543a74620018056cad2f0b08eaf251ad00362551f0a2d000089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c000ca4a4610ad22c97c9161cedcf01faa3619f1b85457f1627d09627b71903a62e33ee2008411c04b99c24b313513d097a0d21a5040b6193d1f978b8226892d60000001000553ea03210e12bf95ed15f0105108f39db784d318cfe9b52cba413618711ce000001001d52eeaaacb445d9193d29e0df8f0ad4bf69bc457fe955b8e05b48ae3fdc3b3f00000180160cf8d0dbcc7b6a69aede9d89adb66554ba8054d9944b6ab5475e155e8f73d4000001800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000067339615a8f1a4313bc15dcd3681ed2b6fdd042f1ee1f8232abdc96d2ec8465dfd2bb7401f90dd3af0db16c3cece57bd5de2b63a3d25140b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "publicInputsHash": "0x0058fc697c9471ef94446a35f46a068633d057596164ddf20e6152f6fac19f81", "numTxs": 4 } } \ No newline at end of file diff --git a/l1-contracts/test/fixtures/mixed_block_2.json b/l1-contracts/test/fixtures/mixed_block_2.json index 0d26ec05a3c7..1a84a75aa316 100644 --- a/l1-contracts/test/fixtures/mixed_block_2.json +++ b/l1-contracts/test/fixtures/mixed_block_2.json @@ -90,25 +90,25 @@ ] }, "block": { - "archive": "0x2ab4164ad9e20771c61fc7d9e2b1cbb2c1e02c6d050503d8d448e2bff77e56d3", - "blockHash": "0x1d3a51cdc172aa1d96a4f371c1673882cde1c0e6ecd26cc017b06dd433ea4c5b", - "body": "0x00000008000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000004100100000000000000000000000000000000000000000000000000000000000410020000000000000000000000000000000000000000000000000000000000041003000000000000000000000000000000000000000000000000000000000004100400000000000000000000000000000000000000000000000000000000000410050000000000000000000000000000000000000000000000000000000000041006000000000000000000000000000000000000000000000000000000000004100700000000000000000000000000000000000000000000000000000000000410080000000000000000000000000000000000000000000000000000000000041009000000000000000000000000000000000000000000000000000000000004100a000000000000000000000000000000000000000000000000000000000004100b000000000000000000000000000000000000000000000000000000000004100c000000000000000000000000000000000000000000000000000000000004100d000000000000000000000000000000000000000000000000000000000004100e000000000000000000000000000000000000000000000000000000000004100f0000000000000000000000000000000000000000000000000000000000041010000000000000000000000000000000000000000000000000000000000004101100000000000000000000000000000000000000000000000000000000000410120000000000000000000000000000000000000000000000000000000000041013000000000000000000000000000000000000000000000000000000000004101400000000000000000000000000000000000000000000000000000000000410150000000000000000000000000000000000000000000000000000000000041016000000000000000000000000000000000000000000000000000000000004101700000000000000000000000000000000000000000000000000000000000410180000000000000000000000000000000000000000000000000000000000041019000000000000000000000000000000000000000000000000000000000004101a000000000000000000000000000000000000000000000000000000000004101b000000000000000000000000000000000000000000000000000000000004101c000000000000000000000000000000000000000000000000000000000004101d000000000000000000000000000000000000000000000000000000000004101e000000000000000000000000000000000000000000000000000000000004101f0000000000000000000000000000000000000000000000000000000000041020000000000000000000000000000000000000000000000000000000000004102100000000000000000000000000000000000000000000000000000000000410220000000000000000000000000000000000000000000000000000000000041023000000000000000000000000000000000000000000000000000000000004102400000000000000000000000000000000000000000000000000000000000410250000000000000000000000000000000000000000000000000000000000041026000000000000000000000000000000000000000000000000000000000004102700000000000000000000000000000000000000000000000000000000000410280000000000000000000000000000000000000000000000000000000000041029000000000000000000000000000000000000000000000000000000000004102a000000000000000000000000000000000000000000000000000000000004102b000000000000000000000000000000000000000000000000000000000004102c000000000000000000000000000000000000000000000000000000000004102d000000000000000000000000000000000000000000000000000000000004102e000000000000000000000000000000000000000000000000000000000004102f0000000000000000000000000000000000000000000000000000000000041030000000000000000000000000000000000000000000000000000000000004103100000000000000000000000000000000000000000000000000000000000410320000000000000000000000000000000000000000000000000000000000041033000000000000000000000000000000000000000000000000000000000004103400000000000000000000000000000000000000000000000000000000000410350000000000000000000000000000000000000000000000000000000000041036000000000000000000000000000000000000000000000000000000000004103700000000000000000000000000000000000000000000000000000000000410380000000000000000000000000000000000000000000000000000000000041039000000000000000000000000000000000000000000000000000000000004103a000000000000000000000000000000000000000000000000000000000004103b000000000000000000000000000000000000000000000000000000000004103c000000000000000000000000000000000000000000000000000000000004103d000000000000000000000000000000000000000000000000000000000004103e000000000000000000000000000000000000000000000000000000000004103f3f0000000000000000000000000000000000000000000000000000000000041100000000000000000000000000000000000000000000000000000000000004110100000000000000000000000000000000000000000000000000000000000411020000000000000000000000000000000000000000000000000000000000041103000000000000000000000000000000000000000000000000000000000004110400000000000000000000000000000000000000000000000000000000000411050000000000000000000000000000000000000000000000000000000000041106000000000000000000000000000000000000000000000000000000000004110700000000000000000000000000000000000000000000000000000000000411080000000000000000000000000000000000000000000000000000000000041109000000000000000000000000000000000000000000000000000000000004110a000000000000000000000000000000000000000000000000000000000004110b000000000000000000000000000000000000000000000000000000000004110c000000000000000000000000000000000000000000000000000000000004110d000000000000000000000000000000000000000000000000000000000004110e000000000000000000000000000000000000000000000000000000000004110f0000000000000000000000000000000000000000000000000000000000041110000000000000000000000000000000000000000000000000000000000004111100000000000000000000000000000000000000000000000000000000000411120000000000000000000000000000000000000000000000000000000000041113000000000000000000000000000000000000000000000000000000000004111400000000000000000000000000000000000000000000000000000000000411150000000000000000000000000000000000000000000000000000000000041116000000000000000000000000000000000000000000000000000000000004111700000000000000000000000000000000000000000000000000000000000411180000000000000000000000000000000000000000000000000000000000041119000000000000000000000000000000000000000000000000000000000004111a000000000000000000000000000000000000000000000000000000000004111b000000000000000000000000000000000000000000000000000000000004111c000000000000000000000000000000000000000000000000000000000004111d000000000000000000000000000000000000000000000000000000000004111e000000000000000000000000000000000000000000000000000000000004111f0000000000000000000000000000000000000000000000000000000000041120000000000000000000000000000000000000000000000000000000000004112100000000000000000000000000000000000000000000000000000000000411220000000000000000000000000000000000000000000000000000000000041123000000000000000000000000000000000000000000000000000000000004112400000000000000000000000000000000000000000000000000000000000411250000000000000000000000000000000000000000000000000000000000041126000000000000000000000000000000000000000000000000000000000004112700000000000000000000000000000000000000000000000000000000000411280000000000000000000000000000000000000000000000000000000000041129000000000000000000000000000000000000000000000000000000000004112a000000000000000000000000000000000000000000000000000000000004112b000000000000000000000000000000000000000000000000000000000004112c000000000000000000000000000000000000000000000000000000000004112d000000000000000000000000000000000000000000000000000000000004112e000000000000000000000000000000000000000000000000000000000004112f0000000000000000000000000000000000000000000000000000000000041130000000000000000000000000000000000000000000000000000000000004113100000000000000000000000000000000000000000000000000000000000411320000000000000000000000000000000000000000000000000000000000041133000000000000000000000000000000000000000000000000000000000004113400000000000000000000000000000000000000000000000000000000000411350000000000000000000000000000000000000000000000000000000000041136000000000000000000000000000000000000000000000000000000000004113700000000000000000000000000000000000000000000000000000000000411380000000000000000000000000000000000000000000000000000000000041139000000000000000000000000000000000000000000000000000000000004113a000000000000000000000000000000000000000000000000000000000004113b000000000000000000000000000000000000000000000000000000000004113c000000000000000000000000000000000000000000000000000000000004113d000000000000000000000000000000000000000000000000000000000004113e080097a6ec570e9b8e257647c9c74c5ad3edc57ca5ef6ae44d80b3c30d1d99b9b300ce48ec41d1edde0066fab553a456ae2f380d14fa8f956af1fb0217513a598900619ff12eaf97f63aa2a2311de3b6571a7b880a5247cb33b6a74787bf3f9bd5007854a2fad4e1801c6404394bf3d37ab08c135ea38a1974242e39a21273685f000f55796e72957a819e68a22e8602d73c3ba3718a5a4bd92b80b0aa444b182a00788b6e9874fb040ee679a7fae257190099a605229b948334e54a57739535d4004f1658ee3c1a91627e5d72f5a731f0796299df82ab41e72c88eee0c82fa85e003ee802add96628c693ed71afa9908138ba5a6fbf0a5f29a9c74e4e42aba6713f0000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042001000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042002000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042003000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042004000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042005000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420060000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004200700000000000000000000000000000000000000000000000000000000000420110000000000000000000000000000000000000000000000000000000000042008000000000000000000000000000000000000000000000000000000000004201200000000000000000000000000000000000000000000000000000000000420090000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042016000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042017000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042011000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042012000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420160000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004201700000000000000000000000000000000000000000000000000000000000420210000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004202200000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042026000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042027000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042021000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042022000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420260000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004202700000000000000000000000000000000000000000000000000000000000420310000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004203200000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042036000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042037000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042031000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042032000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004203f00000000000000000000000000000000000000000000000000000000000420360000000000000000000000000000000000000000000000000000000000042040000000000000000000000000000000000000000000000000000000000004203700000000000000000000000000000000000000000000000000000000000420410000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004204200000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042043000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042044000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042045000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042046000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042047000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000081000000000000000000000000000000000000000000000000000000000000008100100000000000000000000000000000000000000000000000000000000000810020000000000000000000000000000000000000000000000000000000000081003000000000000000000000000000000000000000000000000000000000008100400000000000000000000000000000000000000000000000000000000000810050000000000000000000000000000000000000000000000000000000000081006000000000000000000000000000000000000000000000000000000000008100700000000000000000000000000000000000000000000000000000000000810080000000000000000000000000000000000000000000000000000000000081009000000000000000000000000000000000000000000000000000000000008100a000000000000000000000000000000000000000000000000000000000008100b000000000000000000000000000000000000000000000000000000000008100c000000000000000000000000000000000000000000000000000000000008100d000000000000000000000000000000000000000000000000000000000008100e000000000000000000000000000000000000000000000000000000000008100f0000000000000000000000000000000000000000000000000000000000081010000000000000000000000000000000000000000000000000000000000008101100000000000000000000000000000000000000000000000000000000000810120000000000000000000000000000000000000000000000000000000000081013000000000000000000000000000000000000000000000000000000000008101400000000000000000000000000000000000000000000000000000000000810150000000000000000000000000000000000000000000000000000000000081016000000000000000000000000000000000000000000000000000000000008101700000000000000000000000000000000000000000000000000000000000810180000000000000000000000000000000000000000000000000000000000081019000000000000000000000000000000000000000000000000000000000008101a000000000000000000000000000000000000000000000000000000000008101b000000000000000000000000000000000000000000000000000000000008101c000000000000000000000000000000000000000000000000000000000008101d000000000000000000000000000000000000000000000000000000000008101e000000000000000000000000000000000000000000000000000000000008101f0000000000000000000000000000000000000000000000000000000000081020000000000000000000000000000000000000000000000000000000000008102100000000000000000000000000000000000000000000000000000000000810220000000000000000000000000000000000000000000000000000000000081023000000000000000000000000000000000000000000000000000000000008102400000000000000000000000000000000000000000000000000000000000810250000000000000000000000000000000000000000000000000000000000081026000000000000000000000000000000000000000000000000000000000008102700000000000000000000000000000000000000000000000000000000000810280000000000000000000000000000000000000000000000000000000000081029000000000000000000000000000000000000000000000000000000000008102a000000000000000000000000000000000000000000000000000000000008102b000000000000000000000000000000000000000000000000000000000008102c000000000000000000000000000000000000000000000000000000000008102d000000000000000000000000000000000000000000000000000000000008102e000000000000000000000000000000000000000000000000000000000008102f0000000000000000000000000000000000000000000000000000000000081030000000000000000000000000000000000000000000000000000000000008103100000000000000000000000000000000000000000000000000000000000810320000000000000000000000000000000000000000000000000000000000081033000000000000000000000000000000000000000000000000000000000008103400000000000000000000000000000000000000000000000000000000000810350000000000000000000000000000000000000000000000000000000000081036000000000000000000000000000000000000000000000000000000000008103700000000000000000000000000000000000000000000000000000000000810380000000000000000000000000000000000000000000000000000000000081039000000000000000000000000000000000000000000000000000000000008103a000000000000000000000000000000000000000000000000000000000008103b000000000000000000000000000000000000000000000000000000000008103c000000000000000000000000000000000000000000000000000000000008103d000000000000000000000000000000000000000000000000000000000008103e000000000000000000000000000000000000000000000000000000000008103f3f0000000000000000000000000000000000000000000000000000000000081100000000000000000000000000000000000000000000000000000000000008110100000000000000000000000000000000000000000000000000000000000811020000000000000000000000000000000000000000000000000000000000081103000000000000000000000000000000000000000000000000000000000008110400000000000000000000000000000000000000000000000000000000000811050000000000000000000000000000000000000000000000000000000000081106000000000000000000000000000000000000000000000000000000000008110700000000000000000000000000000000000000000000000000000000000811080000000000000000000000000000000000000000000000000000000000081109000000000000000000000000000000000000000000000000000000000008110a000000000000000000000000000000000000000000000000000000000008110b000000000000000000000000000000000000000000000000000000000008110c000000000000000000000000000000000000000000000000000000000008110d000000000000000000000000000000000000000000000000000000000008110e000000000000000000000000000000000000000000000000000000000008110f0000000000000000000000000000000000000000000000000000000000081110000000000000000000000000000000000000000000000000000000000008111100000000000000000000000000000000000000000000000000000000000811120000000000000000000000000000000000000000000000000000000000081113000000000000000000000000000000000000000000000000000000000008111400000000000000000000000000000000000000000000000000000000000811150000000000000000000000000000000000000000000000000000000000081116000000000000000000000000000000000000000000000000000000000008111700000000000000000000000000000000000000000000000000000000000811180000000000000000000000000000000000000000000000000000000000081119000000000000000000000000000000000000000000000000000000000008111a000000000000000000000000000000000000000000000000000000000008111b000000000000000000000000000000000000000000000000000000000008111c000000000000000000000000000000000000000000000000000000000008111d000000000000000000000000000000000000000000000000000000000008111e000000000000000000000000000000000000000000000000000000000008111f0000000000000000000000000000000000000000000000000000000000081120000000000000000000000000000000000000000000000000000000000008112100000000000000000000000000000000000000000000000000000000000811220000000000000000000000000000000000000000000000000000000000081123000000000000000000000000000000000000000000000000000000000008112400000000000000000000000000000000000000000000000000000000000811250000000000000000000000000000000000000000000000000000000000081126000000000000000000000000000000000000000000000000000000000008112700000000000000000000000000000000000000000000000000000000000811280000000000000000000000000000000000000000000000000000000000081129000000000000000000000000000000000000000000000000000000000008112a000000000000000000000000000000000000000000000000000000000008112b000000000000000000000000000000000000000000000000000000000008112c000000000000000000000000000000000000000000000000000000000008112d000000000000000000000000000000000000000000000000000000000008112e000000000000000000000000000000000000000000000000000000000008112f0000000000000000000000000000000000000000000000000000000000081130000000000000000000000000000000000000000000000000000000000008113100000000000000000000000000000000000000000000000000000000000811320000000000000000000000000000000000000000000000000000000000081133000000000000000000000000000000000000000000000000000000000008113400000000000000000000000000000000000000000000000000000000000811350000000000000000000000000000000000000000000000000000000000081136000000000000000000000000000000000000000000000000000000000008113700000000000000000000000000000000000000000000000000000000000811380000000000000000000000000000000000000000000000000000000000081139000000000000000000000000000000000000000000000000000000000008113a000000000000000000000000000000000000000000000000000000000008113b000000000000000000000000000000000000000000000000000000000008113c000000000000000000000000000000000000000000000000000000000008113d000000000000000000000000000000000000000000000000000000000008113e08003c0472260790b0bdfb8ae4dc4d437e7686b73643f2198970d84e1059a5f13500bfd46275a318e438726ff2765ae154b63ab8a0daebcbed668a5f58a0e63dc1007906b9418dc758c6b4f8454c69baa48b7889b6b511d707abe8e2cb8f7c397300aeb60c4d65a44f122e58bf9565dfe2024b3ae654d5cf2e47ecb035d53c927000bf82e8cda20345f37bbb1de3932172324b57f0b98be483392697b168e3bba8000fb4bbad884ef30edf68e45a6cf2733fcf50310c69d7c1432b29af2c0aa8040023e1622d27fee3b4a40ab975ae0eb2e31619ef3dc76eb858f7fddb6a056131004689cd7007daf98dd3218b839b8e6a29f957154347b391fdb376bd0b344be23f0000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082001000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082002000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082003000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082004000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082005000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820060000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008200700000000000000000000000000000000000000000000000000000000000820110000000000000000000000000000000000000000000000000000000000082008000000000000000000000000000000000000000000000000000000000008201200000000000000000000000000000000000000000000000000000000000820090000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082016000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082017000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082011000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082012000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820160000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008201700000000000000000000000000000000000000000000000000000000000820210000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008202200000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082026000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082027000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082021000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082022000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820260000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008202700000000000000000000000000000000000000000000000000000000000820310000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008203200000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082036000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082037000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082031000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082032000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008203e0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008203f00000000000000000000000000000000000000000000000000000000000820360000000000000000000000000000000000000000000000000000000000082040000000000000000000000000000000000000000000000000000000000008203700000000000000000000000000000000000000000000000000000000000820410000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008204200000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082043000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082044000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082045000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082046000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082047000000000000000000000000000000000000000000000000000000000008203e00000000000000000000000000000000000000000000000000000000000820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c100100000000000000000000000000000000000000000000000000000000000c100200000000000000000000000000000000000000000000000000000000000c100300000000000000000000000000000000000000000000000000000000000c100400000000000000000000000000000000000000000000000000000000000c100500000000000000000000000000000000000000000000000000000000000c100600000000000000000000000000000000000000000000000000000000000c100700000000000000000000000000000000000000000000000000000000000c100800000000000000000000000000000000000000000000000000000000000c100900000000000000000000000000000000000000000000000000000000000c100a00000000000000000000000000000000000000000000000000000000000c100b00000000000000000000000000000000000000000000000000000000000c100c00000000000000000000000000000000000000000000000000000000000c100d00000000000000000000000000000000000000000000000000000000000c100e00000000000000000000000000000000000000000000000000000000000c100f00000000000000000000000000000000000000000000000000000000000c101000000000000000000000000000000000000000000000000000000000000c101100000000000000000000000000000000000000000000000000000000000c101200000000000000000000000000000000000000000000000000000000000c101300000000000000000000000000000000000000000000000000000000000c101400000000000000000000000000000000000000000000000000000000000c101500000000000000000000000000000000000000000000000000000000000c101600000000000000000000000000000000000000000000000000000000000c101700000000000000000000000000000000000000000000000000000000000c101800000000000000000000000000000000000000000000000000000000000c101900000000000000000000000000000000000000000000000000000000000c101a00000000000000000000000000000000000000000000000000000000000c101b00000000000000000000000000000000000000000000000000000000000c101c00000000000000000000000000000000000000000000000000000000000c101d00000000000000000000000000000000000000000000000000000000000c101e00000000000000000000000000000000000000000000000000000000000c101f00000000000000000000000000000000000000000000000000000000000c102000000000000000000000000000000000000000000000000000000000000c102100000000000000000000000000000000000000000000000000000000000c102200000000000000000000000000000000000000000000000000000000000c102300000000000000000000000000000000000000000000000000000000000c102400000000000000000000000000000000000000000000000000000000000c102500000000000000000000000000000000000000000000000000000000000c102600000000000000000000000000000000000000000000000000000000000c102700000000000000000000000000000000000000000000000000000000000c102800000000000000000000000000000000000000000000000000000000000c102900000000000000000000000000000000000000000000000000000000000c102a00000000000000000000000000000000000000000000000000000000000c102b00000000000000000000000000000000000000000000000000000000000c102c00000000000000000000000000000000000000000000000000000000000c102d00000000000000000000000000000000000000000000000000000000000c102e00000000000000000000000000000000000000000000000000000000000c102f00000000000000000000000000000000000000000000000000000000000c103000000000000000000000000000000000000000000000000000000000000c103100000000000000000000000000000000000000000000000000000000000c103200000000000000000000000000000000000000000000000000000000000c103300000000000000000000000000000000000000000000000000000000000c103400000000000000000000000000000000000000000000000000000000000c103500000000000000000000000000000000000000000000000000000000000c103600000000000000000000000000000000000000000000000000000000000c103700000000000000000000000000000000000000000000000000000000000c103800000000000000000000000000000000000000000000000000000000000c103900000000000000000000000000000000000000000000000000000000000c103a00000000000000000000000000000000000000000000000000000000000c103b00000000000000000000000000000000000000000000000000000000000c103c00000000000000000000000000000000000000000000000000000000000c103d00000000000000000000000000000000000000000000000000000000000c103e00000000000000000000000000000000000000000000000000000000000c103f3f00000000000000000000000000000000000000000000000000000000000c110000000000000000000000000000000000000000000000000000000000000c110100000000000000000000000000000000000000000000000000000000000c110200000000000000000000000000000000000000000000000000000000000c110300000000000000000000000000000000000000000000000000000000000c110400000000000000000000000000000000000000000000000000000000000c110500000000000000000000000000000000000000000000000000000000000c110600000000000000000000000000000000000000000000000000000000000c110700000000000000000000000000000000000000000000000000000000000c110800000000000000000000000000000000000000000000000000000000000c110900000000000000000000000000000000000000000000000000000000000c110a00000000000000000000000000000000000000000000000000000000000c110b00000000000000000000000000000000000000000000000000000000000c110c00000000000000000000000000000000000000000000000000000000000c110d00000000000000000000000000000000000000000000000000000000000c110e00000000000000000000000000000000000000000000000000000000000c110f00000000000000000000000000000000000000000000000000000000000c111000000000000000000000000000000000000000000000000000000000000c111100000000000000000000000000000000000000000000000000000000000c111200000000000000000000000000000000000000000000000000000000000c111300000000000000000000000000000000000000000000000000000000000c111400000000000000000000000000000000000000000000000000000000000c111500000000000000000000000000000000000000000000000000000000000c111600000000000000000000000000000000000000000000000000000000000c111700000000000000000000000000000000000000000000000000000000000c111800000000000000000000000000000000000000000000000000000000000c111900000000000000000000000000000000000000000000000000000000000c111a00000000000000000000000000000000000000000000000000000000000c111b00000000000000000000000000000000000000000000000000000000000c111c00000000000000000000000000000000000000000000000000000000000c111d00000000000000000000000000000000000000000000000000000000000c111e00000000000000000000000000000000000000000000000000000000000c111f00000000000000000000000000000000000000000000000000000000000c112000000000000000000000000000000000000000000000000000000000000c112100000000000000000000000000000000000000000000000000000000000c112200000000000000000000000000000000000000000000000000000000000c112300000000000000000000000000000000000000000000000000000000000c112400000000000000000000000000000000000000000000000000000000000c112500000000000000000000000000000000000000000000000000000000000c112600000000000000000000000000000000000000000000000000000000000c112700000000000000000000000000000000000000000000000000000000000c112800000000000000000000000000000000000000000000000000000000000c112900000000000000000000000000000000000000000000000000000000000c112a00000000000000000000000000000000000000000000000000000000000c112b00000000000000000000000000000000000000000000000000000000000c112c00000000000000000000000000000000000000000000000000000000000c112d00000000000000000000000000000000000000000000000000000000000c112e00000000000000000000000000000000000000000000000000000000000c112f00000000000000000000000000000000000000000000000000000000000c113000000000000000000000000000000000000000000000000000000000000c113100000000000000000000000000000000000000000000000000000000000c113200000000000000000000000000000000000000000000000000000000000c113300000000000000000000000000000000000000000000000000000000000c113400000000000000000000000000000000000000000000000000000000000c113500000000000000000000000000000000000000000000000000000000000c113600000000000000000000000000000000000000000000000000000000000c113700000000000000000000000000000000000000000000000000000000000c113800000000000000000000000000000000000000000000000000000000000c113900000000000000000000000000000000000000000000000000000000000c113a00000000000000000000000000000000000000000000000000000000000c113b00000000000000000000000000000000000000000000000000000000000c113c00000000000000000000000000000000000000000000000000000000000c113d00000000000000000000000000000000000000000000000000000000000c113e0800f8029be42ec3f25204907ca981fb71e5b357093eb5db10fc01ca98a4e4154c0030e13d351a5bf1d5a040e82a163ca57017f39162693f85c571e441e36d702d00a550ae0f39f977d9473d6de1be3232fc68ed0c4a601d53542148695102cfc9005580bc65e4bff9c8fffa64db02c0fa6af14d9d26fd962f4c5904cbd3ddec2500758c4a0d43dfec788b2f580877c4f473adec8f168ea24424f2600e4eb4916f00342602bf90d10f8ca8e582a894dcc4c02bb89fe458532e0c632b53bae54b4d00ca43ab78ab834337e9964d84a0674c9adabdca140539c5a6bc96e0ba9a51f6004ffbfd91be292a7c6a0e255e50caa156ac2d628b40ad2128c4ab63a92d8a1c3f00000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c200100000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c200200000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c200300000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c200400000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c200500000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c200600000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c200700000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c200800000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c200900000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c203f00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c204000000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c204100000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c204200000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c204300000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c204400000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c204500000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c204600000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c204700000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000010100100000000000000000000000000000000000000000000000000000000001010020000000000000000000000000000000000000000000000000000000000101003000000000000000000000000000000000000000000000000000000000010100400000000000000000000000000000000000000000000000000000000001010050000000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000010100700000000000000000000000000000000000000000000000000000000001010080000000000000000000000000000000000000000000000000000000000101009000000000000000000000000000000000000000000000000000000000010100a000000000000000000000000000000000000000000000000000000000010100b000000000000000000000000000000000000000000000000000000000010100c000000000000000000000000000000000000000000000000000000000010100d000000000000000000000000000000000000000000000000000000000010100e000000000000000000000000000000000000000000000000000000000010100f0000000000000000000000000000000000000000000000000000000000101010000000000000000000000000000000000000000000000000000000000010101100000000000000000000000000000000000000000000000000000000001010120000000000000000000000000000000000000000000000000000000000101013000000000000000000000000000000000000000000000000000000000010101400000000000000000000000000000000000000000000000000000000001010150000000000000000000000000000000000000000000000000000000000101016000000000000000000000000000000000000000000000000000000000010101700000000000000000000000000000000000000000000000000000000001010180000000000000000000000000000000000000000000000000000000000101019000000000000000000000000000000000000000000000000000000000010101a000000000000000000000000000000000000000000000000000000000010101b000000000000000000000000000000000000000000000000000000000010101c000000000000000000000000000000000000000000000000000000000010101d000000000000000000000000000000000000000000000000000000000010101e000000000000000000000000000000000000000000000000000000000010101f0000000000000000000000000000000000000000000000000000000000101020000000000000000000000000000000000000000000000000000000000010102100000000000000000000000000000000000000000000000000000000001010220000000000000000000000000000000000000000000000000000000000101023000000000000000000000000000000000000000000000000000000000010102400000000000000000000000000000000000000000000000000000000001010250000000000000000000000000000000000000000000000000000000000101026000000000000000000000000000000000000000000000000000000000010102700000000000000000000000000000000000000000000000000000000001010280000000000000000000000000000000000000000000000000000000000101029000000000000000000000000000000000000000000000000000000000010102a000000000000000000000000000000000000000000000000000000000010102b000000000000000000000000000000000000000000000000000000000010102c000000000000000000000000000000000000000000000000000000000010102d000000000000000000000000000000000000000000000000000000000010102e000000000000000000000000000000000000000000000000000000000010102f0000000000000000000000000000000000000000000000000000000000101030000000000000000000000000000000000000000000000000000000000010103100000000000000000000000000000000000000000000000000000000001010320000000000000000000000000000000000000000000000000000000000101033000000000000000000000000000000000000000000000000000000000010103400000000000000000000000000000000000000000000000000000000001010350000000000000000000000000000000000000000000000000000000000101036000000000000000000000000000000000000000000000000000000000010103700000000000000000000000000000000000000000000000000000000001010380000000000000000000000000000000000000000000000000000000000101039000000000000000000000000000000000000000000000000000000000010103a000000000000000000000000000000000000000000000000000000000010103b000000000000000000000000000000000000000000000000000000000010103c000000000000000000000000000000000000000000000000000000000010103d000000000000000000000000000000000000000000000000000000000010103e000000000000000000000000000000000000000000000000000000000010103f3f0000000000000000000000000000000000000000000000000000000000101100000000000000000000000000000000000000000000000000000000000010110100000000000000000000000000000000000000000000000000000000001011020000000000000000000000000000000000000000000000000000000000101103000000000000000000000000000000000000000000000000000000000010110400000000000000000000000000000000000000000000000000000000001011050000000000000000000000000000000000000000000000000000000000101106000000000000000000000000000000000000000000000000000000000010110700000000000000000000000000000000000000000000000000000000001011080000000000000000000000000000000000000000000000000000000000101109000000000000000000000000000000000000000000000000000000000010110a000000000000000000000000000000000000000000000000000000000010110b000000000000000000000000000000000000000000000000000000000010110c000000000000000000000000000000000000000000000000000000000010110d000000000000000000000000000000000000000000000000000000000010110e000000000000000000000000000000000000000000000000000000000010110f0000000000000000000000000000000000000000000000000000000000101110000000000000000000000000000000000000000000000000000000000010111100000000000000000000000000000000000000000000000000000000001011120000000000000000000000000000000000000000000000000000000000101113000000000000000000000000000000000000000000000000000000000010111400000000000000000000000000000000000000000000000000000000001011150000000000000000000000000000000000000000000000000000000000101116000000000000000000000000000000000000000000000000000000000010111700000000000000000000000000000000000000000000000000000000001011180000000000000000000000000000000000000000000000000000000000101119000000000000000000000000000000000000000000000000000000000010111a000000000000000000000000000000000000000000000000000000000010111b000000000000000000000000000000000000000000000000000000000010111c000000000000000000000000000000000000000000000000000000000010111d000000000000000000000000000000000000000000000000000000000010111e000000000000000000000000000000000000000000000000000000000010111f0000000000000000000000000000000000000000000000000000000000101120000000000000000000000000000000000000000000000000000000000010112100000000000000000000000000000000000000000000000000000000001011220000000000000000000000000000000000000000000000000000000000101123000000000000000000000000000000000000000000000000000000000010112400000000000000000000000000000000000000000000000000000000001011250000000000000000000000000000000000000000000000000000000000101126000000000000000000000000000000000000000000000000000000000010112700000000000000000000000000000000000000000000000000000000001011280000000000000000000000000000000000000000000000000000000000101129000000000000000000000000000000000000000000000000000000000010112a000000000000000000000000000000000000000000000000000000000010112b000000000000000000000000000000000000000000000000000000000010112c000000000000000000000000000000000000000000000000000000000010112d000000000000000000000000000000000000000000000000000000000010112e000000000000000000000000000000000000000000000000000000000010112f0000000000000000000000000000000000000000000000000000000000101130000000000000000000000000000000000000000000000000000000000010113100000000000000000000000000000000000000000000000000000000001011320000000000000000000000000000000000000000000000000000000000101133000000000000000000000000000000000000000000000000000000000010113400000000000000000000000000000000000000000000000000000000001011350000000000000000000000000000000000000000000000000000000000101136000000000000000000000000000000000000000000000000000000000010113700000000000000000000000000000000000000000000000000000000001011380000000000000000000000000000000000000000000000000000000000101139000000000000000000000000000000000000000000000000000000000010113a000000000000000000000000000000000000000000000000000000000010113b000000000000000000000000000000000000000000000000000000000010113c000000000000000000000000000000000000000000000000000000000010113d000000000000000000000000000000000000000000000000000000000010113e080099145b6c0d32753835121f8b271186d01236948a4622ce78a98347fcfc98390085277a27c6acbd5ffc4c19cd65fc30056999e9bec36998f753132db0ff8e2300f3cf77a7261759ebd5f4149f6ad56746f4499cfcd4adf27a1d373f77da64d5009bc6e0e994a23cde8c95b90c1acc1b4a480c6599d1df2c3f9f6e76f3d1aff200d7a1c4a2700dacaaf07f1f0ff33837bdbabcf0b9ace17efabe0761708c4bb900dbeb8e96d14f21e57d5786b6d6ae7e5ddb1bb35935c0fb246d4bdbca62e02c00fbf12b5e0df6223b801088798e4e04d2a92ffe9a11639b7f0ce314e3412a8000d796e0724de03b796ba77069fcd6cf921e566f3aed15eb3e77258add74e9ff3f0000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102001000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102002000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102003000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102004000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102005000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020060000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010200700000000000000000000000000000000000000000000000000000000001020110000000000000000000000000000000000000000000000000000000000102008000000000000000000000000000000000000000000000000000000000010201200000000000000000000000000000000000000000000000000000000001020090000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102016000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102017000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102011000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102012000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020160000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010201700000000000000000000000000000000000000000000000000000000001020210000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010202200000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102026000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102027000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102021000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102022000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020260000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010202700000000000000000000000000000000000000000000000000000000001020310000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010203200000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102036000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102037000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102031000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102032000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010203f00000000000000000000000000000000000000000000000000000000001020360000000000000000000000000000000000000000000000000000000000102040000000000000000000000000000000000000000000000000000000000010203700000000000000000000000000000000000000000000000000000000001020410000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010204200000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102043000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102044000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102045000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102046000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102047000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000141000000000000000000000000000000000000000000000000000000000000014100100000000000000000000000000000000000000000000000000000000001410020000000000000000000000000000000000000000000000000000000000141003000000000000000000000000000000000000000000000000000000000014100400000000000000000000000000000000000000000000000000000000001410050000000000000000000000000000000000000000000000000000000000141006000000000000000000000000000000000000000000000000000000000014100700000000000000000000000000000000000000000000000000000000001410080000000000000000000000000000000000000000000000000000000000141009000000000000000000000000000000000000000000000000000000000014100a000000000000000000000000000000000000000000000000000000000014100b000000000000000000000000000000000000000000000000000000000014100c000000000000000000000000000000000000000000000000000000000014100d000000000000000000000000000000000000000000000000000000000014100e000000000000000000000000000000000000000000000000000000000014100f0000000000000000000000000000000000000000000000000000000000141010000000000000000000000000000000000000000000000000000000000014101100000000000000000000000000000000000000000000000000000000001410120000000000000000000000000000000000000000000000000000000000141013000000000000000000000000000000000000000000000000000000000014101400000000000000000000000000000000000000000000000000000000001410150000000000000000000000000000000000000000000000000000000000141016000000000000000000000000000000000000000000000000000000000014101700000000000000000000000000000000000000000000000000000000001410180000000000000000000000000000000000000000000000000000000000141019000000000000000000000000000000000000000000000000000000000014101a000000000000000000000000000000000000000000000000000000000014101b000000000000000000000000000000000000000000000000000000000014101c000000000000000000000000000000000000000000000000000000000014101d000000000000000000000000000000000000000000000000000000000014101e000000000000000000000000000000000000000000000000000000000014101f0000000000000000000000000000000000000000000000000000000000141020000000000000000000000000000000000000000000000000000000000014102100000000000000000000000000000000000000000000000000000000001410220000000000000000000000000000000000000000000000000000000000141023000000000000000000000000000000000000000000000000000000000014102400000000000000000000000000000000000000000000000000000000001410250000000000000000000000000000000000000000000000000000000000141026000000000000000000000000000000000000000000000000000000000014102700000000000000000000000000000000000000000000000000000000001410280000000000000000000000000000000000000000000000000000000000141029000000000000000000000000000000000000000000000000000000000014102a000000000000000000000000000000000000000000000000000000000014102b000000000000000000000000000000000000000000000000000000000014102c000000000000000000000000000000000000000000000000000000000014102d000000000000000000000000000000000000000000000000000000000014102e000000000000000000000000000000000000000000000000000000000014102f0000000000000000000000000000000000000000000000000000000000141030000000000000000000000000000000000000000000000000000000000014103100000000000000000000000000000000000000000000000000000000001410320000000000000000000000000000000000000000000000000000000000141033000000000000000000000000000000000000000000000000000000000014103400000000000000000000000000000000000000000000000000000000001410350000000000000000000000000000000000000000000000000000000000141036000000000000000000000000000000000000000000000000000000000014103700000000000000000000000000000000000000000000000000000000001410380000000000000000000000000000000000000000000000000000000000141039000000000000000000000000000000000000000000000000000000000014103a000000000000000000000000000000000000000000000000000000000014103b000000000000000000000000000000000000000000000000000000000014103c000000000000000000000000000000000000000000000000000000000014103d000000000000000000000000000000000000000000000000000000000014103e000000000000000000000000000000000000000000000000000000000014103f3f0000000000000000000000000000000000000000000000000000000000141100000000000000000000000000000000000000000000000000000000000014110100000000000000000000000000000000000000000000000000000000001411020000000000000000000000000000000000000000000000000000000000141103000000000000000000000000000000000000000000000000000000000014110400000000000000000000000000000000000000000000000000000000001411050000000000000000000000000000000000000000000000000000000000141106000000000000000000000000000000000000000000000000000000000014110700000000000000000000000000000000000000000000000000000000001411080000000000000000000000000000000000000000000000000000000000141109000000000000000000000000000000000000000000000000000000000014110a000000000000000000000000000000000000000000000000000000000014110b000000000000000000000000000000000000000000000000000000000014110c000000000000000000000000000000000000000000000000000000000014110d000000000000000000000000000000000000000000000000000000000014110e000000000000000000000000000000000000000000000000000000000014110f0000000000000000000000000000000000000000000000000000000000141110000000000000000000000000000000000000000000000000000000000014111100000000000000000000000000000000000000000000000000000000001411120000000000000000000000000000000000000000000000000000000000141113000000000000000000000000000000000000000000000000000000000014111400000000000000000000000000000000000000000000000000000000001411150000000000000000000000000000000000000000000000000000000000141116000000000000000000000000000000000000000000000000000000000014111700000000000000000000000000000000000000000000000000000000001411180000000000000000000000000000000000000000000000000000000000141119000000000000000000000000000000000000000000000000000000000014111a000000000000000000000000000000000000000000000000000000000014111b000000000000000000000000000000000000000000000000000000000014111c000000000000000000000000000000000000000000000000000000000014111d000000000000000000000000000000000000000000000000000000000014111e000000000000000000000000000000000000000000000000000000000014111f0000000000000000000000000000000000000000000000000000000000141120000000000000000000000000000000000000000000000000000000000014112100000000000000000000000000000000000000000000000000000000001411220000000000000000000000000000000000000000000000000000000000141123000000000000000000000000000000000000000000000000000000000014112400000000000000000000000000000000000000000000000000000000001411250000000000000000000000000000000000000000000000000000000000141126000000000000000000000000000000000000000000000000000000000014112700000000000000000000000000000000000000000000000000000000001411280000000000000000000000000000000000000000000000000000000000141129000000000000000000000000000000000000000000000000000000000014112a000000000000000000000000000000000000000000000000000000000014112b000000000000000000000000000000000000000000000000000000000014112c000000000000000000000000000000000000000000000000000000000014112d000000000000000000000000000000000000000000000000000000000014112e000000000000000000000000000000000000000000000000000000000014112f0000000000000000000000000000000000000000000000000000000000141130000000000000000000000000000000000000000000000000000000000014113100000000000000000000000000000000000000000000000000000000001411320000000000000000000000000000000000000000000000000000000000141133000000000000000000000000000000000000000000000000000000000014113400000000000000000000000000000000000000000000000000000000001411350000000000000000000000000000000000000000000000000000000000141136000000000000000000000000000000000000000000000000000000000014113700000000000000000000000000000000000000000000000000000000001411380000000000000000000000000000000000000000000000000000000000141139000000000000000000000000000000000000000000000000000000000014113a000000000000000000000000000000000000000000000000000000000014113b000000000000000000000000000000000000000000000000000000000014113c000000000000000000000000000000000000000000000000000000000014113d000000000000000000000000000000000000000000000000000000000014113e08005c015113cb57d67dd6c0febd596819ac0298b6a23fc80aba17d445d540059a00f20b7d1308051fe7b68031a7c336b0b4b56738928b6510133aff1b818d5a9a0063eec1883a4f95f4933f9275e850d84b3d035f5061ed986c437a07331fd30e00d3a32d6bbc4fd843686fd0c5e118a73b847529977dca5b9e0e81f6604f22ca00c2f4f5133d9194d41e853e5e951e16690babce8461f25342c0bad20f2aa1e3000a6bf4739e7eb387913d955dc2e8f14f8cce27696b9d2e128b6acefafb80ee005763f7e0648f958b559677622a648f318fc79ebc0cb539170d49c26456e69200302e2b8a92cda941e9af8761b89899a58a587656d9710594e1d865b16522993f0000000000000000000000000000000000000000000000000000000000142000000000000000000000000000000000000000000000000000000000000014200a0000000000000000000000000000000000000000000000000000000000142001000000000000000000000000000000000000000000000000000000000014200b0000000000000000000000000000000000000000000000000000000000142002000000000000000000000000000000000000000000000000000000000014200c0000000000000000000000000000000000000000000000000000000000142003000000000000000000000000000000000000000000000000000000000014200d0000000000000000000000000000000000000000000000000000000000142004000000000000000000000000000000000000000000000000000000000014200e0000000000000000000000000000000000000000000000000000000000142005000000000000000000000000000000000000000000000000000000000014200f00000000000000000000000000000000000000000000000000000000001420060000000000000000000000000000000000000000000000000000000000142010000000000000000000000000000000000000000000000000000000000014200700000000000000000000000000000000000000000000000000000000001420110000000000000000000000000000000000000000000000000000000000142008000000000000000000000000000000000000000000000000000000000014201200000000000000000000000000000000000000000000000000000000001420090000000000000000000000000000000000000000000000000000000000142013000000000000000000000000000000000000000000000000000000000014200a0000000000000000000000000000000000000000000000000000000000142014000000000000000000000000000000000000000000000000000000000014200b0000000000000000000000000000000000000000000000000000000000142015000000000000000000000000000000000000000000000000000000000014200c0000000000000000000000000000000000000000000000000000000000142016000000000000000000000000000000000000000000000000000000000014200d0000000000000000000000000000000000000000000000000000000000142017000000000000000000000000000000000000000000000000000000000014200e0000000000000000000000000000000000000000000000000000000000142018000000000000000000000000000000000000000000000000000000000014200f00000000000000000000000000000000000000000000000000000000001420190000000000000000000000000000000000000000000000000000000000142010000000000000000000000000000000000000000000000000000000000014201a0000000000000000000000000000000000000000000000000000000000142011000000000000000000000000000000000000000000000000000000000014201b0000000000000000000000000000000000000000000000000000000000142012000000000000000000000000000000000000000000000000000000000014201c0000000000000000000000000000000000000000000000000000000000142013000000000000000000000000000000000000000000000000000000000014201d0000000000000000000000000000000000000000000000000000000000142014000000000000000000000000000000000000000000000000000000000014201e0000000000000000000000000000000000000000000000000000000000142015000000000000000000000000000000000000000000000000000000000014201f00000000000000000000000000000000000000000000000000000000001420160000000000000000000000000000000000000000000000000000000000142020000000000000000000000000000000000000000000000000000000000014201700000000000000000000000000000000000000000000000000000000001420210000000000000000000000000000000000000000000000000000000000142018000000000000000000000000000000000000000000000000000000000014202200000000000000000000000000000000000000000000000000000000001420190000000000000000000000000000000000000000000000000000000000142023000000000000000000000000000000000000000000000000000000000014201a0000000000000000000000000000000000000000000000000000000000142024000000000000000000000000000000000000000000000000000000000014201b0000000000000000000000000000000000000000000000000000000000142025000000000000000000000000000000000000000000000000000000000014201c0000000000000000000000000000000000000000000000000000000000142026000000000000000000000000000000000000000000000000000000000014201d0000000000000000000000000000000000000000000000000000000000142027000000000000000000000000000000000000000000000000000000000014201e0000000000000000000000000000000000000000000000000000000000142028000000000000000000000000000000000000000000000000000000000014201f00000000000000000000000000000000000000000000000000000000001420290000000000000000000000000000000000000000000000000000000000142020000000000000000000000000000000000000000000000000000000000014202a0000000000000000000000000000000000000000000000000000000000142021000000000000000000000000000000000000000000000000000000000014202b0000000000000000000000000000000000000000000000000000000000142022000000000000000000000000000000000000000000000000000000000014202c0000000000000000000000000000000000000000000000000000000000142023000000000000000000000000000000000000000000000000000000000014202d0000000000000000000000000000000000000000000000000000000000142024000000000000000000000000000000000000000000000000000000000014202e0000000000000000000000000000000000000000000000000000000000142025000000000000000000000000000000000000000000000000000000000014202f00000000000000000000000000000000000000000000000000000000001420260000000000000000000000000000000000000000000000000000000000142030000000000000000000000000000000000000000000000000000000000014202700000000000000000000000000000000000000000000000000000000001420310000000000000000000000000000000000000000000000000000000000142028000000000000000000000000000000000000000000000000000000000014203200000000000000000000000000000000000000000000000000000000001420290000000000000000000000000000000000000000000000000000000000142033000000000000000000000000000000000000000000000000000000000014202a0000000000000000000000000000000000000000000000000000000000142034000000000000000000000000000000000000000000000000000000000014202b0000000000000000000000000000000000000000000000000000000000142035000000000000000000000000000000000000000000000000000000000014202c0000000000000000000000000000000000000000000000000000000000142036000000000000000000000000000000000000000000000000000000000014202d0000000000000000000000000000000000000000000000000000000000142037000000000000000000000000000000000000000000000000000000000014202e0000000000000000000000000000000000000000000000000000000000142038000000000000000000000000000000000000000000000000000000000014202f00000000000000000000000000000000000000000000000000000000001420390000000000000000000000000000000000000000000000000000000000142030000000000000000000000000000000000000000000000000000000000014203a0000000000000000000000000000000000000000000000000000000000142031000000000000000000000000000000000000000000000000000000000014203b0000000000000000000000000000000000000000000000000000000000142032000000000000000000000000000000000000000000000000000000000014203c0000000000000000000000000000000000000000000000000000000000142033000000000000000000000000000000000000000000000000000000000014203d0000000000000000000000000000000000000000000000000000000000142034000000000000000000000000000000000000000000000000000000000014203e0000000000000000000000000000000000000000000000000000000000142035000000000000000000000000000000000000000000000000000000000014203f00000000000000000000000000000000000000000000000000000000001420360000000000000000000000000000000000000000000000000000000000142040000000000000000000000000000000000000000000000000000000000014203700000000000000000000000000000000000000000000000000000000001420410000000000000000000000000000000000000000000000000000000000142038000000000000000000000000000000000000000000000000000000000014204200000000000000000000000000000000000000000000000000000000001420390000000000000000000000000000000000000000000000000000000000142043000000000000000000000000000000000000000000000000000000000014203a0000000000000000000000000000000000000000000000000000000000142044000000000000000000000000000000000000000000000000000000000014203b0000000000000000000000000000000000000000000000000000000000142045000000000000000000000000000000000000000000000000000000000014203c0000000000000000000000000000000000000000000000000000000000142046000000000000000000000000000000000000000000000000000000000014203d0000000000000000000000000000000000000000000000000000000000142047000000000000000000000000000000000000000000000000000000000014203e0000000000000000000000000000000000000000000000000000000000142048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000181000000000000000000000000000000000000000000000000000000000000018100100000000000000000000000000000000000000000000000000000000001810020000000000000000000000000000000000000000000000000000000000181003000000000000000000000000000000000000000000000000000000000018100400000000000000000000000000000000000000000000000000000000001810050000000000000000000000000000000000000000000000000000000000181006000000000000000000000000000000000000000000000000000000000018100700000000000000000000000000000000000000000000000000000000001810080000000000000000000000000000000000000000000000000000000000181009000000000000000000000000000000000000000000000000000000000018100a000000000000000000000000000000000000000000000000000000000018100b000000000000000000000000000000000000000000000000000000000018100c000000000000000000000000000000000000000000000000000000000018100d000000000000000000000000000000000000000000000000000000000018100e000000000000000000000000000000000000000000000000000000000018100f0000000000000000000000000000000000000000000000000000000000181010000000000000000000000000000000000000000000000000000000000018101100000000000000000000000000000000000000000000000000000000001810120000000000000000000000000000000000000000000000000000000000181013000000000000000000000000000000000000000000000000000000000018101400000000000000000000000000000000000000000000000000000000001810150000000000000000000000000000000000000000000000000000000000181016000000000000000000000000000000000000000000000000000000000018101700000000000000000000000000000000000000000000000000000000001810180000000000000000000000000000000000000000000000000000000000181019000000000000000000000000000000000000000000000000000000000018101a000000000000000000000000000000000000000000000000000000000018101b000000000000000000000000000000000000000000000000000000000018101c000000000000000000000000000000000000000000000000000000000018101d000000000000000000000000000000000000000000000000000000000018101e000000000000000000000000000000000000000000000000000000000018101f0000000000000000000000000000000000000000000000000000000000181020000000000000000000000000000000000000000000000000000000000018102100000000000000000000000000000000000000000000000000000000001810220000000000000000000000000000000000000000000000000000000000181023000000000000000000000000000000000000000000000000000000000018102400000000000000000000000000000000000000000000000000000000001810250000000000000000000000000000000000000000000000000000000000181026000000000000000000000000000000000000000000000000000000000018102700000000000000000000000000000000000000000000000000000000001810280000000000000000000000000000000000000000000000000000000000181029000000000000000000000000000000000000000000000000000000000018102a000000000000000000000000000000000000000000000000000000000018102b000000000000000000000000000000000000000000000000000000000018102c000000000000000000000000000000000000000000000000000000000018102d000000000000000000000000000000000000000000000000000000000018102e000000000000000000000000000000000000000000000000000000000018102f0000000000000000000000000000000000000000000000000000000000181030000000000000000000000000000000000000000000000000000000000018103100000000000000000000000000000000000000000000000000000000001810320000000000000000000000000000000000000000000000000000000000181033000000000000000000000000000000000000000000000000000000000018103400000000000000000000000000000000000000000000000000000000001810350000000000000000000000000000000000000000000000000000000000181036000000000000000000000000000000000000000000000000000000000018103700000000000000000000000000000000000000000000000000000000001810380000000000000000000000000000000000000000000000000000000000181039000000000000000000000000000000000000000000000000000000000018103a000000000000000000000000000000000000000000000000000000000018103b000000000000000000000000000000000000000000000000000000000018103c000000000000000000000000000000000000000000000000000000000018103d000000000000000000000000000000000000000000000000000000000018103e000000000000000000000000000000000000000000000000000000000018103f3f0000000000000000000000000000000000000000000000000000000000181100000000000000000000000000000000000000000000000000000000000018110100000000000000000000000000000000000000000000000000000000001811020000000000000000000000000000000000000000000000000000000000181103000000000000000000000000000000000000000000000000000000000018110400000000000000000000000000000000000000000000000000000000001811050000000000000000000000000000000000000000000000000000000000181106000000000000000000000000000000000000000000000000000000000018110700000000000000000000000000000000000000000000000000000000001811080000000000000000000000000000000000000000000000000000000000181109000000000000000000000000000000000000000000000000000000000018110a000000000000000000000000000000000000000000000000000000000018110b000000000000000000000000000000000000000000000000000000000018110c000000000000000000000000000000000000000000000000000000000018110d000000000000000000000000000000000000000000000000000000000018110e000000000000000000000000000000000000000000000000000000000018110f0000000000000000000000000000000000000000000000000000000000181110000000000000000000000000000000000000000000000000000000000018111100000000000000000000000000000000000000000000000000000000001811120000000000000000000000000000000000000000000000000000000000181113000000000000000000000000000000000000000000000000000000000018111400000000000000000000000000000000000000000000000000000000001811150000000000000000000000000000000000000000000000000000000000181116000000000000000000000000000000000000000000000000000000000018111700000000000000000000000000000000000000000000000000000000001811180000000000000000000000000000000000000000000000000000000000181119000000000000000000000000000000000000000000000000000000000018111a000000000000000000000000000000000000000000000000000000000018111b000000000000000000000000000000000000000000000000000000000018111c000000000000000000000000000000000000000000000000000000000018111d000000000000000000000000000000000000000000000000000000000018111e000000000000000000000000000000000000000000000000000000000018111f0000000000000000000000000000000000000000000000000000000000181120000000000000000000000000000000000000000000000000000000000018112100000000000000000000000000000000000000000000000000000000001811220000000000000000000000000000000000000000000000000000000000181123000000000000000000000000000000000000000000000000000000000018112400000000000000000000000000000000000000000000000000000000001811250000000000000000000000000000000000000000000000000000000000181126000000000000000000000000000000000000000000000000000000000018112700000000000000000000000000000000000000000000000000000000001811280000000000000000000000000000000000000000000000000000000000181129000000000000000000000000000000000000000000000000000000000018112a000000000000000000000000000000000000000000000000000000000018112b000000000000000000000000000000000000000000000000000000000018112c000000000000000000000000000000000000000000000000000000000018112d000000000000000000000000000000000000000000000000000000000018112e000000000000000000000000000000000000000000000000000000000018112f0000000000000000000000000000000000000000000000000000000000181130000000000000000000000000000000000000000000000000000000000018113100000000000000000000000000000000000000000000000000000000001811320000000000000000000000000000000000000000000000000000000000181133000000000000000000000000000000000000000000000000000000000018113400000000000000000000000000000000000000000000000000000000001811350000000000000000000000000000000000000000000000000000000000181136000000000000000000000000000000000000000000000000000000000018113700000000000000000000000000000000000000000000000000000000001811380000000000000000000000000000000000000000000000000000000000181139000000000000000000000000000000000000000000000000000000000018113a000000000000000000000000000000000000000000000000000000000018113b000000000000000000000000000000000000000000000000000000000018113c000000000000000000000000000000000000000000000000000000000018113d000000000000000000000000000000000000000000000000000000000018113e0800f872eb9653f03af10f331da1361fa1524d3cd958cb72dacea1d424f19df3af00ffc548a17cd6ba1f2d228f30e4ddb19ecc46ad3b609977d52bb0f49e1206410032f8058bd779c520eabae2743b02ec4f71670428506fcceb2d4b69f26fb11800c0283e15fbf74ffa4eafb984030394f3c2ea6733cc0eacb0431a9475eff28f00b7f55314bfd9d441c1c624e241908228fe4da3d3a0a7fbd56814e1c8cd5d3e00f430f33a786675271736fd728c7bf7428b8c24ac948d7faf76ddb8783a496c0048fc235ead8d4b9d44929662a6384074fc4e5076bec5b7deb34f612393684300fd9b61cb1ad9b4b28f58399906e73933e3cccee8fc98a393f0eedb95b13ee63f0000000000000000000000000000000000000000000000000000000000182000000000000000000000000000000000000000000000000000000000000018200a0000000000000000000000000000000000000000000000000000000000182001000000000000000000000000000000000000000000000000000000000018200b0000000000000000000000000000000000000000000000000000000000182002000000000000000000000000000000000000000000000000000000000018200c0000000000000000000000000000000000000000000000000000000000182003000000000000000000000000000000000000000000000000000000000018200d0000000000000000000000000000000000000000000000000000000000182004000000000000000000000000000000000000000000000000000000000018200e0000000000000000000000000000000000000000000000000000000000182005000000000000000000000000000000000000000000000000000000000018200f00000000000000000000000000000000000000000000000000000000001820060000000000000000000000000000000000000000000000000000000000182010000000000000000000000000000000000000000000000000000000000018200700000000000000000000000000000000000000000000000000000000001820110000000000000000000000000000000000000000000000000000000000182008000000000000000000000000000000000000000000000000000000000018201200000000000000000000000000000000000000000000000000000000001820090000000000000000000000000000000000000000000000000000000000182013000000000000000000000000000000000000000000000000000000000018200a0000000000000000000000000000000000000000000000000000000000182014000000000000000000000000000000000000000000000000000000000018200b0000000000000000000000000000000000000000000000000000000000182015000000000000000000000000000000000000000000000000000000000018200c0000000000000000000000000000000000000000000000000000000000182016000000000000000000000000000000000000000000000000000000000018200d0000000000000000000000000000000000000000000000000000000000182017000000000000000000000000000000000000000000000000000000000018200e0000000000000000000000000000000000000000000000000000000000182018000000000000000000000000000000000000000000000000000000000018200f00000000000000000000000000000000000000000000000000000000001820190000000000000000000000000000000000000000000000000000000000182010000000000000000000000000000000000000000000000000000000000018201a0000000000000000000000000000000000000000000000000000000000182011000000000000000000000000000000000000000000000000000000000018201b0000000000000000000000000000000000000000000000000000000000182012000000000000000000000000000000000000000000000000000000000018201c0000000000000000000000000000000000000000000000000000000000182013000000000000000000000000000000000000000000000000000000000018201d0000000000000000000000000000000000000000000000000000000000182014000000000000000000000000000000000000000000000000000000000018201e0000000000000000000000000000000000000000000000000000000000182015000000000000000000000000000000000000000000000000000000000018201f00000000000000000000000000000000000000000000000000000000001820160000000000000000000000000000000000000000000000000000000000182020000000000000000000000000000000000000000000000000000000000018201700000000000000000000000000000000000000000000000000000000001820210000000000000000000000000000000000000000000000000000000000182018000000000000000000000000000000000000000000000000000000000018202200000000000000000000000000000000000000000000000000000000001820190000000000000000000000000000000000000000000000000000000000182023000000000000000000000000000000000000000000000000000000000018201a0000000000000000000000000000000000000000000000000000000000182024000000000000000000000000000000000000000000000000000000000018201b0000000000000000000000000000000000000000000000000000000000182025000000000000000000000000000000000000000000000000000000000018201c0000000000000000000000000000000000000000000000000000000000182026000000000000000000000000000000000000000000000000000000000018201d0000000000000000000000000000000000000000000000000000000000182027000000000000000000000000000000000000000000000000000000000018201e0000000000000000000000000000000000000000000000000000000000182028000000000000000000000000000000000000000000000000000000000018201f00000000000000000000000000000000000000000000000000000000001820290000000000000000000000000000000000000000000000000000000000182020000000000000000000000000000000000000000000000000000000000018202a0000000000000000000000000000000000000000000000000000000000182021000000000000000000000000000000000000000000000000000000000018202b0000000000000000000000000000000000000000000000000000000000182022000000000000000000000000000000000000000000000000000000000018202c0000000000000000000000000000000000000000000000000000000000182023000000000000000000000000000000000000000000000000000000000018202d0000000000000000000000000000000000000000000000000000000000182024000000000000000000000000000000000000000000000000000000000018202e0000000000000000000000000000000000000000000000000000000000182025000000000000000000000000000000000000000000000000000000000018202f00000000000000000000000000000000000000000000000000000000001820260000000000000000000000000000000000000000000000000000000000182030000000000000000000000000000000000000000000000000000000000018202700000000000000000000000000000000000000000000000000000000001820310000000000000000000000000000000000000000000000000000000000182028000000000000000000000000000000000000000000000000000000000018203200000000000000000000000000000000000000000000000000000000001820290000000000000000000000000000000000000000000000000000000000182033000000000000000000000000000000000000000000000000000000000018202a0000000000000000000000000000000000000000000000000000000000182034000000000000000000000000000000000000000000000000000000000018202b0000000000000000000000000000000000000000000000000000000000182035000000000000000000000000000000000000000000000000000000000018202c0000000000000000000000000000000000000000000000000000000000182036000000000000000000000000000000000000000000000000000000000018202d0000000000000000000000000000000000000000000000000000000000182037000000000000000000000000000000000000000000000000000000000018202e0000000000000000000000000000000000000000000000000000000000182038000000000000000000000000000000000000000000000000000000000018202f00000000000000000000000000000000000000000000000000000000001820390000000000000000000000000000000000000000000000000000000000182030000000000000000000000000000000000000000000000000000000000018203a0000000000000000000000000000000000000000000000000000000000182031000000000000000000000000000000000000000000000000000000000018203b0000000000000000000000000000000000000000000000000000000000182032000000000000000000000000000000000000000000000000000000000018203c0000000000000000000000000000000000000000000000000000000000182033000000000000000000000000000000000000000000000000000000000018203d0000000000000000000000000000000000000000000000000000000000182034000000000000000000000000000000000000000000000000000000000018203e0000000000000000000000000000000000000000000000000000000000182035000000000000000000000000000000000000000000000000000000000018203f00000000000000000000000000000000000000000000000000000000001820360000000000000000000000000000000000000000000000000000000000182040000000000000000000000000000000000000000000000000000000000018203700000000000000000000000000000000000000000000000000000000001820410000000000000000000000000000000000000000000000000000000000182038000000000000000000000000000000000000000000000000000000000018204200000000000000000000000000000000000000000000000000000000001820390000000000000000000000000000000000000000000000000000000000182043000000000000000000000000000000000000000000000000000000000018203a0000000000000000000000000000000000000000000000000000000000182044000000000000000000000000000000000000000000000000000000000018203b0000000000000000000000000000000000000000000000000000000000182045000000000000000000000000000000000000000000000000000000000018203c0000000000000000000000000000000000000000000000000000000000182046000000000000000000000000000000000000000000000000000000000018203d0000000000000000000000000000000000000000000000000000000000182047000000000000000000000000000000000000000000000000000000000018203e00000000000000000000000000000000000000000000000000000000001820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000001c100000000000000000000000000000000000000000000000000000000000001c100100000000000000000000000000000000000000000000000000000000001c100200000000000000000000000000000000000000000000000000000000001c100300000000000000000000000000000000000000000000000000000000001c100400000000000000000000000000000000000000000000000000000000001c100500000000000000000000000000000000000000000000000000000000001c100600000000000000000000000000000000000000000000000000000000001c100700000000000000000000000000000000000000000000000000000000001c100800000000000000000000000000000000000000000000000000000000001c100900000000000000000000000000000000000000000000000000000000001c100a00000000000000000000000000000000000000000000000000000000001c100b00000000000000000000000000000000000000000000000000000000001c100c00000000000000000000000000000000000000000000000000000000001c100d00000000000000000000000000000000000000000000000000000000001c100e00000000000000000000000000000000000000000000000000000000001c100f00000000000000000000000000000000000000000000000000000000001c101000000000000000000000000000000000000000000000000000000000001c101100000000000000000000000000000000000000000000000000000000001c101200000000000000000000000000000000000000000000000000000000001c101300000000000000000000000000000000000000000000000000000000001c101400000000000000000000000000000000000000000000000000000000001c101500000000000000000000000000000000000000000000000000000000001c101600000000000000000000000000000000000000000000000000000000001c101700000000000000000000000000000000000000000000000000000000001c101800000000000000000000000000000000000000000000000000000000001c101900000000000000000000000000000000000000000000000000000000001c101a00000000000000000000000000000000000000000000000000000000001c101b00000000000000000000000000000000000000000000000000000000001c101c00000000000000000000000000000000000000000000000000000000001c101d00000000000000000000000000000000000000000000000000000000001c101e00000000000000000000000000000000000000000000000000000000001c101f00000000000000000000000000000000000000000000000000000000001c102000000000000000000000000000000000000000000000000000000000001c102100000000000000000000000000000000000000000000000000000000001c102200000000000000000000000000000000000000000000000000000000001c102300000000000000000000000000000000000000000000000000000000001c102400000000000000000000000000000000000000000000000000000000001c102500000000000000000000000000000000000000000000000000000000001c102600000000000000000000000000000000000000000000000000000000001c102700000000000000000000000000000000000000000000000000000000001c102800000000000000000000000000000000000000000000000000000000001c102900000000000000000000000000000000000000000000000000000000001c102a00000000000000000000000000000000000000000000000000000000001c102b00000000000000000000000000000000000000000000000000000000001c102c00000000000000000000000000000000000000000000000000000000001c102d00000000000000000000000000000000000000000000000000000000001c102e00000000000000000000000000000000000000000000000000000000001c102f00000000000000000000000000000000000000000000000000000000001c103000000000000000000000000000000000000000000000000000000000001c103100000000000000000000000000000000000000000000000000000000001c103200000000000000000000000000000000000000000000000000000000001c103300000000000000000000000000000000000000000000000000000000001c103400000000000000000000000000000000000000000000000000000000001c103500000000000000000000000000000000000000000000000000000000001c103600000000000000000000000000000000000000000000000000000000001c103700000000000000000000000000000000000000000000000000000000001c103800000000000000000000000000000000000000000000000000000000001c103900000000000000000000000000000000000000000000000000000000001c103a00000000000000000000000000000000000000000000000000000000001c103b00000000000000000000000000000000000000000000000000000000001c103c00000000000000000000000000000000000000000000000000000000001c103d00000000000000000000000000000000000000000000000000000000001c103e00000000000000000000000000000000000000000000000000000000001c103f3f00000000000000000000000000000000000000000000000000000000001c110000000000000000000000000000000000000000000000000000000000001c110100000000000000000000000000000000000000000000000000000000001c110200000000000000000000000000000000000000000000000000000000001c110300000000000000000000000000000000000000000000000000000000001c110400000000000000000000000000000000000000000000000000000000001c110500000000000000000000000000000000000000000000000000000000001c110600000000000000000000000000000000000000000000000000000000001c110700000000000000000000000000000000000000000000000000000000001c110800000000000000000000000000000000000000000000000000000000001c110900000000000000000000000000000000000000000000000000000000001c110a00000000000000000000000000000000000000000000000000000000001c110b00000000000000000000000000000000000000000000000000000000001c110c00000000000000000000000000000000000000000000000000000000001c110d00000000000000000000000000000000000000000000000000000000001c110e00000000000000000000000000000000000000000000000000000000001c110f00000000000000000000000000000000000000000000000000000000001c111000000000000000000000000000000000000000000000000000000000001c111100000000000000000000000000000000000000000000000000000000001c111200000000000000000000000000000000000000000000000000000000001c111300000000000000000000000000000000000000000000000000000000001c111400000000000000000000000000000000000000000000000000000000001c111500000000000000000000000000000000000000000000000000000000001c111600000000000000000000000000000000000000000000000000000000001c111700000000000000000000000000000000000000000000000000000000001c111800000000000000000000000000000000000000000000000000000000001c111900000000000000000000000000000000000000000000000000000000001c111a00000000000000000000000000000000000000000000000000000000001c111b00000000000000000000000000000000000000000000000000000000001c111c00000000000000000000000000000000000000000000000000000000001c111d00000000000000000000000000000000000000000000000000000000001c111e00000000000000000000000000000000000000000000000000000000001c111f00000000000000000000000000000000000000000000000000000000001c112000000000000000000000000000000000000000000000000000000000001c112100000000000000000000000000000000000000000000000000000000001c112200000000000000000000000000000000000000000000000000000000001c112300000000000000000000000000000000000000000000000000000000001c112400000000000000000000000000000000000000000000000000000000001c112500000000000000000000000000000000000000000000000000000000001c112600000000000000000000000000000000000000000000000000000000001c112700000000000000000000000000000000000000000000000000000000001c112800000000000000000000000000000000000000000000000000000000001c112900000000000000000000000000000000000000000000000000000000001c112a00000000000000000000000000000000000000000000000000000000001c112b00000000000000000000000000000000000000000000000000000000001c112c00000000000000000000000000000000000000000000000000000000001c112d00000000000000000000000000000000000000000000000000000000001c112e00000000000000000000000000000000000000000000000000000000001c112f00000000000000000000000000000000000000000000000000000000001c113000000000000000000000000000000000000000000000000000000000001c113100000000000000000000000000000000000000000000000000000000001c113200000000000000000000000000000000000000000000000000000000001c113300000000000000000000000000000000000000000000000000000000001c113400000000000000000000000000000000000000000000000000000000001c113500000000000000000000000000000000000000000000000000000000001c113600000000000000000000000000000000000000000000000000000000001c113700000000000000000000000000000000000000000000000000000000001c113800000000000000000000000000000000000000000000000000000000001c113900000000000000000000000000000000000000000000000000000000001c113a00000000000000000000000000000000000000000000000000000000001c113b00000000000000000000000000000000000000000000000000000000001c113c00000000000000000000000000000000000000000000000000000000001c113d00000000000000000000000000000000000000000000000000000000001c113e08006838aa99533bea0d4204cad17cb3c147e99c2f9089e54a4289d54733eeada2002ab314bd11ace2494a3fb0970d276da39f0fe7da19c9a2438b9c7c334d32470071703d79d8425a7eca52006df6a8f9728508a83639e3e1c2ebae2b853a087c00c9501ac04a78ac5413c9131b08708064ed2c2515b8893f12c2d1cda15a44f100a0955f93e109778d26f9e5b0d46e45c539e59b0941517bfa888eb2d7d2d8a6005adc3be9406cc5f102c6adb44746e8529a256e2396353a8659344cc3e914c4007a5fe572cf6af804f472dabf095c5eb6b30efc5fd627ad3245a8ef0f3f578c003dcaa91dfc9fdad7ba8da68a48fc662dfc0a995cbb0c1bc62099c8257d240d3f00000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000001c200a00000000000000000000000000000000000000000000000000000000001c200100000000000000000000000000000000000000000000000000000000001c200b00000000000000000000000000000000000000000000000000000000001c200200000000000000000000000000000000000000000000000000000000001c200c00000000000000000000000000000000000000000000000000000000001c200300000000000000000000000000000000000000000000000000000000001c200d00000000000000000000000000000000000000000000000000000000001c200400000000000000000000000000000000000000000000000000000000001c200e00000000000000000000000000000000000000000000000000000000001c200500000000000000000000000000000000000000000000000000000000001c200f00000000000000000000000000000000000000000000000000000000001c200600000000000000000000000000000000000000000000000000000000001c201000000000000000000000000000000000000000000000000000000000001c200700000000000000000000000000000000000000000000000000000000001c201100000000000000000000000000000000000000000000000000000000001c200800000000000000000000000000000000000000000000000000000000001c201200000000000000000000000000000000000000000000000000000000001c200900000000000000000000000000000000000000000000000000000000001c201300000000000000000000000000000000000000000000000000000000001c200a00000000000000000000000000000000000000000000000000000000001c201400000000000000000000000000000000000000000000000000000000001c200b00000000000000000000000000000000000000000000000000000000001c201500000000000000000000000000000000000000000000000000000000001c200c00000000000000000000000000000000000000000000000000000000001c201600000000000000000000000000000000000000000000000000000000001c200d00000000000000000000000000000000000000000000000000000000001c201700000000000000000000000000000000000000000000000000000000001c200e00000000000000000000000000000000000000000000000000000000001c201800000000000000000000000000000000000000000000000000000000001c200f00000000000000000000000000000000000000000000000000000000001c201900000000000000000000000000000000000000000000000000000000001c201000000000000000000000000000000000000000000000000000000000001c201a00000000000000000000000000000000000000000000000000000000001c201100000000000000000000000000000000000000000000000000000000001c201b00000000000000000000000000000000000000000000000000000000001c201200000000000000000000000000000000000000000000000000000000001c201c00000000000000000000000000000000000000000000000000000000001c201300000000000000000000000000000000000000000000000000000000001c201d00000000000000000000000000000000000000000000000000000000001c201400000000000000000000000000000000000000000000000000000000001c201e00000000000000000000000000000000000000000000000000000000001c201500000000000000000000000000000000000000000000000000000000001c201f00000000000000000000000000000000000000000000000000000000001c201600000000000000000000000000000000000000000000000000000000001c202000000000000000000000000000000000000000000000000000000000001c201700000000000000000000000000000000000000000000000000000000001c202100000000000000000000000000000000000000000000000000000000001c201800000000000000000000000000000000000000000000000000000000001c202200000000000000000000000000000000000000000000000000000000001c201900000000000000000000000000000000000000000000000000000000001c202300000000000000000000000000000000000000000000000000000000001c201a00000000000000000000000000000000000000000000000000000000001c202400000000000000000000000000000000000000000000000000000000001c201b00000000000000000000000000000000000000000000000000000000001c202500000000000000000000000000000000000000000000000000000000001c201c00000000000000000000000000000000000000000000000000000000001c202600000000000000000000000000000000000000000000000000000000001c201d00000000000000000000000000000000000000000000000000000000001c202700000000000000000000000000000000000000000000000000000000001c201e00000000000000000000000000000000000000000000000000000000001c202800000000000000000000000000000000000000000000000000000000001c201f00000000000000000000000000000000000000000000000000000000001c202900000000000000000000000000000000000000000000000000000000001c202000000000000000000000000000000000000000000000000000000000001c202a00000000000000000000000000000000000000000000000000000000001c202100000000000000000000000000000000000000000000000000000000001c202b00000000000000000000000000000000000000000000000000000000001c202200000000000000000000000000000000000000000000000000000000001c202c00000000000000000000000000000000000000000000000000000000001c202300000000000000000000000000000000000000000000000000000000001c202d00000000000000000000000000000000000000000000000000000000001c202400000000000000000000000000000000000000000000000000000000001c202e00000000000000000000000000000000000000000000000000000000001c202500000000000000000000000000000000000000000000000000000000001c202f00000000000000000000000000000000000000000000000000000000001c202600000000000000000000000000000000000000000000000000000000001c203000000000000000000000000000000000000000000000000000000000001c202700000000000000000000000000000000000000000000000000000000001c203100000000000000000000000000000000000000000000000000000000001c202800000000000000000000000000000000000000000000000000000000001c203200000000000000000000000000000000000000000000000000000000001c202900000000000000000000000000000000000000000000000000000000001c203300000000000000000000000000000000000000000000000000000000001c202a00000000000000000000000000000000000000000000000000000000001c203400000000000000000000000000000000000000000000000000000000001c202b00000000000000000000000000000000000000000000000000000000001c203500000000000000000000000000000000000000000000000000000000001c202c00000000000000000000000000000000000000000000000000000000001c203600000000000000000000000000000000000000000000000000000000001c202d00000000000000000000000000000000000000000000000000000000001c203700000000000000000000000000000000000000000000000000000000001c202e00000000000000000000000000000000000000000000000000000000001c203800000000000000000000000000000000000000000000000000000000001c202f00000000000000000000000000000000000000000000000000000000001c203900000000000000000000000000000000000000000000000000000000001c203000000000000000000000000000000000000000000000000000000000001c203a00000000000000000000000000000000000000000000000000000000001c203100000000000000000000000000000000000000000000000000000000001c203b00000000000000000000000000000000000000000000000000000000001c203200000000000000000000000000000000000000000000000000000000001c203c00000000000000000000000000000000000000000000000000000000001c203300000000000000000000000000000000000000000000000000000000001c203d00000000000000000000000000000000000000000000000000000000001c203400000000000000000000000000000000000000000000000000000000001c203e00000000000000000000000000000000000000000000000000000000001c203500000000000000000000000000000000000000000000000000000000001c203f00000000000000000000000000000000000000000000000000000000001c203600000000000000000000000000000000000000000000000000000000001c204000000000000000000000000000000000000000000000000000000000001c203700000000000000000000000000000000000000000000000000000000001c204100000000000000000000000000000000000000000000000000000000001c203800000000000000000000000000000000000000000000000000000000001c204200000000000000000000000000000000000000000000000000000000001c203900000000000000000000000000000000000000000000000000000000001c204300000000000000000000000000000000000000000000000000000000001c203a00000000000000000000000000000000000000000000000000000000001c204400000000000000000000000000000000000000000000000000000000001c203b00000000000000000000000000000000000000000000000000000000001c204500000000000000000000000000000000000000000000000000000000001c203c00000000000000000000000000000000000000000000000000000000001c204600000000000000000000000000000000000000000000000000000000001c203d00000000000000000000000000000000000000000000000000000000001c204700000000000000000000000000000000000000000000000000000000001c203e00000000000000000000000000000000000000000000000000000000001c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000201000000000000000000000000000000000000000000000000000000000000020100100000000000000000000000000000000000000000000000000000000002010020000000000000000000000000000000000000000000000000000000000201003000000000000000000000000000000000000000000000000000000000020100400000000000000000000000000000000000000000000000000000000002010050000000000000000000000000000000000000000000000000000000000201006000000000000000000000000000000000000000000000000000000000020100700000000000000000000000000000000000000000000000000000000002010080000000000000000000000000000000000000000000000000000000000201009000000000000000000000000000000000000000000000000000000000020100a000000000000000000000000000000000000000000000000000000000020100b000000000000000000000000000000000000000000000000000000000020100c000000000000000000000000000000000000000000000000000000000020100d000000000000000000000000000000000000000000000000000000000020100e000000000000000000000000000000000000000000000000000000000020100f0000000000000000000000000000000000000000000000000000000000201010000000000000000000000000000000000000000000000000000000000020101100000000000000000000000000000000000000000000000000000000002010120000000000000000000000000000000000000000000000000000000000201013000000000000000000000000000000000000000000000000000000000020101400000000000000000000000000000000000000000000000000000000002010150000000000000000000000000000000000000000000000000000000000201016000000000000000000000000000000000000000000000000000000000020101700000000000000000000000000000000000000000000000000000000002010180000000000000000000000000000000000000000000000000000000000201019000000000000000000000000000000000000000000000000000000000020101a000000000000000000000000000000000000000000000000000000000020101b000000000000000000000000000000000000000000000000000000000020101c000000000000000000000000000000000000000000000000000000000020101d000000000000000000000000000000000000000000000000000000000020101e000000000000000000000000000000000000000000000000000000000020101f0000000000000000000000000000000000000000000000000000000000201020000000000000000000000000000000000000000000000000000000000020102100000000000000000000000000000000000000000000000000000000002010220000000000000000000000000000000000000000000000000000000000201023000000000000000000000000000000000000000000000000000000000020102400000000000000000000000000000000000000000000000000000000002010250000000000000000000000000000000000000000000000000000000000201026000000000000000000000000000000000000000000000000000000000020102700000000000000000000000000000000000000000000000000000000002010280000000000000000000000000000000000000000000000000000000000201029000000000000000000000000000000000000000000000000000000000020102a000000000000000000000000000000000000000000000000000000000020102b000000000000000000000000000000000000000000000000000000000020102c000000000000000000000000000000000000000000000000000000000020102d000000000000000000000000000000000000000000000000000000000020102e000000000000000000000000000000000000000000000000000000000020102f0000000000000000000000000000000000000000000000000000000000201030000000000000000000000000000000000000000000000000000000000020103100000000000000000000000000000000000000000000000000000000002010320000000000000000000000000000000000000000000000000000000000201033000000000000000000000000000000000000000000000000000000000020103400000000000000000000000000000000000000000000000000000000002010350000000000000000000000000000000000000000000000000000000000201036000000000000000000000000000000000000000000000000000000000020103700000000000000000000000000000000000000000000000000000000002010380000000000000000000000000000000000000000000000000000000000201039000000000000000000000000000000000000000000000000000000000020103a000000000000000000000000000000000000000000000000000000000020103b000000000000000000000000000000000000000000000000000000000020103c000000000000000000000000000000000000000000000000000000000020103d000000000000000000000000000000000000000000000000000000000020103e000000000000000000000000000000000000000000000000000000000020103f3f0000000000000000000000000000000000000000000000000000000000201100000000000000000000000000000000000000000000000000000000000020110100000000000000000000000000000000000000000000000000000000002011020000000000000000000000000000000000000000000000000000000000201103000000000000000000000000000000000000000000000000000000000020110400000000000000000000000000000000000000000000000000000000002011050000000000000000000000000000000000000000000000000000000000201106000000000000000000000000000000000000000000000000000000000020110700000000000000000000000000000000000000000000000000000000002011080000000000000000000000000000000000000000000000000000000000201109000000000000000000000000000000000000000000000000000000000020110a000000000000000000000000000000000000000000000000000000000020110b000000000000000000000000000000000000000000000000000000000020110c000000000000000000000000000000000000000000000000000000000020110d000000000000000000000000000000000000000000000000000000000020110e000000000000000000000000000000000000000000000000000000000020110f0000000000000000000000000000000000000000000000000000000000201110000000000000000000000000000000000000000000000000000000000020111100000000000000000000000000000000000000000000000000000000002011120000000000000000000000000000000000000000000000000000000000201113000000000000000000000000000000000000000000000000000000000020111400000000000000000000000000000000000000000000000000000000002011150000000000000000000000000000000000000000000000000000000000201116000000000000000000000000000000000000000000000000000000000020111700000000000000000000000000000000000000000000000000000000002011180000000000000000000000000000000000000000000000000000000000201119000000000000000000000000000000000000000000000000000000000020111a000000000000000000000000000000000000000000000000000000000020111b000000000000000000000000000000000000000000000000000000000020111c000000000000000000000000000000000000000000000000000000000020111d000000000000000000000000000000000000000000000000000000000020111e000000000000000000000000000000000000000000000000000000000020111f0000000000000000000000000000000000000000000000000000000000201120000000000000000000000000000000000000000000000000000000000020112100000000000000000000000000000000000000000000000000000000002011220000000000000000000000000000000000000000000000000000000000201123000000000000000000000000000000000000000000000000000000000020112400000000000000000000000000000000000000000000000000000000002011250000000000000000000000000000000000000000000000000000000000201126000000000000000000000000000000000000000000000000000000000020112700000000000000000000000000000000000000000000000000000000002011280000000000000000000000000000000000000000000000000000000000201129000000000000000000000000000000000000000000000000000000000020112a000000000000000000000000000000000000000000000000000000000020112b000000000000000000000000000000000000000000000000000000000020112c000000000000000000000000000000000000000000000000000000000020112d000000000000000000000000000000000000000000000000000000000020112e000000000000000000000000000000000000000000000000000000000020112f0000000000000000000000000000000000000000000000000000000000201130000000000000000000000000000000000000000000000000000000000020113100000000000000000000000000000000000000000000000000000000002011320000000000000000000000000000000000000000000000000000000000201133000000000000000000000000000000000000000000000000000000000020113400000000000000000000000000000000000000000000000000000000002011350000000000000000000000000000000000000000000000000000000000201136000000000000000000000000000000000000000000000000000000000020113700000000000000000000000000000000000000000000000000000000002011380000000000000000000000000000000000000000000000000000000000201139000000000000000000000000000000000000000000000000000000000020113a000000000000000000000000000000000000000000000000000000000020113b000000000000000000000000000000000000000000000000000000000020113c000000000000000000000000000000000000000000000000000000000020113d000000000000000000000000000000000000000000000000000000000020113e0800e9805e8a4faa87fc419af08a6d956f18976c46ea694bbd4cf6946e6d02033200e0925a6b172b4b01bb76eb1d3f7dd2ced118bca70d223a6d61afa1b75915ae00383590492d2f99a0283d1de57015b4b6b0759a8023af2c68fb4929dee2f303007ed57100dd77e2b6405f780503ef61b7b53e13f344b6e6a6eff3e3c13de0d0001ab1b0c348c46184dbc86ff79f248e7da1b09d3f9c6a986e98fe45389f060d0023d134bc68d7efa25e255001069827dc0bee766c08c988d6300071ed27fe6c0031cbb780b07f632cbaf767dc80608cc0a8e1d1df3ecd6f5d8bc0ca6703e4f4002c7dc9e731fc5f6456b2a70b4e636ac17d5e0cd36d3a591116a9e124f735863f0000000000000000000000000000000000000000000000000000000000202000000000000000000000000000000000000000000000000000000000000020200a0000000000000000000000000000000000000000000000000000000000202001000000000000000000000000000000000000000000000000000000000020200b0000000000000000000000000000000000000000000000000000000000202002000000000000000000000000000000000000000000000000000000000020200c0000000000000000000000000000000000000000000000000000000000202003000000000000000000000000000000000000000000000000000000000020200d0000000000000000000000000000000000000000000000000000000000202004000000000000000000000000000000000000000000000000000000000020200e0000000000000000000000000000000000000000000000000000000000202005000000000000000000000000000000000000000000000000000000000020200f00000000000000000000000000000000000000000000000000000000002020060000000000000000000000000000000000000000000000000000000000202010000000000000000000000000000000000000000000000000000000000020200700000000000000000000000000000000000000000000000000000000002020110000000000000000000000000000000000000000000000000000000000202008000000000000000000000000000000000000000000000000000000000020201200000000000000000000000000000000000000000000000000000000002020090000000000000000000000000000000000000000000000000000000000202013000000000000000000000000000000000000000000000000000000000020200a0000000000000000000000000000000000000000000000000000000000202014000000000000000000000000000000000000000000000000000000000020200b0000000000000000000000000000000000000000000000000000000000202015000000000000000000000000000000000000000000000000000000000020200c0000000000000000000000000000000000000000000000000000000000202016000000000000000000000000000000000000000000000000000000000020200d0000000000000000000000000000000000000000000000000000000000202017000000000000000000000000000000000000000000000000000000000020200e0000000000000000000000000000000000000000000000000000000000202018000000000000000000000000000000000000000000000000000000000020200f00000000000000000000000000000000000000000000000000000000002020190000000000000000000000000000000000000000000000000000000000202010000000000000000000000000000000000000000000000000000000000020201a0000000000000000000000000000000000000000000000000000000000202011000000000000000000000000000000000000000000000000000000000020201b0000000000000000000000000000000000000000000000000000000000202012000000000000000000000000000000000000000000000000000000000020201c0000000000000000000000000000000000000000000000000000000000202013000000000000000000000000000000000000000000000000000000000020201d0000000000000000000000000000000000000000000000000000000000202014000000000000000000000000000000000000000000000000000000000020201e0000000000000000000000000000000000000000000000000000000000202015000000000000000000000000000000000000000000000000000000000020201f00000000000000000000000000000000000000000000000000000000002020160000000000000000000000000000000000000000000000000000000000202020000000000000000000000000000000000000000000000000000000000020201700000000000000000000000000000000000000000000000000000000002020210000000000000000000000000000000000000000000000000000000000202018000000000000000000000000000000000000000000000000000000000020202200000000000000000000000000000000000000000000000000000000002020190000000000000000000000000000000000000000000000000000000000202023000000000000000000000000000000000000000000000000000000000020201a0000000000000000000000000000000000000000000000000000000000202024000000000000000000000000000000000000000000000000000000000020201b0000000000000000000000000000000000000000000000000000000000202025000000000000000000000000000000000000000000000000000000000020201c0000000000000000000000000000000000000000000000000000000000202026000000000000000000000000000000000000000000000000000000000020201d0000000000000000000000000000000000000000000000000000000000202027000000000000000000000000000000000000000000000000000000000020201e0000000000000000000000000000000000000000000000000000000000202028000000000000000000000000000000000000000000000000000000000020201f00000000000000000000000000000000000000000000000000000000002020290000000000000000000000000000000000000000000000000000000000202020000000000000000000000000000000000000000000000000000000000020202a0000000000000000000000000000000000000000000000000000000000202021000000000000000000000000000000000000000000000000000000000020202b0000000000000000000000000000000000000000000000000000000000202022000000000000000000000000000000000000000000000000000000000020202c0000000000000000000000000000000000000000000000000000000000202023000000000000000000000000000000000000000000000000000000000020202d0000000000000000000000000000000000000000000000000000000000202024000000000000000000000000000000000000000000000000000000000020202e0000000000000000000000000000000000000000000000000000000000202025000000000000000000000000000000000000000000000000000000000020202f00000000000000000000000000000000000000000000000000000000002020260000000000000000000000000000000000000000000000000000000000202030000000000000000000000000000000000000000000000000000000000020202700000000000000000000000000000000000000000000000000000000002020310000000000000000000000000000000000000000000000000000000000202028000000000000000000000000000000000000000000000000000000000020203200000000000000000000000000000000000000000000000000000000002020290000000000000000000000000000000000000000000000000000000000202033000000000000000000000000000000000000000000000000000000000020202a0000000000000000000000000000000000000000000000000000000000202034000000000000000000000000000000000000000000000000000000000020202b0000000000000000000000000000000000000000000000000000000000202035000000000000000000000000000000000000000000000000000000000020202c0000000000000000000000000000000000000000000000000000000000202036000000000000000000000000000000000000000000000000000000000020202d0000000000000000000000000000000000000000000000000000000000202037000000000000000000000000000000000000000000000000000000000020202e0000000000000000000000000000000000000000000000000000000000202038000000000000000000000000000000000000000000000000000000000020202f00000000000000000000000000000000000000000000000000000000002020390000000000000000000000000000000000000000000000000000000000202030000000000000000000000000000000000000000000000000000000000020203a0000000000000000000000000000000000000000000000000000000000202031000000000000000000000000000000000000000000000000000000000020203b0000000000000000000000000000000000000000000000000000000000202032000000000000000000000000000000000000000000000000000000000020203c0000000000000000000000000000000000000000000000000000000000202033000000000000000000000000000000000000000000000000000000000020203d0000000000000000000000000000000000000000000000000000000000202034000000000000000000000000000000000000000000000000000000000020203e0000000000000000000000000000000000000000000000000000000000202035000000000000000000000000000000000000000000000000000000000020203f00000000000000000000000000000000000000000000000000000000002020360000000000000000000000000000000000000000000000000000000000202040000000000000000000000000000000000000000000000000000000000020203700000000000000000000000000000000000000000000000000000000002020410000000000000000000000000000000000000000000000000000000000202038000000000000000000000000000000000000000000000000000000000020204200000000000000000000000000000000000000000000000000000000002020390000000000000000000000000000000000000000000000000000000000202043000000000000000000000000000000000000000000000000000000000020203a0000000000000000000000000000000000000000000000000000000000202044000000000000000000000000000000000000000000000000000000000020203b0000000000000000000000000000000000000000000000000000000000202045000000000000000000000000000000000000000000000000000000000020203c0000000000000000000000000000000000000000000000000000000000202046000000000000000000000000000000000000000000000000000000000020203d0000000000000000000000000000000000000000000000000000000000202047000000000000000000000000000000000000000000000000000000000020203e0000000000000000000000000000000000000000000000000000000000202048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "txsEffectsHash": "0x006355bc5a5a6353eca00eac5e4aede081b359a25bcf81604aacd84dd1947561", + "archive": "0x18d695c543b39ed4aebf51260b01cd023d27c36e90e2756413803fe06d376c70", + "blockHash": "0x1794217194decb456524466a01a7356e8b08b751ef0bc596431405c749627782", + "body": "0x00000008000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000004100100000000000000000000000000000000000000000000000000000000000410020000000000000000000000000000000000000000000000000000000000041003000000000000000000000000000000000000000000000000000000000004100400000000000000000000000000000000000000000000000000000000000410050000000000000000000000000000000000000000000000000000000000041006000000000000000000000000000000000000000000000000000000000004100700000000000000000000000000000000000000000000000000000000000410080000000000000000000000000000000000000000000000000000000000041009000000000000000000000000000000000000000000000000000000000004100a000000000000000000000000000000000000000000000000000000000004100b000000000000000000000000000000000000000000000000000000000004100c000000000000000000000000000000000000000000000000000000000004100d000000000000000000000000000000000000000000000000000000000004100e000000000000000000000000000000000000000000000000000000000004100f0000000000000000000000000000000000000000000000000000000000041010000000000000000000000000000000000000000000000000000000000004101100000000000000000000000000000000000000000000000000000000000410120000000000000000000000000000000000000000000000000000000000041013000000000000000000000000000000000000000000000000000000000004101400000000000000000000000000000000000000000000000000000000000410150000000000000000000000000000000000000000000000000000000000041016000000000000000000000000000000000000000000000000000000000004101700000000000000000000000000000000000000000000000000000000000410180000000000000000000000000000000000000000000000000000000000041019000000000000000000000000000000000000000000000000000000000004101a000000000000000000000000000000000000000000000000000000000004101b000000000000000000000000000000000000000000000000000000000004101c000000000000000000000000000000000000000000000000000000000004101d000000000000000000000000000000000000000000000000000000000004101e000000000000000000000000000000000000000000000000000000000004101f0000000000000000000000000000000000000000000000000000000000041020000000000000000000000000000000000000000000000000000000000004102100000000000000000000000000000000000000000000000000000000000410220000000000000000000000000000000000000000000000000000000000041023000000000000000000000000000000000000000000000000000000000004102400000000000000000000000000000000000000000000000000000000000410250000000000000000000000000000000000000000000000000000000000041026000000000000000000000000000000000000000000000000000000000004102700000000000000000000000000000000000000000000000000000000000410280000000000000000000000000000000000000000000000000000000000041029000000000000000000000000000000000000000000000000000000000004102a000000000000000000000000000000000000000000000000000000000004102b000000000000000000000000000000000000000000000000000000000004102c000000000000000000000000000000000000000000000000000000000004102d000000000000000000000000000000000000000000000000000000000004102e000000000000000000000000000000000000000000000000000000000004102f0000000000000000000000000000000000000000000000000000000000041030000000000000000000000000000000000000000000000000000000000004103100000000000000000000000000000000000000000000000000000000000410320000000000000000000000000000000000000000000000000000000000041033000000000000000000000000000000000000000000000000000000000004103400000000000000000000000000000000000000000000000000000000000410350000000000000000000000000000000000000000000000000000000000041036000000000000000000000000000000000000000000000000000000000004103700000000000000000000000000000000000000000000000000000000000410380000000000000000000000000000000000000000000000000000000000041039000000000000000000000000000000000000000000000000000000000004103a000000000000000000000000000000000000000000000000000000000004103b000000000000000000000000000000000000000000000000000000000004103c000000000000000000000000000000000000000000000000000000000004103d000000000000000000000000000000000000000000000000000000000004103e000000000000000000000000000000000000000000000000000000000004103f3f0000000000000000000000000000000000000000000000000000000000041100000000000000000000000000000000000000000000000000000000000004110100000000000000000000000000000000000000000000000000000000000411020000000000000000000000000000000000000000000000000000000000041103000000000000000000000000000000000000000000000000000000000004110400000000000000000000000000000000000000000000000000000000000411050000000000000000000000000000000000000000000000000000000000041106000000000000000000000000000000000000000000000000000000000004110700000000000000000000000000000000000000000000000000000000000411080000000000000000000000000000000000000000000000000000000000041109000000000000000000000000000000000000000000000000000000000004110a000000000000000000000000000000000000000000000000000000000004110b000000000000000000000000000000000000000000000000000000000004110c000000000000000000000000000000000000000000000000000000000004110d000000000000000000000000000000000000000000000000000000000004110e000000000000000000000000000000000000000000000000000000000004110f0000000000000000000000000000000000000000000000000000000000041110000000000000000000000000000000000000000000000000000000000004111100000000000000000000000000000000000000000000000000000000000411120000000000000000000000000000000000000000000000000000000000041113000000000000000000000000000000000000000000000000000000000004111400000000000000000000000000000000000000000000000000000000000411150000000000000000000000000000000000000000000000000000000000041116000000000000000000000000000000000000000000000000000000000004111700000000000000000000000000000000000000000000000000000000000411180000000000000000000000000000000000000000000000000000000000041119000000000000000000000000000000000000000000000000000000000004111a000000000000000000000000000000000000000000000000000000000004111b000000000000000000000000000000000000000000000000000000000004111c000000000000000000000000000000000000000000000000000000000004111d000000000000000000000000000000000000000000000000000000000004111e000000000000000000000000000000000000000000000000000000000004111f0000000000000000000000000000000000000000000000000000000000041120000000000000000000000000000000000000000000000000000000000004112100000000000000000000000000000000000000000000000000000000000411220000000000000000000000000000000000000000000000000000000000041123000000000000000000000000000000000000000000000000000000000004112400000000000000000000000000000000000000000000000000000000000411250000000000000000000000000000000000000000000000000000000000041126000000000000000000000000000000000000000000000000000000000004112700000000000000000000000000000000000000000000000000000000000411280000000000000000000000000000000000000000000000000000000000041129000000000000000000000000000000000000000000000000000000000004112a000000000000000000000000000000000000000000000000000000000004112b000000000000000000000000000000000000000000000000000000000004112c000000000000000000000000000000000000000000000000000000000004112d000000000000000000000000000000000000000000000000000000000004112e000000000000000000000000000000000000000000000000000000000004112f0000000000000000000000000000000000000000000000000000000000041130000000000000000000000000000000000000000000000000000000000004113100000000000000000000000000000000000000000000000000000000000411320000000000000000000000000000000000000000000000000000000000041133000000000000000000000000000000000000000000000000000000000004113400000000000000000000000000000000000000000000000000000000000411350000000000000000000000000000000000000000000000000000000000041136000000000000000000000000000000000000000000000000000000000004113700000000000000000000000000000000000000000000000000000000000411380000000000000000000000000000000000000000000000000000000000041139000000000000000000000000000000000000000000000000000000000004113a000000000000000000000000000000000000000000000000000000000004113b000000000000000000000000000000000000000000000000000000000004113c000000000000000000000000000000000000000000000000000000000004113d000000000000000000000000000000000000000000000000000000000004113e080097a6ec570e9b8e257647c9c74c5ad3edc57ca5ef6ae44d80b3c30d1d99b9b300ce48ec41d1edde0066fab553a456ae2f380d14fa8f956af1fb0217513a598900619ff12eaf97f63aa2a2311de3b6571a7b880a5247cb33b6a74787bf3f9bd5007854a2fad4e1801c6404394bf3d37ab08c135ea38a1974242e39a21273685f000f55796e72957a819e68a22e8602d73c3ba3718a5a4bd92b80b0aa444b182a00788b6e9874fb040ee679a7fae257190099a605229b948334e54a57739535d4004f1658ee3c1a91627e5d72f5a731f0796299df82ab41e72c88eee0c82fa85e003ee802add96628c693ed71afa9908138ba5a6fbf0a5f29a9c74e4e42aba6713f0000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042001000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042002000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042003000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042004000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042005000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420060000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004200700000000000000000000000000000000000000000000000000000000000420110000000000000000000000000000000000000000000000000000000000042008000000000000000000000000000000000000000000000000000000000004201200000000000000000000000000000000000000000000000000000000000420090000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004200a0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004200b0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004200c0000000000000000000000000000000000000000000000000000000000042016000000000000000000000000000000000000000000000000000000000004200d0000000000000000000000000000000000000000000000000000000000042017000000000000000000000000000000000000000000000000000000000004200e0000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004200f00000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042010000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042011000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042012000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042013000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042014000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042015000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420160000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004201700000000000000000000000000000000000000000000000000000000000420210000000000000000000000000000000000000000000000000000000000042018000000000000000000000000000000000000000000000000000000000004202200000000000000000000000000000000000000000000000000000000000420190000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004201a0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004201b0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004201c0000000000000000000000000000000000000000000000000000000000042026000000000000000000000000000000000000000000000000000000000004201d0000000000000000000000000000000000000000000000000000000000042027000000000000000000000000000000000000000000000000000000000004201e0000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004201f00000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042020000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042021000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042022000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042023000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042024000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042025000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420260000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004202700000000000000000000000000000000000000000000000000000000000420310000000000000000000000000000000000000000000000000000000000042028000000000000000000000000000000000000000000000000000000000004203200000000000000000000000000000000000000000000000000000000000420290000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004202a0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004202b0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004202c0000000000000000000000000000000000000000000000000000000000042036000000000000000000000000000000000000000000000000000000000004202d0000000000000000000000000000000000000000000000000000000000042037000000000000000000000000000000000000000000000000000000000004202e0000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004202f00000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042030000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042031000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042032000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042033000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042034000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042035000000000000000000000000000000000000000000000000000000000004203f00000000000000000000000000000000000000000000000000000000000420360000000000000000000000000000000000000000000000000000000000042040000000000000000000000000000000000000000000000000000000000004203700000000000000000000000000000000000000000000000000000000000420410000000000000000000000000000000000000000000000000000000000042038000000000000000000000000000000000000000000000000000000000004204200000000000000000000000000000000000000000000000000000000000420390000000000000000000000000000000000000000000000000000000000042043000000000000000000000000000000000000000000000000000000000004203a0000000000000000000000000000000000000000000000000000000000042044000000000000000000000000000000000000000000000000000000000004203b0000000000000000000000000000000000000000000000000000000000042045000000000000000000000000000000000000000000000000000000000004203c0000000000000000000000000000000000000000000000000000000000042046000000000000000000000000000000000000000000000000000000000004203d0000000000000000000000000000000000000000000000000000000000042047000000000000000000000000000000000000000000000000000000000004203e0000000000000000000000000000000000000000000000000000000000042048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000081000000000000000000000000000000000000000000000000000000000000008100100000000000000000000000000000000000000000000000000000000000810020000000000000000000000000000000000000000000000000000000000081003000000000000000000000000000000000000000000000000000000000008100400000000000000000000000000000000000000000000000000000000000810050000000000000000000000000000000000000000000000000000000000081006000000000000000000000000000000000000000000000000000000000008100700000000000000000000000000000000000000000000000000000000000810080000000000000000000000000000000000000000000000000000000000081009000000000000000000000000000000000000000000000000000000000008100a000000000000000000000000000000000000000000000000000000000008100b000000000000000000000000000000000000000000000000000000000008100c000000000000000000000000000000000000000000000000000000000008100d000000000000000000000000000000000000000000000000000000000008100e000000000000000000000000000000000000000000000000000000000008100f0000000000000000000000000000000000000000000000000000000000081010000000000000000000000000000000000000000000000000000000000008101100000000000000000000000000000000000000000000000000000000000810120000000000000000000000000000000000000000000000000000000000081013000000000000000000000000000000000000000000000000000000000008101400000000000000000000000000000000000000000000000000000000000810150000000000000000000000000000000000000000000000000000000000081016000000000000000000000000000000000000000000000000000000000008101700000000000000000000000000000000000000000000000000000000000810180000000000000000000000000000000000000000000000000000000000081019000000000000000000000000000000000000000000000000000000000008101a000000000000000000000000000000000000000000000000000000000008101b000000000000000000000000000000000000000000000000000000000008101c000000000000000000000000000000000000000000000000000000000008101d000000000000000000000000000000000000000000000000000000000008101e000000000000000000000000000000000000000000000000000000000008101f0000000000000000000000000000000000000000000000000000000000081020000000000000000000000000000000000000000000000000000000000008102100000000000000000000000000000000000000000000000000000000000810220000000000000000000000000000000000000000000000000000000000081023000000000000000000000000000000000000000000000000000000000008102400000000000000000000000000000000000000000000000000000000000810250000000000000000000000000000000000000000000000000000000000081026000000000000000000000000000000000000000000000000000000000008102700000000000000000000000000000000000000000000000000000000000810280000000000000000000000000000000000000000000000000000000000081029000000000000000000000000000000000000000000000000000000000008102a000000000000000000000000000000000000000000000000000000000008102b000000000000000000000000000000000000000000000000000000000008102c000000000000000000000000000000000000000000000000000000000008102d000000000000000000000000000000000000000000000000000000000008102e000000000000000000000000000000000000000000000000000000000008102f0000000000000000000000000000000000000000000000000000000000081030000000000000000000000000000000000000000000000000000000000008103100000000000000000000000000000000000000000000000000000000000810320000000000000000000000000000000000000000000000000000000000081033000000000000000000000000000000000000000000000000000000000008103400000000000000000000000000000000000000000000000000000000000810350000000000000000000000000000000000000000000000000000000000081036000000000000000000000000000000000000000000000000000000000008103700000000000000000000000000000000000000000000000000000000000810380000000000000000000000000000000000000000000000000000000000081039000000000000000000000000000000000000000000000000000000000008103a000000000000000000000000000000000000000000000000000000000008103b000000000000000000000000000000000000000000000000000000000008103c000000000000000000000000000000000000000000000000000000000008103d000000000000000000000000000000000000000000000000000000000008103e000000000000000000000000000000000000000000000000000000000008103f3f0000000000000000000000000000000000000000000000000000000000081100000000000000000000000000000000000000000000000000000000000008110100000000000000000000000000000000000000000000000000000000000811020000000000000000000000000000000000000000000000000000000000081103000000000000000000000000000000000000000000000000000000000008110400000000000000000000000000000000000000000000000000000000000811050000000000000000000000000000000000000000000000000000000000081106000000000000000000000000000000000000000000000000000000000008110700000000000000000000000000000000000000000000000000000000000811080000000000000000000000000000000000000000000000000000000000081109000000000000000000000000000000000000000000000000000000000008110a000000000000000000000000000000000000000000000000000000000008110b000000000000000000000000000000000000000000000000000000000008110c000000000000000000000000000000000000000000000000000000000008110d000000000000000000000000000000000000000000000000000000000008110e000000000000000000000000000000000000000000000000000000000008110f0000000000000000000000000000000000000000000000000000000000081110000000000000000000000000000000000000000000000000000000000008111100000000000000000000000000000000000000000000000000000000000811120000000000000000000000000000000000000000000000000000000000081113000000000000000000000000000000000000000000000000000000000008111400000000000000000000000000000000000000000000000000000000000811150000000000000000000000000000000000000000000000000000000000081116000000000000000000000000000000000000000000000000000000000008111700000000000000000000000000000000000000000000000000000000000811180000000000000000000000000000000000000000000000000000000000081119000000000000000000000000000000000000000000000000000000000008111a000000000000000000000000000000000000000000000000000000000008111b000000000000000000000000000000000000000000000000000000000008111c000000000000000000000000000000000000000000000000000000000008111d000000000000000000000000000000000000000000000000000000000008111e000000000000000000000000000000000000000000000000000000000008111f0000000000000000000000000000000000000000000000000000000000081120000000000000000000000000000000000000000000000000000000000008112100000000000000000000000000000000000000000000000000000000000811220000000000000000000000000000000000000000000000000000000000081123000000000000000000000000000000000000000000000000000000000008112400000000000000000000000000000000000000000000000000000000000811250000000000000000000000000000000000000000000000000000000000081126000000000000000000000000000000000000000000000000000000000008112700000000000000000000000000000000000000000000000000000000000811280000000000000000000000000000000000000000000000000000000000081129000000000000000000000000000000000000000000000000000000000008112a000000000000000000000000000000000000000000000000000000000008112b000000000000000000000000000000000000000000000000000000000008112c000000000000000000000000000000000000000000000000000000000008112d000000000000000000000000000000000000000000000000000000000008112e000000000000000000000000000000000000000000000000000000000008112f0000000000000000000000000000000000000000000000000000000000081130000000000000000000000000000000000000000000000000000000000008113100000000000000000000000000000000000000000000000000000000000811320000000000000000000000000000000000000000000000000000000000081133000000000000000000000000000000000000000000000000000000000008113400000000000000000000000000000000000000000000000000000000000811350000000000000000000000000000000000000000000000000000000000081136000000000000000000000000000000000000000000000000000000000008113700000000000000000000000000000000000000000000000000000000000811380000000000000000000000000000000000000000000000000000000000081139000000000000000000000000000000000000000000000000000000000008113a000000000000000000000000000000000000000000000000000000000008113b000000000000000000000000000000000000000000000000000000000008113c000000000000000000000000000000000000000000000000000000000008113d000000000000000000000000000000000000000000000000000000000008113e08003c0472260790b0bdfb8ae4dc4d437e7686b73643f2198970d84e1059a5f13500bfd46275a318e438726ff2765ae154b63ab8a0daebcbed668a5f58a0e63dc1007906b9418dc758c6b4f8454c69baa48b7889b6b511d707abe8e2cb8f7c397300aeb60c4d65a44f122e58bf9565dfe2024b3ae654d5cf2e47ecb035d53c927000bf82e8cda20345f37bbb1de3932172324b57f0b98be483392697b168e3bba8000fb4bbad884ef30edf68e45a6cf2733fcf50310c69d7c1432b29af2c0aa8040023e1622d27fee3b4a40ab975ae0eb2e31619ef3dc76eb858f7fddb6a056131004689cd7007daf98dd3218b839b8e6a29f957154347b391fdb376bd0b344be23f0000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082001000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082002000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082003000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082004000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082005000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820060000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008200700000000000000000000000000000000000000000000000000000000000820110000000000000000000000000000000000000000000000000000000000082008000000000000000000000000000000000000000000000000000000000008201200000000000000000000000000000000000000000000000000000000000820090000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008200a0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008200b0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008200c0000000000000000000000000000000000000000000000000000000000082016000000000000000000000000000000000000000000000000000000000008200d0000000000000000000000000000000000000000000000000000000000082017000000000000000000000000000000000000000000000000000000000008200e0000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008200f00000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082010000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082011000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082012000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082013000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082014000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082015000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820160000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008201700000000000000000000000000000000000000000000000000000000000820210000000000000000000000000000000000000000000000000000000000082018000000000000000000000000000000000000000000000000000000000008202200000000000000000000000000000000000000000000000000000000000820190000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008201a0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008201b0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008201c0000000000000000000000000000000000000000000000000000000000082026000000000000000000000000000000000000000000000000000000000008201d0000000000000000000000000000000000000000000000000000000000082027000000000000000000000000000000000000000000000000000000000008201e0000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008201f00000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082020000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082021000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082022000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082023000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082024000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082025000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820260000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008202700000000000000000000000000000000000000000000000000000000000820310000000000000000000000000000000000000000000000000000000000082028000000000000000000000000000000000000000000000000000000000008203200000000000000000000000000000000000000000000000000000000000820290000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008202a0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008202b0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008202c0000000000000000000000000000000000000000000000000000000000082036000000000000000000000000000000000000000000000000000000000008202d0000000000000000000000000000000000000000000000000000000000082037000000000000000000000000000000000000000000000000000000000008202e0000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008202f00000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082030000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082031000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082032000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082033000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082034000000000000000000000000000000000000000000000000000000000008203e0000000000000000000000000000000000000000000000000000000000082035000000000000000000000000000000000000000000000000000000000008203f00000000000000000000000000000000000000000000000000000000000820360000000000000000000000000000000000000000000000000000000000082040000000000000000000000000000000000000000000000000000000000008203700000000000000000000000000000000000000000000000000000000000820410000000000000000000000000000000000000000000000000000000000082038000000000000000000000000000000000000000000000000000000000008204200000000000000000000000000000000000000000000000000000000000820390000000000000000000000000000000000000000000000000000000000082043000000000000000000000000000000000000000000000000000000000008203a0000000000000000000000000000000000000000000000000000000000082044000000000000000000000000000000000000000000000000000000000008203b0000000000000000000000000000000000000000000000000000000000082045000000000000000000000000000000000000000000000000000000000008203c0000000000000000000000000000000000000000000000000000000000082046000000000000000000000000000000000000000000000000000000000008203d0000000000000000000000000000000000000000000000000000000000082047000000000000000000000000000000000000000000000000000000000008203e00000000000000000000000000000000000000000000000000000000000820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c100100000000000000000000000000000000000000000000000000000000000c100200000000000000000000000000000000000000000000000000000000000c100300000000000000000000000000000000000000000000000000000000000c100400000000000000000000000000000000000000000000000000000000000c100500000000000000000000000000000000000000000000000000000000000c100600000000000000000000000000000000000000000000000000000000000c100700000000000000000000000000000000000000000000000000000000000c100800000000000000000000000000000000000000000000000000000000000c100900000000000000000000000000000000000000000000000000000000000c100a00000000000000000000000000000000000000000000000000000000000c100b00000000000000000000000000000000000000000000000000000000000c100c00000000000000000000000000000000000000000000000000000000000c100d00000000000000000000000000000000000000000000000000000000000c100e00000000000000000000000000000000000000000000000000000000000c100f00000000000000000000000000000000000000000000000000000000000c101000000000000000000000000000000000000000000000000000000000000c101100000000000000000000000000000000000000000000000000000000000c101200000000000000000000000000000000000000000000000000000000000c101300000000000000000000000000000000000000000000000000000000000c101400000000000000000000000000000000000000000000000000000000000c101500000000000000000000000000000000000000000000000000000000000c101600000000000000000000000000000000000000000000000000000000000c101700000000000000000000000000000000000000000000000000000000000c101800000000000000000000000000000000000000000000000000000000000c101900000000000000000000000000000000000000000000000000000000000c101a00000000000000000000000000000000000000000000000000000000000c101b00000000000000000000000000000000000000000000000000000000000c101c00000000000000000000000000000000000000000000000000000000000c101d00000000000000000000000000000000000000000000000000000000000c101e00000000000000000000000000000000000000000000000000000000000c101f00000000000000000000000000000000000000000000000000000000000c102000000000000000000000000000000000000000000000000000000000000c102100000000000000000000000000000000000000000000000000000000000c102200000000000000000000000000000000000000000000000000000000000c102300000000000000000000000000000000000000000000000000000000000c102400000000000000000000000000000000000000000000000000000000000c102500000000000000000000000000000000000000000000000000000000000c102600000000000000000000000000000000000000000000000000000000000c102700000000000000000000000000000000000000000000000000000000000c102800000000000000000000000000000000000000000000000000000000000c102900000000000000000000000000000000000000000000000000000000000c102a00000000000000000000000000000000000000000000000000000000000c102b00000000000000000000000000000000000000000000000000000000000c102c00000000000000000000000000000000000000000000000000000000000c102d00000000000000000000000000000000000000000000000000000000000c102e00000000000000000000000000000000000000000000000000000000000c102f00000000000000000000000000000000000000000000000000000000000c103000000000000000000000000000000000000000000000000000000000000c103100000000000000000000000000000000000000000000000000000000000c103200000000000000000000000000000000000000000000000000000000000c103300000000000000000000000000000000000000000000000000000000000c103400000000000000000000000000000000000000000000000000000000000c103500000000000000000000000000000000000000000000000000000000000c103600000000000000000000000000000000000000000000000000000000000c103700000000000000000000000000000000000000000000000000000000000c103800000000000000000000000000000000000000000000000000000000000c103900000000000000000000000000000000000000000000000000000000000c103a00000000000000000000000000000000000000000000000000000000000c103b00000000000000000000000000000000000000000000000000000000000c103c00000000000000000000000000000000000000000000000000000000000c103d00000000000000000000000000000000000000000000000000000000000c103e00000000000000000000000000000000000000000000000000000000000c103f3f00000000000000000000000000000000000000000000000000000000000c110000000000000000000000000000000000000000000000000000000000000c110100000000000000000000000000000000000000000000000000000000000c110200000000000000000000000000000000000000000000000000000000000c110300000000000000000000000000000000000000000000000000000000000c110400000000000000000000000000000000000000000000000000000000000c110500000000000000000000000000000000000000000000000000000000000c110600000000000000000000000000000000000000000000000000000000000c110700000000000000000000000000000000000000000000000000000000000c110800000000000000000000000000000000000000000000000000000000000c110900000000000000000000000000000000000000000000000000000000000c110a00000000000000000000000000000000000000000000000000000000000c110b00000000000000000000000000000000000000000000000000000000000c110c00000000000000000000000000000000000000000000000000000000000c110d00000000000000000000000000000000000000000000000000000000000c110e00000000000000000000000000000000000000000000000000000000000c110f00000000000000000000000000000000000000000000000000000000000c111000000000000000000000000000000000000000000000000000000000000c111100000000000000000000000000000000000000000000000000000000000c111200000000000000000000000000000000000000000000000000000000000c111300000000000000000000000000000000000000000000000000000000000c111400000000000000000000000000000000000000000000000000000000000c111500000000000000000000000000000000000000000000000000000000000c111600000000000000000000000000000000000000000000000000000000000c111700000000000000000000000000000000000000000000000000000000000c111800000000000000000000000000000000000000000000000000000000000c111900000000000000000000000000000000000000000000000000000000000c111a00000000000000000000000000000000000000000000000000000000000c111b00000000000000000000000000000000000000000000000000000000000c111c00000000000000000000000000000000000000000000000000000000000c111d00000000000000000000000000000000000000000000000000000000000c111e00000000000000000000000000000000000000000000000000000000000c111f00000000000000000000000000000000000000000000000000000000000c112000000000000000000000000000000000000000000000000000000000000c112100000000000000000000000000000000000000000000000000000000000c112200000000000000000000000000000000000000000000000000000000000c112300000000000000000000000000000000000000000000000000000000000c112400000000000000000000000000000000000000000000000000000000000c112500000000000000000000000000000000000000000000000000000000000c112600000000000000000000000000000000000000000000000000000000000c112700000000000000000000000000000000000000000000000000000000000c112800000000000000000000000000000000000000000000000000000000000c112900000000000000000000000000000000000000000000000000000000000c112a00000000000000000000000000000000000000000000000000000000000c112b00000000000000000000000000000000000000000000000000000000000c112c00000000000000000000000000000000000000000000000000000000000c112d00000000000000000000000000000000000000000000000000000000000c112e00000000000000000000000000000000000000000000000000000000000c112f00000000000000000000000000000000000000000000000000000000000c113000000000000000000000000000000000000000000000000000000000000c113100000000000000000000000000000000000000000000000000000000000c113200000000000000000000000000000000000000000000000000000000000c113300000000000000000000000000000000000000000000000000000000000c113400000000000000000000000000000000000000000000000000000000000c113500000000000000000000000000000000000000000000000000000000000c113600000000000000000000000000000000000000000000000000000000000c113700000000000000000000000000000000000000000000000000000000000c113800000000000000000000000000000000000000000000000000000000000c113900000000000000000000000000000000000000000000000000000000000c113a00000000000000000000000000000000000000000000000000000000000c113b00000000000000000000000000000000000000000000000000000000000c113c00000000000000000000000000000000000000000000000000000000000c113d00000000000000000000000000000000000000000000000000000000000c113e0800f8029be42ec3f25204907ca981fb71e5b357093eb5db10fc01ca98a4e4154c0030e13d351a5bf1d5a040e82a163ca57017f39162693f85c571e441e36d702d00a550ae0f39f977d9473d6de1be3232fc68ed0c4a601d53542148695102cfc9005580bc65e4bff9c8fffa64db02c0fa6af14d9d26fd962f4c5904cbd3ddec2500758c4a0d43dfec788b2f580877c4f473adec8f168ea24424f2600e4eb4916f00342602bf90d10f8ca8e582a894dcc4c02bb89fe458532e0c632b53bae54b4d00ca43ab78ab834337e9964d84a0674c9adabdca140539c5a6bc96e0ba9a51f6004ffbfd91be292a7c6a0e255e50caa156ac2d628b40ad2128c4ab63a92d8a1c3f00000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c200100000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c200200000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c200300000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c200400000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c200500000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c200600000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c200700000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c200800000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c200900000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c200a00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c200b00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c200c00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c200d00000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c200e00000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c200f00000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c201000000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c201100000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c201200000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c201300000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c201400000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c201500000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c201600000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c201700000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c201800000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c201900000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c201a00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c201b00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c201c00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c201d00000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c201e00000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c201f00000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c202000000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c202100000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c202200000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c202300000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c202400000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c202500000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c202600000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c202700000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c202800000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c202900000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c202a00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c202b00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c202c00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c202d00000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c202e00000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c202f00000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c203000000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c203100000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c203200000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c203300000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c203400000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c203500000000000000000000000000000000000000000000000000000000000c203f00000000000000000000000000000000000000000000000000000000000c203600000000000000000000000000000000000000000000000000000000000c204000000000000000000000000000000000000000000000000000000000000c203700000000000000000000000000000000000000000000000000000000000c204100000000000000000000000000000000000000000000000000000000000c203800000000000000000000000000000000000000000000000000000000000c204200000000000000000000000000000000000000000000000000000000000c203900000000000000000000000000000000000000000000000000000000000c204300000000000000000000000000000000000000000000000000000000000c203a00000000000000000000000000000000000000000000000000000000000c204400000000000000000000000000000000000000000000000000000000000c203b00000000000000000000000000000000000000000000000000000000000c204500000000000000000000000000000000000000000000000000000000000c203c00000000000000000000000000000000000000000000000000000000000c204600000000000000000000000000000000000000000000000000000000000c203d00000000000000000000000000000000000000000000000000000000000c204700000000000000000000000000000000000000000000000000000000000c203e00000000000000000000000000000000000000000000000000000000000c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000010100100000000000000000000000000000000000000000000000000000000001010020000000000000000000000000000000000000000000000000000000000101003000000000000000000000000000000000000000000000000000000000010100400000000000000000000000000000000000000000000000000000000001010050000000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000010100700000000000000000000000000000000000000000000000000000000001010080000000000000000000000000000000000000000000000000000000000101009000000000000000000000000000000000000000000000000000000000010100a000000000000000000000000000000000000000000000000000000000010100b000000000000000000000000000000000000000000000000000000000010100c000000000000000000000000000000000000000000000000000000000010100d000000000000000000000000000000000000000000000000000000000010100e000000000000000000000000000000000000000000000000000000000010100f0000000000000000000000000000000000000000000000000000000000101010000000000000000000000000000000000000000000000000000000000010101100000000000000000000000000000000000000000000000000000000001010120000000000000000000000000000000000000000000000000000000000101013000000000000000000000000000000000000000000000000000000000010101400000000000000000000000000000000000000000000000000000000001010150000000000000000000000000000000000000000000000000000000000101016000000000000000000000000000000000000000000000000000000000010101700000000000000000000000000000000000000000000000000000000001010180000000000000000000000000000000000000000000000000000000000101019000000000000000000000000000000000000000000000000000000000010101a000000000000000000000000000000000000000000000000000000000010101b000000000000000000000000000000000000000000000000000000000010101c000000000000000000000000000000000000000000000000000000000010101d000000000000000000000000000000000000000000000000000000000010101e000000000000000000000000000000000000000000000000000000000010101f0000000000000000000000000000000000000000000000000000000000101020000000000000000000000000000000000000000000000000000000000010102100000000000000000000000000000000000000000000000000000000001010220000000000000000000000000000000000000000000000000000000000101023000000000000000000000000000000000000000000000000000000000010102400000000000000000000000000000000000000000000000000000000001010250000000000000000000000000000000000000000000000000000000000101026000000000000000000000000000000000000000000000000000000000010102700000000000000000000000000000000000000000000000000000000001010280000000000000000000000000000000000000000000000000000000000101029000000000000000000000000000000000000000000000000000000000010102a000000000000000000000000000000000000000000000000000000000010102b000000000000000000000000000000000000000000000000000000000010102c000000000000000000000000000000000000000000000000000000000010102d000000000000000000000000000000000000000000000000000000000010102e000000000000000000000000000000000000000000000000000000000010102f0000000000000000000000000000000000000000000000000000000000101030000000000000000000000000000000000000000000000000000000000010103100000000000000000000000000000000000000000000000000000000001010320000000000000000000000000000000000000000000000000000000000101033000000000000000000000000000000000000000000000000000000000010103400000000000000000000000000000000000000000000000000000000001010350000000000000000000000000000000000000000000000000000000000101036000000000000000000000000000000000000000000000000000000000010103700000000000000000000000000000000000000000000000000000000001010380000000000000000000000000000000000000000000000000000000000101039000000000000000000000000000000000000000000000000000000000010103a000000000000000000000000000000000000000000000000000000000010103b000000000000000000000000000000000000000000000000000000000010103c000000000000000000000000000000000000000000000000000000000010103d000000000000000000000000000000000000000000000000000000000010103e000000000000000000000000000000000000000000000000000000000010103f3f0000000000000000000000000000000000000000000000000000000000101100000000000000000000000000000000000000000000000000000000000010110100000000000000000000000000000000000000000000000000000000001011020000000000000000000000000000000000000000000000000000000000101103000000000000000000000000000000000000000000000000000000000010110400000000000000000000000000000000000000000000000000000000001011050000000000000000000000000000000000000000000000000000000000101106000000000000000000000000000000000000000000000000000000000010110700000000000000000000000000000000000000000000000000000000001011080000000000000000000000000000000000000000000000000000000000101109000000000000000000000000000000000000000000000000000000000010110a000000000000000000000000000000000000000000000000000000000010110b000000000000000000000000000000000000000000000000000000000010110c000000000000000000000000000000000000000000000000000000000010110d000000000000000000000000000000000000000000000000000000000010110e000000000000000000000000000000000000000000000000000000000010110f0000000000000000000000000000000000000000000000000000000000101110000000000000000000000000000000000000000000000000000000000010111100000000000000000000000000000000000000000000000000000000001011120000000000000000000000000000000000000000000000000000000000101113000000000000000000000000000000000000000000000000000000000010111400000000000000000000000000000000000000000000000000000000001011150000000000000000000000000000000000000000000000000000000000101116000000000000000000000000000000000000000000000000000000000010111700000000000000000000000000000000000000000000000000000000001011180000000000000000000000000000000000000000000000000000000000101119000000000000000000000000000000000000000000000000000000000010111a000000000000000000000000000000000000000000000000000000000010111b000000000000000000000000000000000000000000000000000000000010111c000000000000000000000000000000000000000000000000000000000010111d000000000000000000000000000000000000000000000000000000000010111e000000000000000000000000000000000000000000000000000000000010111f0000000000000000000000000000000000000000000000000000000000101120000000000000000000000000000000000000000000000000000000000010112100000000000000000000000000000000000000000000000000000000001011220000000000000000000000000000000000000000000000000000000000101123000000000000000000000000000000000000000000000000000000000010112400000000000000000000000000000000000000000000000000000000001011250000000000000000000000000000000000000000000000000000000000101126000000000000000000000000000000000000000000000000000000000010112700000000000000000000000000000000000000000000000000000000001011280000000000000000000000000000000000000000000000000000000000101129000000000000000000000000000000000000000000000000000000000010112a000000000000000000000000000000000000000000000000000000000010112b000000000000000000000000000000000000000000000000000000000010112c000000000000000000000000000000000000000000000000000000000010112d000000000000000000000000000000000000000000000000000000000010112e000000000000000000000000000000000000000000000000000000000010112f0000000000000000000000000000000000000000000000000000000000101130000000000000000000000000000000000000000000000000000000000010113100000000000000000000000000000000000000000000000000000000001011320000000000000000000000000000000000000000000000000000000000101133000000000000000000000000000000000000000000000000000000000010113400000000000000000000000000000000000000000000000000000000001011350000000000000000000000000000000000000000000000000000000000101136000000000000000000000000000000000000000000000000000000000010113700000000000000000000000000000000000000000000000000000000001011380000000000000000000000000000000000000000000000000000000000101139000000000000000000000000000000000000000000000000000000000010113a000000000000000000000000000000000000000000000000000000000010113b000000000000000000000000000000000000000000000000000000000010113c000000000000000000000000000000000000000000000000000000000010113d000000000000000000000000000000000000000000000000000000000010113e080099145b6c0d32753835121f8b271186d01236948a4622ce78a98347fcfc98390085277a27c6acbd5ffc4c19cd65fc30056999e9bec36998f753132db0ff8e2300f3cf77a7261759ebd5f4149f6ad56746f4499cfcd4adf27a1d373f77da64d5009bc6e0e994a23cde8c95b90c1acc1b4a480c6599d1df2c3f9f6e76f3d1aff200d7a1c4a2700dacaaf07f1f0ff33837bdbabcf0b9ace17efabe0761708c4bb900dbeb8e96d14f21e57d5786b6d6ae7e5ddb1bb35935c0fb246d4bdbca62e02c00fbf12b5e0df6223b801088798e4e04d2a92ffe9a11639b7f0ce314e3412a8000d796e0724de03b796ba77069fcd6cf921e566f3aed15eb3e77258add74e9ff3f0000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102001000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102002000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102003000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102004000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102005000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020060000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010200700000000000000000000000000000000000000000000000000000000001020110000000000000000000000000000000000000000000000000000000000102008000000000000000000000000000000000000000000000000000000000010201200000000000000000000000000000000000000000000000000000000001020090000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010200a0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010200b0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010200c0000000000000000000000000000000000000000000000000000000000102016000000000000000000000000000000000000000000000000000000000010200d0000000000000000000000000000000000000000000000000000000000102017000000000000000000000000000000000000000000000000000000000010200e0000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010200f00000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102010000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102011000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102012000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102013000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102014000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102015000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020160000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010201700000000000000000000000000000000000000000000000000000000001020210000000000000000000000000000000000000000000000000000000000102018000000000000000000000000000000000000000000000000000000000010202200000000000000000000000000000000000000000000000000000000001020190000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010201a0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010201b0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010201c0000000000000000000000000000000000000000000000000000000000102026000000000000000000000000000000000000000000000000000000000010201d0000000000000000000000000000000000000000000000000000000000102027000000000000000000000000000000000000000000000000000000000010201e0000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010201f00000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102020000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102021000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102022000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102023000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102024000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102025000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020260000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010202700000000000000000000000000000000000000000000000000000000001020310000000000000000000000000000000000000000000000000000000000102028000000000000000000000000000000000000000000000000000000000010203200000000000000000000000000000000000000000000000000000000001020290000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010202a0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010202b0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010202c0000000000000000000000000000000000000000000000000000000000102036000000000000000000000000000000000000000000000000000000000010202d0000000000000000000000000000000000000000000000000000000000102037000000000000000000000000000000000000000000000000000000000010202e0000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010202f00000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102030000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102031000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102032000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102033000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102034000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102035000000000000000000000000000000000000000000000000000000000010203f00000000000000000000000000000000000000000000000000000000001020360000000000000000000000000000000000000000000000000000000000102040000000000000000000000000000000000000000000000000000000000010203700000000000000000000000000000000000000000000000000000000001020410000000000000000000000000000000000000000000000000000000000102038000000000000000000000000000000000000000000000000000000000010204200000000000000000000000000000000000000000000000000000000001020390000000000000000000000000000000000000000000000000000000000102043000000000000000000000000000000000000000000000000000000000010203a0000000000000000000000000000000000000000000000000000000000102044000000000000000000000000000000000000000000000000000000000010203b0000000000000000000000000000000000000000000000000000000000102045000000000000000000000000000000000000000000000000000000000010203c0000000000000000000000000000000000000000000000000000000000102046000000000000000000000000000000000000000000000000000000000010203d0000000000000000000000000000000000000000000000000000000000102047000000000000000000000000000000000000000000000000000000000010203e0000000000000000000000000000000000000000000000000000000000102048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000141000000000000000000000000000000000000000000000000000000000000014100100000000000000000000000000000000000000000000000000000000001410020000000000000000000000000000000000000000000000000000000000141003000000000000000000000000000000000000000000000000000000000014100400000000000000000000000000000000000000000000000000000000001410050000000000000000000000000000000000000000000000000000000000141006000000000000000000000000000000000000000000000000000000000014100700000000000000000000000000000000000000000000000000000000001410080000000000000000000000000000000000000000000000000000000000141009000000000000000000000000000000000000000000000000000000000014100a000000000000000000000000000000000000000000000000000000000014100b000000000000000000000000000000000000000000000000000000000014100c000000000000000000000000000000000000000000000000000000000014100d000000000000000000000000000000000000000000000000000000000014100e000000000000000000000000000000000000000000000000000000000014100f0000000000000000000000000000000000000000000000000000000000141010000000000000000000000000000000000000000000000000000000000014101100000000000000000000000000000000000000000000000000000000001410120000000000000000000000000000000000000000000000000000000000141013000000000000000000000000000000000000000000000000000000000014101400000000000000000000000000000000000000000000000000000000001410150000000000000000000000000000000000000000000000000000000000141016000000000000000000000000000000000000000000000000000000000014101700000000000000000000000000000000000000000000000000000000001410180000000000000000000000000000000000000000000000000000000000141019000000000000000000000000000000000000000000000000000000000014101a000000000000000000000000000000000000000000000000000000000014101b000000000000000000000000000000000000000000000000000000000014101c000000000000000000000000000000000000000000000000000000000014101d000000000000000000000000000000000000000000000000000000000014101e000000000000000000000000000000000000000000000000000000000014101f0000000000000000000000000000000000000000000000000000000000141020000000000000000000000000000000000000000000000000000000000014102100000000000000000000000000000000000000000000000000000000001410220000000000000000000000000000000000000000000000000000000000141023000000000000000000000000000000000000000000000000000000000014102400000000000000000000000000000000000000000000000000000000001410250000000000000000000000000000000000000000000000000000000000141026000000000000000000000000000000000000000000000000000000000014102700000000000000000000000000000000000000000000000000000000001410280000000000000000000000000000000000000000000000000000000000141029000000000000000000000000000000000000000000000000000000000014102a000000000000000000000000000000000000000000000000000000000014102b000000000000000000000000000000000000000000000000000000000014102c000000000000000000000000000000000000000000000000000000000014102d000000000000000000000000000000000000000000000000000000000014102e000000000000000000000000000000000000000000000000000000000014102f0000000000000000000000000000000000000000000000000000000000141030000000000000000000000000000000000000000000000000000000000014103100000000000000000000000000000000000000000000000000000000001410320000000000000000000000000000000000000000000000000000000000141033000000000000000000000000000000000000000000000000000000000014103400000000000000000000000000000000000000000000000000000000001410350000000000000000000000000000000000000000000000000000000000141036000000000000000000000000000000000000000000000000000000000014103700000000000000000000000000000000000000000000000000000000001410380000000000000000000000000000000000000000000000000000000000141039000000000000000000000000000000000000000000000000000000000014103a000000000000000000000000000000000000000000000000000000000014103b000000000000000000000000000000000000000000000000000000000014103c000000000000000000000000000000000000000000000000000000000014103d000000000000000000000000000000000000000000000000000000000014103e000000000000000000000000000000000000000000000000000000000014103f3f0000000000000000000000000000000000000000000000000000000000141100000000000000000000000000000000000000000000000000000000000014110100000000000000000000000000000000000000000000000000000000001411020000000000000000000000000000000000000000000000000000000000141103000000000000000000000000000000000000000000000000000000000014110400000000000000000000000000000000000000000000000000000000001411050000000000000000000000000000000000000000000000000000000000141106000000000000000000000000000000000000000000000000000000000014110700000000000000000000000000000000000000000000000000000000001411080000000000000000000000000000000000000000000000000000000000141109000000000000000000000000000000000000000000000000000000000014110a000000000000000000000000000000000000000000000000000000000014110b000000000000000000000000000000000000000000000000000000000014110c000000000000000000000000000000000000000000000000000000000014110d000000000000000000000000000000000000000000000000000000000014110e000000000000000000000000000000000000000000000000000000000014110f0000000000000000000000000000000000000000000000000000000000141110000000000000000000000000000000000000000000000000000000000014111100000000000000000000000000000000000000000000000000000000001411120000000000000000000000000000000000000000000000000000000000141113000000000000000000000000000000000000000000000000000000000014111400000000000000000000000000000000000000000000000000000000001411150000000000000000000000000000000000000000000000000000000000141116000000000000000000000000000000000000000000000000000000000014111700000000000000000000000000000000000000000000000000000000001411180000000000000000000000000000000000000000000000000000000000141119000000000000000000000000000000000000000000000000000000000014111a000000000000000000000000000000000000000000000000000000000014111b000000000000000000000000000000000000000000000000000000000014111c000000000000000000000000000000000000000000000000000000000014111d000000000000000000000000000000000000000000000000000000000014111e000000000000000000000000000000000000000000000000000000000014111f0000000000000000000000000000000000000000000000000000000000141120000000000000000000000000000000000000000000000000000000000014112100000000000000000000000000000000000000000000000000000000001411220000000000000000000000000000000000000000000000000000000000141123000000000000000000000000000000000000000000000000000000000014112400000000000000000000000000000000000000000000000000000000001411250000000000000000000000000000000000000000000000000000000000141126000000000000000000000000000000000000000000000000000000000014112700000000000000000000000000000000000000000000000000000000001411280000000000000000000000000000000000000000000000000000000000141129000000000000000000000000000000000000000000000000000000000014112a000000000000000000000000000000000000000000000000000000000014112b000000000000000000000000000000000000000000000000000000000014112c000000000000000000000000000000000000000000000000000000000014112d000000000000000000000000000000000000000000000000000000000014112e000000000000000000000000000000000000000000000000000000000014112f0000000000000000000000000000000000000000000000000000000000141130000000000000000000000000000000000000000000000000000000000014113100000000000000000000000000000000000000000000000000000000001411320000000000000000000000000000000000000000000000000000000000141133000000000000000000000000000000000000000000000000000000000014113400000000000000000000000000000000000000000000000000000000001411350000000000000000000000000000000000000000000000000000000000141136000000000000000000000000000000000000000000000000000000000014113700000000000000000000000000000000000000000000000000000000001411380000000000000000000000000000000000000000000000000000000000141139000000000000000000000000000000000000000000000000000000000014113a000000000000000000000000000000000000000000000000000000000014113b000000000000000000000000000000000000000000000000000000000014113c000000000000000000000000000000000000000000000000000000000014113d000000000000000000000000000000000000000000000000000000000014113e08005c015113cb57d67dd6c0febd596819ac0298b6a23fc80aba17d445d540059a00f20b7d1308051fe7b68031a7c336b0b4b56738928b6510133aff1b818d5a9a0063eec1883a4f95f4933f9275e850d84b3d035f5061ed986c437a07331fd30e00d3a32d6bbc4fd843686fd0c5e118a73b847529977dca5b9e0e81f6604f22ca00c2f4f5133d9194d41e853e5e951e16690babce8461f25342c0bad20f2aa1e3000a6bf4739e7eb387913d955dc2e8f14f8cce27696b9d2e128b6acefafb80ee005763f7e0648f958b559677622a648f318fc79ebc0cb539170d49c26456e69200302e2b8a92cda941e9af8761b89899a58a587656d9710594e1d865b16522993f0000000000000000000000000000000000000000000000000000000000142000000000000000000000000000000000000000000000000000000000000014200a0000000000000000000000000000000000000000000000000000000000142001000000000000000000000000000000000000000000000000000000000014200b0000000000000000000000000000000000000000000000000000000000142002000000000000000000000000000000000000000000000000000000000014200c0000000000000000000000000000000000000000000000000000000000142003000000000000000000000000000000000000000000000000000000000014200d0000000000000000000000000000000000000000000000000000000000142004000000000000000000000000000000000000000000000000000000000014200e0000000000000000000000000000000000000000000000000000000000142005000000000000000000000000000000000000000000000000000000000014200f00000000000000000000000000000000000000000000000000000000001420060000000000000000000000000000000000000000000000000000000000142010000000000000000000000000000000000000000000000000000000000014200700000000000000000000000000000000000000000000000000000000001420110000000000000000000000000000000000000000000000000000000000142008000000000000000000000000000000000000000000000000000000000014201200000000000000000000000000000000000000000000000000000000001420090000000000000000000000000000000000000000000000000000000000142013000000000000000000000000000000000000000000000000000000000014200a0000000000000000000000000000000000000000000000000000000000142014000000000000000000000000000000000000000000000000000000000014200b0000000000000000000000000000000000000000000000000000000000142015000000000000000000000000000000000000000000000000000000000014200c0000000000000000000000000000000000000000000000000000000000142016000000000000000000000000000000000000000000000000000000000014200d0000000000000000000000000000000000000000000000000000000000142017000000000000000000000000000000000000000000000000000000000014200e0000000000000000000000000000000000000000000000000000000000142018000000000000000000000000000000000000000000000000000000000014200f00000000000000000000000000000000000000000000000000000000001420190000000000000000000000000000000000000000000000000000000000142010000000000000000000000000000000000000000000000000000000000014201a0000000000000000000000000000000000000000000000000000000000142011000000000000000000000000000000000000000000000000000000000014201b0000000000000000000000000000000000000000000000000000000000142012000000000000000000000000000000000000000000000000000000000014201c0000000000000000000000000000000000000000000000000000000000142013000000000000000000000000000000000000000000000000000000000014201d0000000000000000000000000000000000000000000000000000000000142014000000000000000000000000000000000000000000000000000000000014201e0000000000000000000000000000000000000000000000000000000000142015000000000000000000000000000000000000000000000000000000000014201f00000000000000000000000000000000000000000000000000000000001420160000000000000000000000000000000000000000000000000000000000142020000000000000000000000000000000000000000000000000000000000014201700000000000000000000000000000000000000000000000000000000001420210000000000000000000000000000000000000000000000000000000000142018000000000000000000000000000000000000000000000000000000000014202200000000000000000000000000000000000000000000000000000000001420190000000000000000000000000000000000000000000000000000000000142023000000000000000000000000000000000000000000000000000000000014201a0000000000000000000000000000000000000000000000000000000000142024000000000000000000000000000000000000000000000000000000000014201b0000000000000000000000000000000000000000000000000000000000142025000000000000000000000000000000000000000000000000000000000014201c0000000000000000000000000000000000000000000000000000000000142026000000000000000000000000000000000000000000000000000000000014201d0000000000000000000000000000000000000000000000000000000000142027000000000000000000000000000000000000000000000000000000000014201e0000000000000000000000000000000000000000000000000000000000142028000000000000000000000000000000000000000000000000000000000014201f00000000000000000000000000000000000000000000000000000000001420290000000000000000000000000000000000000000000000000000000000142020000000000000000000000000000000000000000000000000000000000014202a0000000000000000000000000000000000000000000000000000000000142021000000000000000000000000000000000000000000000000000000000014202b0000000000000000000000000000000000000000000000000000000000142022000000000000000000000000000000000000000000000000000000000014202c0000000000000000000000000000000000000000000000000000000000142023000000000000000000000000000000000000000000000000000000000014202d0000000000000000000000000000000000000000000000000000000000142024000000000000000000000000000000000000000000000000000000000014202e0000000000000000000000000000000000000000000000000000000000142025000000000000000000000000000000000000000000000000000000000014202f00000000000000000000000000000000000000000000000000000000001420260000000000000000000000000000000000000000000000000000000000142030000000000000000000000000000000000000000000000000000000000014202700000000000000000000000000000000000000000000000000000000001420310000000000000000000000000000000000000000000000000000000000142028000000000000000000000000000000000000000000000000000000000014203200000000000000000000000000000000000000000000000000000000001420290000000000000000000000000000000000000000000000000000000000142033000000000000000000000000000000000000000000000000000000000014202a0000000000000000000000000000000000000000000000000000000000142034000000000000000000000000000000000000000000000000000000000014202b0000000000000000000000000000000000000000000000000000000000142035000000000000000000000000000000000000000000000000000000000014202c0000000000000000000000000000000000000000000000000000000000142036000000000000000000000000000000000000000000000000000000000014202d0000000000000000000000000000000000000000000000000000000000142037000000000000000000000000000000000000000000000000000000000014202e0000000000000000000000000000000000000000000000000000000000142038000000000000000000000000000000000000000000000000000000000014202f00000000000000000000000000000000000000000000000000000000001420390000000000000000000000000000000000000000000000000000000000142030000000000000000000000000000000000000000000000000000000000014203a0000000000000000000000000000000000000000000000000000000000142031000000000000000000000000000000000000000000000000000000000014203b0000000000000000000000000000000000000000000000000000000000142032000000000000000000000000000000000000000000000000000000000014203c0000000000000000000000000000000000000000000000000000000000142033000000000000000000000000000000000000000000000000000000000014203d0000000000000000000000000000000000000000000000000000000000142034000000000000000000000000000000000000000000000000000000000014203e0000000000000000000000000000000000000000000000000000000000142035000000000000000000000000000000000000000000000000000000000014203f00000000000000000000000000000000000000000000000000000000001420360000000000000000000000000000000000000000000000000000000000142040000000000000000000000000000000000000000000000000000000000014203700000000000000000000000000000000000000000000000000000000001420410000000000000000000000000000000000000000000000000000000000142038000000000000000000000000000000000000000000000000000000000014204200000000000000000000000000000000000000000000000000000000001420390000000000000000000000000000000000000000000000000000000000142043000000000000000000000000000000000000000000000000000000000014203a0000000000000000000000000000000000000000000000000000000000142044000000000000000000000000000000000000000000000000000000000014203b0000000000000000000000000000000000000000000000000000000000142045000000000000000000000000000000000000000000000000000000000014203c0000000000000000000000000000000000000000000000000000000000142046000000000000000000000000000000000000000000000000000000000014203d0000000000000000000000000000000000000000000000000000000000142047000000000000000000000000000000000000000000000000000000000014203e0000000000000000000000000000000000000000000000000000000000142048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000181000000000000000000000000000000000000000000000000000000000000018100100000000000000000000000000000000000000000000000000000000001810020000000000000000000000000000000000000000000000000000000000181003000000000000000000000000000000000000000000000000000000000018100400000000000000000000000000000000000000000000000000000000001810050000000000000000000000000000000000000000000000000000000000181006000000000000000000000000000000000000000000000000000000000018100700000000000000000000000000000000000000000000000000000000001810080000000000000000000000000000000000000000000000000000000000181009000000000000000000000000000000000000000000000000000000000018100a000000000000000000000000000000000000000000000000000000000018100b000000000000000000000000000000000000000000000000000000000018100c000000000000000000000000000000000000000000000000000000000018100d000000000000000000000000000000000000000000000000000000000018100e000000000000000000000000000000000000000000000000000000000018100f0000000000000000000000000000000000000000000000000000000000181010000000000000000000000000000000000000000000000000000000000018101100000000000000000000000000000000000000000000000000000000001810120000000000000000000000000000000000000000000000000000000000181013000000000000000000000000000000000000000000000000000000000018101400000000000000000000000000000000000000000000000000000000001810150000000000000000000000000000000000000000000000000000000000181016000000000000000000000000000000000000000000000000000000000018101700000000000000000000000000000000000000000000000000000000001810180000000000000000000000000000000000000000000000000000000000181019000000000000000000000000000000000000000000000000000000000018101a000000000000000000000000000000000000000000000000000000000018101b000000000000000000000000000000000000000000000000000000000018101c000000000000000000000000000000000000000000000000000000000018101d000000000000000000000000000000000000000000000000000000000018101e000000000000000000000000000000000000000000000000000000000018101f0000000000000000000000000000000000000000000000000000000000181020000000000000000000000000000000000000000000000000000000000018102100000000000000000000000000000000000000000000000000000000001810220000000000000000000000000000000000000000000000000000000000181023000000000000000000000000000000000000000000000000000000000018102400000000000000000000000000000000000000000000000000000000001810250000000000000000000000000000000000000000000000000000000000181026000000000000000000000000000000000000000000000000000000000018102700000000000000000000000000000000000000000000000000000000001810280000000000000000000000000000000000000000000000000000000000181029000000000000000000000000000000000000000000000000000000000018102a000000000000000000000000000000000000000000000000000000000018102b000000000000000000000000000000000000000000000000000000000018102c000000000000000000000000000000000000000000000000000000000018102d000000000000000000000000000000000000000000000000000000000018102e000000000000000000000000000000000000000000000000000000000018102f0000000000000000000000000000000000000000000000000000000000181030000000000000000000000000000000000000000000000000000000000018103100000000000000000000000000000000000000000000000000000000001810320000000000000000000000000000000000000000000000000000000000181033000000000000000000000000000000000000000000000000000000000018103400000000000000000000000000000000000000000000000000000000001810350000000000000000000000000000000000000000000000000000000000181036000000000000000000000000000000000000000000000000000000000018103700000000000000000000000000000000000000000000000000000000001810380000000000000000000000000000000000000000000000000000000000181039000000000000000000000000000000000000000000000000000000000018103a000000000000000000000000000000000000000000000000000000000018103b000000000000000000000000000000000000000000000000000000000018103c000000000000000000000000000000000000000000000000000000000018103d000000000000000000000000000000000000000000000000000000000018103e000000000000000000000000000000000000000000000000000000000018103f3f0000000000000000000000000000000000000000000000000000000000181100000000000000000000000000000000000000000000000000000000000018110100000000000000000000000000000000000000000000000000000000001811020000000000000000000000000000000000000000000000000000000000181103000000000000000000000000000000000000000000000000000000000018110400000000000000000000000000000000000000000000000000000000001811050000000000000000000000000000000000000000000000000000000000181106000000000000000000000000000000000000000000000000000000000018110700000000000000000000000000000000000000000000000000000000001811080000000000000000000000000000000000000000000000000000000000181109000000000000000000000000000000000000000000000000000000000018110a000000000000000000000000000000000000000000000000000000000018110b000000000000000000000000000000000000000000000000000000000018110c000000000000000000000000000000000000000000000000000000000018110d000000000000000000000000000000000000000000000000000000000018110e000000000000000000000000000000000000000000000000000000000018110f0000000000000000000000000000000000000000000000000000000000181110000000000000000000000000000000000000000000000000000000000018111100000000000000000000000000000000000000000000000000000000001811120000000000000000000000000000000000000000000000000000000000181113000000000000000000000000000000000000000000000000000000000018111400000000000000000000000000000000000000000000000000000000001811150000000000000000000000000000000000000000000000000000000000181116000000000000000000000000000000000000000000000000000000000018111700000000000000000000000000000000000000000000000000000000001811180000000000000000000000000000000000000000000000000000000000181119000000000000000000000000000000000000000000000000000000000018111a000000000000000000000000000000000000000000000000000000000018111b000000000000000000000000000000000000000000000000000000000018111c000000000000000000000000000000000000000000000000000000000018111d000000000000000000000000000000000000000000000000000000000018111e000000000000000000000000000000000000000000000000000000000018111f0000000000000000000000000000000000000000000000000000000000181120000000000000000000000000000000000000000000000000000000000018112100000000000000000000000000000000000000000000000000000000001811220000000000000000000000000000000000000000000000000000000000181123000000000000000000000000000000000000000000000000000000000018112400000000000000000000000000000000000000000000000000000000001811250000000000000000000000000000000000000000000000000000000000181126000000000000000000000000000000000000000000000000000000000018112700000000000000000000000000000000000000000000000000000000001811280000000000000000000000000000000000000000000000000000000000181129000000000000000000000000000000000000000000000000000000000018112a000000000000000000000000000000000000000000000000000000000018112b000000000000000000000000000000000000000000000000000000000018112c000000000000000000000000000000000000000000000000000000000018112d000000000000000000000000000000000000000000000000000000000018112e000000000000000000000000000000000000000000000000000000000018112f0000000000000000000000000000000000000000000000000000000000181130000000000000000000000000000000000000000000000000000000000018113100000000000000000000000000000000000000000000000000000000001811320000000000000000000000000000000000000000000000000000000000181133000000000000000000000000000000000000000000000000000000000018113400000000000000000000000000000000000000000000000000000000001811350000000000000000000000000000000000000000000000000000000000181136000000000000000000000000000000000000000000000000000000000018113700000000000000000000000000000000000000000000000000000000001811380000000000000000000000000000000000000000000000000000000000181139000000000000000000000000000000000000000000000000000000000018113a000000000000000000000000000000000000000000000000000000000018113b000000000000000000000000000000000000000000000000000000000018113c000000000000000000000000000000000000000000000000000000000018113d000000000000000000000000000000000000000000000000000000000018113e0800f872eb9653f03af10f331da1361fa1524d3cd958cb72dacea1d424f19df3af00ffc548a17cd6ba1f2d228f30e4ddb19ecc46ad3b609977d52bb0f49e1206410032f8058bd779c520eabae2743b02ec4f71670428506fcceb2d4b69f26fb11800c0283e15fbf74ffa4eafb984030394f3c2ea6733cc0eacb0431a9475eff28f00b7f55314bfd9d441c1c624e241908228fe4da3d3a0a7fbd56814e1c8cd5d3e00f430f33a786675271736fd728c7bf7428b8c24ac948d7faf76ddb8783a496c0048fc235ead8d4b9d44929662a6384074fc4e5076bec5b7deb34f612393684300fd9b61cb1ad9b4b28f58399906e73933e3cccee8fc98a393f0eedb95b13ee63f0000000000000000000000000000000000000000000000000000000000182000000000000000000000000000000000000000000000000000000000000018200a0000000000000000000000000000000000000000000000000000000000182001000000000000000000000000000000000000000000000000000000000018200b0000000000000000000000000000000000000000000000000000000000182002000000000000000000000000000000000000000000000000000000000018200c0000000000000000000000000000000000000000000000000000000000182003000000000000000000000000000000000000000000000000000000000018200d0000000000000000000000000000000000000000000000000000000000182004000000000000000000000000000000000000000000000000000000000018200e0000000000000000000000000000000000000000000000000000000000182005000000000000000000000000000000000000000000000000000000000018200f00000000000000000000000000000000000000000000000000000000001820060000000000000000000000000000000000000000000000000000000000182010000000000000000000000000000000000000000000000000000000000018200700000000000000000000000000000000000000000000000000000000001820110000000000000000000000000000000000000000000000000000000000182008000000000000000000000000000000000000000000000000000000000018201200000000000000000000000000000000000000000000000000000000001820090000000000000000000000000000000000000000000000000000000000182013000000000000000000000000000000000000000000000000000000000018200a0000000000000000000000000000000000000000000000000000000000182014000000000000000000000000000000000000000000000000000000000018200b0000000000000000000000000000000000000000000000000000000000182015000000000000000000000000000000000000000000000000000000000018200c0000000000000000000000000000000000000000000000000000000000182016000000000000000000000000000000000000000000000000000000000018200d0000000000000000000000000000000000000000000000000000000000182017000000000000000000000000000000000000000000000000000000000018200e0000000000000000000000000000000000000000000000000000000000182018000000000000000000000000000000000000000000000000000000000018200f00000000000000000000000000000000000000000000000000000000001820190000000000000000000000000000000000000000000000000000000000182010000000000000000000000000000000000000000000000000000000000018201a0000000000000000000000000000000000000000000000000000000000182011000000000000000000000000000000000000000000000000000000000018201b0000000000000000000000000000000000000000000000000000000000182012000000000000000000000000000000000000000000000000000000000018201c0000000000000000000000000000000000000000000000000000000000182013000000000000000000000000000000000000000000000000000000000018201d0000000000000000000000000000000000000000000000000000000000182014000000000000000000000000000000000000000000000000000000000018201e0000000000000000000000000000000000000000000000000000000000182015000000000000000000000000000000000000000000000000000000000018201f00000000000000000000000000000000000000000000000000000000001820160000000000000000000000000000000000000000000000000000000000182020000000000000000000000000000000000000000000000000000000000018201700000000000000000000000000000000000000000000000000000000001820210000000000000000000000000000000000000000000000000000000000182018000000000000000000000000000000000000000000000000000000000018202200000000000000000000000000000000000000000000000000000000001820190000000000000000000000000000000000000000000000000000000000182023000000000000000000000000000000000000000000000000000000000018201a0000000000000000000000000000000000000000000000000000000000182024000000000000000000000000000000000000000000000000000000000018201b0000000000000000000000000000000000000000000000000000000000182025000000000000000000000000000000000000000000000000000000000018201c0000000000000000000000000000000000000000000000000000000000182026000000000000000000000000000000000000000000000000000000000018201d0000000000000000000000000000000000000000000000000000000000182027000000000000000000000000000000000000000000000000000000000018201e0000000000000000000000000000000000000000000000000000000000182028000000000000000000000000000000000000000000000000000000000018201f00000000000000000000000000000000000000000000000000000000001820290000000000000000000000000000000000000000000000000000000000182020000000000000000000000000000000000000000000000000000000000018202a0000000000000000000000000000000000000000000000000000000000182021000000000000000000000000000000000000000000000000000000000018202b0000000000000000000000000000000000000000000000000000000000182022000000000000000000000000000000000000000000000000000000000018202c0000000000000000000000000000000000000000000000000000000000182023000000000000000000000000000000000000000000000000000000000018202d0000000000000000000000000000000000000000000000000000000000182024000000000000000000000000000000000000000000000000000000000018202e0000000000000000000000000000000000000000000000000000000000182025000000000000000000000000000000000000000000000000000000000018202f00000000000000000000000000000000000000000000000000000000001820260000000000000000000000000000000000000000000000000000000000182030000000000000000000000000000000000000000000000000000000000018202700000000000000000000000000000000000000000000000000000000001820310000000000000000000000000000000000000000000000000000000000182028000000000000000000000000000000000000000000000000000000000018203200000000000000000000000000000000000000000000000000000000001820290000000000000000000000000000000000000000000000000000000000182033000000000000000000000000000000000000000000000000000000000018202a0000000000000000000000000000000000000000000000000000000000182034000000000000000000000000000000000000000000000000000000000018202b0000000000000000000000000000000000000000000000000000000000182035000000000000000000000000000000000000000000000000000000000018202c0000000000000000000000000000000000000000000000000000000000182036000000000000000000000000000000000000000000000000000000000018202d0000000000000000000000000000000000000000000000000000000000182037000000000000000000000000000000000000000000000000000000000018202e0000000000000000000000000000000000000000000000000000000000182038000000000000000000000000000000000000000000000000000000000018202f00000000000000000000000000000000000000000000000000000000001820390000000000000000000000000000000000000000000000000000000000182030000000000000000000000000000000000000000000000000000000000018203a0000000000000000000000000000000000000000000000000000000000182031000000000000000000000000000000000000000000000000000000000018203b0000000000000000000000000000000000000000000000000000000000182032000000000000000000000000000000000000000000000000000000000018203c0000000000000000000000000000000000000000000000000000000000182033000000000000000000000000000000000000000000000000000000000018203d0000000000000000000000000000000000000000000000000000000000182034000000000000000000000000000000000000000000000000000000000018203e0000000000000000000000000000000000000000000000000000000000182035000000000000000000000000000000000000000000000000000000000018203f00000000000000000000000000000000000000000000000000000000001820360000000000000000000000000000000000000000000000000000000000182040000000000000000000000000000000000000000000000000000000000018203700000000000000000000000000000000000000000000000000000000001820410000000000000000000000000000000000000000000000000000000000182038000000000000000000000000000000000000000000000000000000000018204200000000000000000000000000000000000000000000000000000000001820390000000000000000000000000000000000000000000000000000000000182043000000000000000000000000000000000000000000000000000000000018203a0000000000000000000000000000000000000000000000000000000000182044000000000000000000000000000000000000000000000000000000000018203b0000000000000000000000000000000000000000000000000000000000182045000000000000000000000000000000000000000000000000000000000018203c0000000000000000000000000000000000000000000000000000000000182046000000000000000000000000000000000000000000000000000000000018203d0000000000000000000000000000000000000000000000000000000000182047000000000000000000000000000000000000000000000000000000000018203e00000000000000000000000000000000000000000000000000000000001820480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000001c100000000000000000000000000000000000000000000000000000000000001c100100000000000000000000000000000000000000000000000000000000001c100200000000000000000000000000000000000000000000000000000000001c100300000000000000000000000000000000000000000000000000000000001c100400000000000000000000000000000000000000000000000000000000001c100500000000000000000000000000000000000000000000000000000000001c100600000000000000000000000000000000000000000000000000000000001c100700000000000000000000000000000000000000000000000000000000001c100800000000000000000000000000000000000000000000000000000000001c100900000000000000000000000000000000000000000000000000000000001c100a00000000000000000000000000000000000000000000000000000000001c100b00000000000000000000000000000000000000000000000000000000001c100c00000000000000000000000000000000000000000000000000000000001c100d00000000000000000000000000000000000000000000000000000000001c100e00000000000000000000000000000000000000000000000000000000001c100f00000000000000000000000000000000000000000000000000000000001c101000000000000000000000000000000000000000000000000000000000001c101100000000000000000000000000000000000000000000000000000000001c101200000000000000000000000000000000000000000000000000000000001c101300000000000000000000000000000000000000000000000000000000001c101400000000000000000000000000000000000000000000000000000000001c101500000000000000000000000000000000000000000000000000000000001c101600000000000000000000000000000000000000000000000000000000001c101700000000000000000000000000000000000000000000000000000000001c101800000000000000000000000000000000000000000000000000000000001c101900000000000000000000000000000000000000000000000000000000001c101a00000000000000000000000000000000000000000000000000000000001c101b00000000000000000000000000000000000000000000000000000000001c101c00000000000000000000000000000000000000000000000000000000001c101d00000000000000000000000000000000000000000000000000000000001c101e00000000000000000000000000000000000000000000000000000000001c101f00000000000000000000000000000000000000000000000000000000001c102000000000000000000000000000000000000000000000000000000000001c102100000000000000000000000000000000000000000000000000000000001c102200000000000000000000000000000000000000000000000000000000001c102300000000000000000000000000000000000000000000000000000000001c102400000000000000000000000000000000000000000000000000000000001c102500000000000000000000000000000000000000000000000000000000001c102600000000000000000000000000000000000000000000000000000000001c102700000000000000000000000000000000000000000000000000000000001c102800000000000000000000000000000000000000000000000000000000001c102900000000000000000000000000000000000000000000000000000000001c102a00000000000000000000000000000000000000000000000000000000001c102b00000000000000000000000000000000000000000000000000000000001c102c00000000000000000000000000000000000000000000000000000000001c102d00000000000000000000000000000000000000000000000000000000001c102e00000000000000000000000000000000000000000000000000000000001c102f00000000000000000000000000000000000000000000000000000000001c103000000000000000000000000000000000000000000000000000000000001c103100000000000000000000000000000000000000000000000000000000001c103200000000000000000000000000000000000000000000000000000000001c103300000000000000000000000000000000000000000000000000000000001c103400000000000000000000000000000000000000000000000000000000001c103500000000000000000000000000000000000000000000000000000000001c103600000000000000000000000000000000000000000000000000000000001c103700000000000000000000000000000000000000000000000000000000001c103800000000000000000000000000000000000000000000000000000000001c103900000000000000000000000000000000000000000000000000000000001c103a00000000000000000000000000000000000000000000000000000000001c103b00000000000000000000000000000000000000000000000000000000001c103c00000000000000000000000000000000000000000000000000000000001c103d00000000000000000000000000000000000000000000000000000000001c103e00000000000000000000000000000000000000000000000000000000001c103f3f00000000000000000000000000000000000000000000000000000000001c110000000000000000000000000000000000000000000000000000000000001c110100000000000000000000000000000000000000000000000000000000001c110200000000000000000000000000000000000000000000000000000000001c110300000000000000000000000000000000000000000000000000000000001c110400000000000000000000000000000000000000000000000000000000001c110500000000000000000000000000000000000000000000000000000000001c110600000000000000000000000000000000000000000000000000000000001c110700000000000000000000000000000000000000000000000000000000001c110800000000000000000000000000000000000000000000000000000000001c110900000000000000000000000000000000000000000000000000000000001c110a00000000000000000000000000000000000000000000000000000000001c110b00000000000000000000000000000000000000000000000000000000001c110c00000000000000000000000000000000000000000000000000000000001c110d00000000000000000000000000000000000000000000000000000000001c110e00000000000000000000000000000000000000000000000000000000001c110f00000000000000000000000000000000000000000000000000000000001c111000000000000000000000000000000000000000000000000000000000001c111100000000000000000000000000000000000000000000000000000000001c111200000000000000000000000000000000000000000000000000000000001c111300000000000000000000000000000000000000000000000000000000001c111400000000000000000000000000000000000000000000000000000000001c111500000000000000000000000000000000000000000000000000000000001c111600000000000000000000000000000000000000000000000000000000001c111700000000000000000000000000000000000000000000000000000000001c111800000000000000000000000000000000000000000000000000000000001c111900000000000000000000000000000000000000000000000000000000001c111a00000000000000000000000000000000000000000000000000000000001c111b00000000000000000000000000000000000000000000000000000000001c111c00000000000000000000000000000000000000000000000000000000001c111d00000000000000000000000000000000000000000000000000000000001c111e00000000000000000000000000000000000000000000000000000000001c111f00000000000000000000000000000000000000000000000000000000001c112000000000000000000000000000000000000000000000000000000000001c112100000000000000000000000000000000000000000000000000000000001c112200000000000000000000000000000000000000000000000000000000001c112300000000000000000000000000000000000000000000000000000000001c112400000000000000000000000000000000000000000000000000000000001c112500000000000000000000000000000000000000000000000000000000001c112600000000000000000000000000000000000000000000000000000000001c112700000000000000000000000000000000000000000000000000000000001c112800000000000000000000000000000000000000000000000000000000001c112900000000000000000000000000000000000000000000000000000000001c112a00000000000000000000000000000000000000000000000000000000001c112b00000000000000000000000000000000000000000000000000000000001c112c00000000000000000000000000000000000000000000000000000000001c112d00000000000000000000000000000000000000000000000000000000001c112e00000000000000000000000000000000000000000000000000000000001c112f00000000000000000000000000000000000000000000000000000000001c113000000000000000000000000000000000000000000000000000000000001c113100000000000000000000000000000000000000000000000000000000001c113200000000000000000000000000000000000000000000000000000000001c113300000000000000000000000000000000000000000000000000000000001c113400000000000000000000000000000000000000000000000000000000001c113500000000000000000000000000000000000000000000000000000000001c113600000000000000000000000000000000000000000000000000000000001c113700000000000000000000000000000000000000000000000000000000001c113800000000000000000000000000000000000000000000000000000000001c113900000000000000000000000000000000000000000000000000000000001c113a00000000000000000000000000000000000000000000000000000000001c113b00000000000000000000000000000000000000000000000000000000001c113c00000000000000000000000000000000000000000000000000000000001c113d00000000000000000000000000000000000000000000000000000000001c113e08006838aa99533bea0d4204cad17cb3c147e99c2f9089e54a4289d54733eeada2002ab314bd11ace2494a3fb0970d276da39f0fe7da19c9a2438b9c7c334d32470071703d79d8425a7eca52006df6a8f9728508a83639e3e1c2ebae2b853a087c00c9501ac04a78ac5413c9131b08708064ed2c2515b8893f12c2d1cda15a44f100a0955f93e109778d26f9e5b0d46e45c539e59b0941517bfa888eb2d7d2d8a6005adc3be9406cc5f102c6adb44746e8529a256e2396353a8659344cc3e914c4007a5fe572cf6af804f472dabf095c5eb6b30efc5fd627ad3245a8ef0f3f578c003dcaa91dfc9fdad7ba8da68a48fc662dfc0a995cbb0c1bc62099c8257d240d3f00000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000001c200a00000000000000000000000000000000000000000000000000000000001c200100000000000000000000000000000000000000000000000000000000001c200b00000000000000000000000000000000000000000000000000000000001c200200000000000000000000000000000000000000000000000000000000001c200c00000000000000000000000000000000000000000000000000000000001c200300000000000000000000000000000000000000000000000000000000001c200d00000000000000000000000000000000000000000000000000000000001c200400000000000000000000000000000000000000000000000000000000001c200e00000000000000000000000000000000000000000000000000000000001c200500000000000000000000000000000000000000000000000000000000001c200f00000000000000000000000000000000000000000000000000000000001c200600000000000000000000000000000000000000000000000000000000001c201000000000000000000000000000000000000000000000000000000000001c200700000000000000000000000000000000000000000000000000000000001c201100000000000000000000000000000000000000000000000000000000001c200800000000000000000000000000000000000000000000000000000000001c201200000000000000000000000000000000000000000000000000000000001c200900000000000000000000000000000000000000000000000000000000001c201300000000000000000000000000000000000000000000000000000000001c200a00000000000000000000000000000000000000000000000000000000001c201400000000000000000000000000000000000000000000000000000000001c200b00000000000000000000000000000000000000000000000000000000001c201500000000000000000000000000000000000000000000000000000000001c200c00000000000000000000000000000000000000000000000000000000001c201600000000000000000000000000000000000000000000000000000000001c200d00000000000000000000000000000000000000000000000000000000001c201700000000000000000000000000000000000000000000000000000000001c200e00000000000000000000000000000000000000000000000000000000001c201800000000000000000000000000000000000000000000000000000000001c200f00000000000000000000000000000000000000000000000000000000001c201900000000000000000000000000000000000000000000000000000000001c201000000000000000000000000000000000000000000000000000000000001c201a00000000000000000000000000000000000000000000000000000000001c201100000000000000000000000000000000000000000000000000000000001c201b00000000000000000000000000000000000000000000000000000000001c201200000000000000000000000000000000000000000000000000000000001c201c00000000000000000000000000000000000000000000000000000000001c201300000000000000000000000000000000000000000000000000000000001c201d00000000000000000000000000000000000000000000000000000000001c201400000000000000000000000000000000000000000000000000000000001c201e00000000000000000000000000000000000000000000000000000000001c201500000000000000000000000000000000000000000000000000000000001c201f00000000000000000000000000000000000000000000000000000000001c201600000000000000000000000000000000000000000000000000000000001c202000000000000000000000000000000000000000000000000000000000001c201700000000000000000000000000000000000000000000000000000000001c202100000000000000000000000000000000000000000000000000000000001c201800000000000000000000000000000000000000000000000000000000001c202200000000000000000000000000000000000000000000000000000000001c201900000000000000000000000000000000000000000000000000000000001c202300000000000000000000000000000000000000000000000000000000001c201a00000000000000000000000000000000000000000000000000000000001c202400000000000000000000000000000000000000000000000000000000001c201b00000000000000000000000000000000000000000000000000000000001c202500000000000000000000000000000000000000000000000000000000001c201c00000000000000000000000000000000000000000000000000000000001c202600000000000000000000000000000000000000000000000000000000001c201d00000000000000000000000000000000000000000000000000000000001c202700000000000000000000000000000000000000000000000000000000001c201e00000000000000000000000000000000000000000000000000000000001c202800000000000000000000000000000000000000000000000000000000001c201f00000000000000000000000000000000000000000000000000000000001c202900000000000000000000000000000000000000000000000000000000001c202000000000000000000000000000000000000000000000000000000000001c202a00000000000000000000000000000000000000000000000000000000001c202100000000000000000000000000000000000000000000000000000000001c202b00000000000000000000000000000000000000000000000000000000001c202200000000000000000000000000000000000000000000000000000000001c202c00000000000000000000000000000000000000000000000000000000001c202300000000000000000000000000000000000000000000000000000000001c202d00000000000000000000000000000000000000000000000000000000001c202400000000000000000000000000000000000000000000000000000000001c202e00000000000000000000000000000000000000000000000000000000001c202500000000000000000000000000000000000000000000000000000000001c202f00000000000000000000000000000000000000000000000000000000001c202600000000000000000000000000000000000000000000000000000000001c203000000000000000000000000000000000000000000000000000000000001c202700000000000000000000000000000000000000000000000000000000001c203100000000000000000000000000000000000000000000000000000000001c202800000000000000000000000000000000000000000000000000000000001c203200000000000000000000000000000000000000000000000000000000001c202900000000000000000000000000000000000000000000000000000000001c203300000000000000000000000000000000000000000000000000000000001c202a00000000000000000000000000000000000000000000000000000000001c203400000000000000000000000000000000000000000000000000000000001c202b00000000000000000000000000000000000000000000000000000000001c203500000000000000000000000000000000000000000000000000000000001c202c00000000000000000000000000000000000000000000000000000000001c203600000000000000000000000000000000000000000000000000000000001c202d00000000000000000000000000000000000000000000000000000000001c203700000000000000000000000000000000000000000000000000000000001c202e00000000000000000000000000000000000000000000000000000000001c203800000000000000000000000000000000000000000000000000000000001c202f00000000000000000000000000000000000000000000000000000000001c203900000000000000000000000000000000000000000000000000000000001c203000000000000000000000000000000000000000000000000000000000001c203a00000000000000000000000000000000000000000000000000000000001c203100000000000000000000000000000000000000000000000000000000001c203b00000000000000000000000000000000000000000000000000000000001c203200000000000000000000000000000000000000000000000000000000001c203c00000000000000000000000000000000000000000000000000000000001c203300000000000000000000000000000000000000000000000000000000001c203d00000000000000000000000000000000000000000000000000000000001c203400000000000000000000000000000000000000000000000000000000001c203e00000000000000000000000000000000000000000000000000000000001c203500000000000000000000000000000000000000000000000000000000001c203f00000000000000000000000000000000000000000000000000000000001c203600000000000000000000000000000000000000000000000000000000001c204000000000000000000000000000000000000000000000000000000000001c203700000000000000000000000000000000000000000000000000000000001c204100000000000000000000000000000000000000000000000000000000001c203800000000000000000000000000000000000000000000000000000000001c204200000000000000000000000000000000000000000000000000000000001c203900000000000000000000000000000000000000000000000000000000001c204300000000000000000000000000000000000000000000000000000000001c203a00000000000000000000000000000000000000000000000000000000001c204400000000000000000000000000000000000000000000000000000000001c203b00000000000000000000000000000000000000000000000000000000001c204500000000000000000000000000000000000000000000000000000000001c203c00000000000000000000000000000000000000000000000000000000001c204600000000000000000000000000000000000000000000000000000000001c203d00000000000000000000000000000000000000000000000000000000001c204700000000000000000000000000000000000000000000000000000000001c203e00000000000000000000000000000000000000000000000000000000001c2048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000201000000000000000000000000000000000000000000000000000000000000020100100000000000000000000000000000000000000000000000000000000002010020000000000000000000000000000000000000000000000000000000000201003000000000000000000000000000000000000000000000000000000000020100400000000000000000000000000000000000000000000000000000000002010050000000000000000000000000000000000000000000000000000000000201006000000000000000000000000000000000000000000000000000000000020100700000000000000000000000000000000000000000000000000000000002010080000000000000000000000000000000000000000000000000000000000201009000000000000000000000000000000000000000000000000000000000020100a000000000000000000000000000000000000000000000000000000000020100b000000000000000000000000000000000000000000000000000000000020100c000000000000000000000000000000000000000000000000000000000020100d000000000000000000000000000000000000000000000000000000000020100e000000000000000000000000000000000000000000000000000000000020100f0000000000000000000000000000000000000000000000000000000000201010000000000000000000000000000000000000000000000000000000000020101100000000000000000000000000000000000000000000000000000000002010120000000000000000000000000000000000000000000000000000000000201013000000000000000000000000000000000000000000000000000000000020101400000000000000000000000000000000000000000000000000000000002010150000000000000000000000000000000000000000000000000000000000201016000000000000000000000000000000000000000000000000000000000020101700000000000000000000000000000000000000000000000000000000002010180000000000000000000000000000000000000000000000000000000000201019000000000000000000000000000000000000000000000000000000000020101a000000000000000000000000000000000000000000000000000000000020101b000000000000000000000000000000000000000000000000000000000020101c000000000000000000000000000000000000000000000000000000000020101d000000000000000000000000000000000000000000000000000000000020101e000000000000000000000000000000000000000000000000000000000020101f0000000000000000000000000000000000000000000000000000000000201020000000000000000000000000000000000000000000000000000000000020102100000000000000000000000000000000000000000000000000000000002010220000000000000000000000000000000000000000000000000000000000201023000000000000000000000000000000000000000000000000000000000020102400000000000000000000000000000000000000000000000000000000002010250000000000000000000000000000000000000000000000000000000000201026000000000000000000000000000000000000000000000000000000000020102700000000000000000000000000000000000000000000000000000000002010280000000000000000000000000000000000000000000000000000000000201029000000000000000000000000000000000000000000000000000000000020102a000000000000000000000000000000000000000000000000000000000020102b000000000000000000000000000000000000000000000000000000000020102c000000000000000000000000000000000000000000000000000000000020102d000000000000000000000000000000000000000000000000000000000020102e000000000000000000000000000000000000000000000000000000000020102f0000000000000000000000000000000000000000000000000000000000201030000000000000000000000000000000000000000000000000000000000020103100000000000000000000000000000000000000000000000000000000002010320000000000000000000000000000000000000000000000000000000000201033000000000000000000000000000000000000000000000000000000000020103400000000000000000000000000000000000000000000000000000000002010350000000000000000000000000000000000000000000000000000000000201036000000000000000000000000000000000000000000000000000000000020103700000000000000000000000000000000000000000000000000000000002010380000000000000000000000000000000000000000000000000000000000201039000000000000000000000000000000000000000000000000000000000020103a000000000000000000000000000000000000000000000000000000000020103b000000000000000000000000000000000000000000000000000000000020103c000000000000000000000000000000000000000000000000000000000020103d000000000000000000000000000000000000000000000000000000000020103e000000000000000000000000000000000000000000000000000000000020103f3f0000000000000000000000000000000000000000000000000000000000201100000000000000000000000000000000000000000000000000000000000020110100000000000000000000000000000000000000000000000000000000002011020000000000000000000000000000000000000000000000000000000000201103000000000000000000000000000000000000000000000000000000000020110400000000000000000000000000000000000000000000000000000000002011050000000000000000000000000000000000000000000000000000000000201106000000000000000000000000000000000000000000000000000000000020110700000000000000000000000000000000000000000000000000000000002011080000000000000000000000000000000000000000000000000000000000201109000000000000000000000000000000000000000000000000000000000020110a000000000000000000000000000000000000000000000000000000000020110b000000000000000000000000000000000000000000000000000000000020110c000000000000000000000000000000000000000000000000000000000020110d000000000000000000000000000000000000000000000000000000000020110e000000000000000000000000000000000000000000000000000000000020110f0000000000000000000000000000000000000000000000000000000000201110000000000000000000000000000000000000000000000000000000000020111100000000000000000000000000000000000000000000000000000000002011120000000000000000000000000000000000000000000000000000000000201113000000000000000000000000000000000000000000000000000000000020111400000000000000000000000000000000000000000000000000000000002011150000000000000000000000000000000000000000000000000000000000201116000000000000000000000000000000000000000000000000000000000020111700000000000000000000000000000000000000000000000000000000002011180000000000000000000000000000000000000000000000000000000000201119000000000000000000000000000000000000000000000000000000000020111a000000000000000000000000000000000000000000000000000000000020111b000000000000000000000000000000000000000000000000000000000020111c000000000000000000000000000000000000000000000000000000000020111d000000000000000000000000000000000000000000000000000000000020111e000000000000000000000000000000000000000000000000000000000020111f0000000000000000000000000000000000000000000000000000000000201120000000000000000000000000000000000000000000000000000000000020112100000000000000000000000000000000000000000000000000000000002011220000000000000000000000000000000000000000000000000000000000201123000000000000000000000000000000000000000000000000000000000020112400000000000000000000000000000000000000000000000000000000002011250000000000000000000000000000000000000000000000000000000000201126000000000000000000000000000000000000000000000000000000000020112700000000000000000000000000000000000000000000000000000000002011280000000000000000000000000000000000000000000000000000000000201129000000000000000000000000000000000000000000000000000000000020112a000000000000000000000000000000000000000000000000000000000020112b000000000000000000000000000000000000000000000000000000000020112c000000000000000000000000000000000000000000000000000000000020112d000000000000000000000000000000000000000000000000000000000020112e000000000000000000000000000000000000000000000000000000000020112f0000000000000000000000000000000000000000000000000000000000201130000000000000000000000000000000000000000000000000000000000020113100000000000000000000000000000000000000000000000000000000002011320000000000000000000000000000000000000000000000000000000000201133000000000000000000000000000000000000000000000000000000000020113400000000000000000000000000000000000000000000000000000000002011350000000000000000000000000000000000000000000000000000000000201136000000000000000000000000000000000000000000000000000000000020113700000000000000000000000000000000000000000000000000000000002011380000000000000000000000000000000000000000000000000000000000201139000000000000000000000000000000000000000000000000000000000020113a000000000000000000000000000000000000000000000000000000000020113b000000000000000000000000000000000000000000000000000000000020113c000000000000000000000000000000000000000000000000000000000020113d000000000000000000000000000000000000000000000000000000000020113e0800e9805e8a4faa87fc419af08a6d956f18976c46ea694bbd4cf6946e6d02033200e0925a6b172b4b01bb76eb1d3f7dd2ced118bca70d223a6d61afa1b75915ae00383590492d2f99a0283d1de57015b4b6b0759a8023af2c68fb4929dee2f303007ed57100dd77e2b6405f780503ef61b7b53e13f344b6e6a6eff3e3c13de0d0001ab1b0c348c46184dbc86ff79f248e7da1b09d3f9c6a986e98fe45389f060d0023d134bc68d7efa25e255001069827dc0bee766c08c988d6300071ed27fe6c0031cbb780b07f632cbaf767dc80608cc0a8e1d1df3ecd6f5d8bc0ca6703e4f4002c7dc9e731fc5f6456b2a70b4e636ac17d5e0cd36d3a591116a9e124f735863f0000000000000000000000000000000000000000000000000000000000202000000000000000000000000000000000000000000000000000000000000020200a0000000000000000000000000000000000000000000000000000000000202001000000000000000000000000000000000000000000000000000000000020200b0000000000000000000000000000000000000000000000000000000000202002000000000000000000000000000000000000000000000000000000000020200c0000000000000000000000000000000000000000000000000000000000202003000000000000000000000000000000000000000000000000000000000020200d0000000000000000000000000000000000000000000000000000000000202004000000000000000000000000000000000000000000000000000000000020200e0000000000000000000000000000000000000000000000000000000000202005000000000000000000000000000000000000000000000000000000000020200f00000000000000000000000000000000000000000000000000000000002020060000000000000000000000000000000000000000000000000000000000202010000000000000000000000000000000000000000000000000000000000020200700000000000000000000000000000000000000000000000000000000002020110000000000000000000000000000000000000000000000000000000000202008000000000000000000000000000000000000000000000000000000000020201200000000000000000000000000000000000000000000000000000000002020090000000000000000000000000000000000000000000000000000000000202013000000000000000000000000000000000000000000000000000000000020200a0000000000000000000000000000000000000000000000000000000000202014000000000000000000000000000000000000000000000000000000000020200b0000000000000000000000000000000000000000000000000000000000202015000000000000000000000000000000000000000000000000000000000020200c0000000000000000000000000000000000000000000000000000000000202016000000000000000000000000000000000000000000000000000000000020200d0000000000000000000000000000000000000000000000000000000000202017000000000000000000000000000000000000000000000000000000000020200e0000000000000000000000000000000000000000000000000000000000202018000000000000000000000000000000000000000000000000000000000020200f00000000000000000000000000000000000000000000000000000000002020190000000000000000000000000000000000000000000000000000000000202010000000000000000000000000000000000000000000000000000000000020201a0000000000000000000000000000000000000000000000000000000000202011000000000000000000000000000000000000000000000000000000000020201b0000000000000000000000000000000000000000000000000000000000202012000000000000000000000000000000000000000000000000000000000020201c0000000000000000000000000000000000000000000000000000000000202013000000000000000000000000000000000000000000000000000000000020201d0000000000000000000000000000000000000000000000000000000000202014000000000000000000000000000000000000000000000000000000000020201e0000000000000000000000000000000000000000000000000000000000202015000000000000000000000000000000000000000000000000000000000020201f00000000000000000000000000000000000000000000000000000000002020160000000000000000000000000000000000000000000000000000000000202020000000000000000000000000000000000000000000000000000000000020201700000000000000000000000000000000000000000000000000000000002020210000000000000000000000000000000000000000000000000000000000202018000000000000000000000000000000000000000000000000000000000020202200000000000000000000000000000000000000000000000000000000002020190000000000000000000000000000000000000000000000000000000000202023000000000000000000000000000000000000000000000000000000000020201a0000000000000000000000000000000000000000000000000000000000202024000000000000000000000000000000000000000000000000000000000020201b0000000000000000000000000000000000000000000000000000000000202025000000000000000000000000000000000000000000000000000000000020201c0000000000000000000000000000000000000000000000000000000000202026000000000000000000000000000000000000000000000000000000000020201d0000000000000000000000000000000000000000000000000000000000202027000000000000000000000000000000000000000000000000000000000020201e0000000000000000000000000000000000000000000000000000000000202028000000000000000000000000000000000000000000000000000000000020201f00000000000000000000000000000000000000000000000000000000002020290000000000000000000000000000000000000000000000000000000000202020000000000000000000000000000000000000000000000000000000000020202a0000000000000000000000000000000000000000000000000000000000202021000000000000000000000000000000000000000000000000000000000020202b0000000000000000000000000000000000000000000000000000000000202022000000000000000000000000000000000000000000000000000000000020202c0000000000000000000000000000000000000000000000000000000000202023000000000000000000000000000000000000000000000000000000000020202d0000000000000000000000000000000000000000000000000000000000202024000000000000000000000000000000000000000000000000000000000020202e0000000000000000000000000000000000000000000000000000000000202025000000000000000000000000000000000000000000000000000000000020202f00000000000000000000000000000000000000000000000000000000002020260000000000000000000000000000000000000000000000000000000000202030000000000000000000000000000000000000000000000000000000000020202700000000000000000000000000000000000000000000000000000000002020310000000000000000000000000000000000000000000000000000000000202028000000000000000000000000000000000000000000000000000000000020203200000000000000000000000000000000000000000000000000000000002020290000000000000000000000000000000000000000000000000000000000202033000000000000000000000000000000000000000000000000000000000020202a0000000000000000000000000000000000000000000000000000000000202034000000000000000000000000000000000000000000000000000000000020202b0000000000000000000000000000000000000000000000000000000000202035000000000000000000000000000000000000000000000000000000000020202c0000000000000000000000000000000000000000000000000000000000202036000000000000000000000000000000000000000000000000000000000020202d0000000000000000000000000000000000000000000000000000000000202037000000000000000000000000000000000000000000000000000000000020202e0000000000000000000000000000000000000000000000000000000000202038000000000000000000000000000000000000000000000000000000000020202f00000000000000000000000000000000000000000000000000000000002020390000000000000000000000000000000000000000000000000000000000202030000000000000000000000000000000000000000000000000000000000020203a0000000000000000000000000000000000000000000000000000000000202031000000000000000000000000000000000000000000000000000000000020203b0000000000000000000000000000000000000000000000000000000000202032000000000000000000000000000000000000000000000000000000000020203c0000000000000000000000000000000000000000000000000000000000202033000000000000000000000000000000000000000000000000000000000020203d0000000000000000000000000000000000000000000000000000000000202034000000000000000000000000000000000000000000000000000000000020203e0000000000000000000000000000000000000000000000000000000000202035000000000000000000000000000000000000000000000000000000000020203f00000000000000000000000000000000000000000000000000000000002020360000000000000000000000000000000000000000000000000000000000202040000000000000000000000000000000000000000000000000000000000020203700000000000000000000000000000000000000000000000000000000002020410000000000000000000000000000000000000000000000000000000000202038000000000000000000000000000000000000000000000000000000000020204200000000000000000000000000000000000000000000000000000000002020390000000000000000000000000000000000000000000000000000000000202043000000000000000000000000000000000000000000000000000000000020203a0000000000000000000000000000000000000000000000000000000000202044000000000000000000000000000000000000000000000000000000000020203b0000000000000000000000000000000000000000000000000000000000202045000000000000000000000000000000000000000000000000000000000020203c0000000000000000000000000000000000000000000000000000000000202046000000000000000000000000000000000000000000000000000000000020203d0000000000000000000000000000000000000000000000000000000000202047000000000000000000000000000000000000000000000000000000000020203e0000000000000000000000000000000000000000000000000000000000202048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "txsEffectsHash": "0x00d2d12b4d0c6202124a7625c585097078920e09dd2c650401a91b564234a6b4", "decodedHeader": { "contentCommitment": { "inHash": "0x00e1371045bd7d2c3e1f19cba5f536f0e82042ba4bc257d4ba19c146215e8242", "outHash": "0x009514581058b2b6aae79574cc9129a801904407c6d869a5f168b02cebffecfe", "numTxs": 8, - "txsEffectsHash": "0x006355bc5a5a6353eca00eac5e4aede081b359a25bcf81604aacd84dd1947561" + "txsEffectsHash": "0x00d2d12b4d0c6202124a7625c585097078920e09dd2c650401a91b564234a6b4" }, "globalVariables": { "blockNumber": 2, "slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000023", "chainId": 31337, - "timestamp": 1731106635, + "timestamp": 1731434221, "version": 1, - "coinbase": "0xe1b76c7e0eb80841fed024c0470d663250bdd96e", - "feeRecipient": "0x1f1730e56d57b24d909d5eae3094c83900c3fb2fa90e248dfddb825f2e4e55e8", + "coinbase": "0xa8f1a4313bc15dcd3681ed2b6fdd042f1ee1f823", + "feeRecipient": "0x2abdc96d2ec8465dfd2bb7401f90dd3af0db16c3cece57bd5de2b63a3d25140b", "gasFees": { "feePerDaGas": 0, "feePerL2Gas": 0 @@ -116,7 +116,7 @@ }, "lastArchive": { "nextAvailableLeafIndex": 2, - "root": "0x0f5694321be22526e5a7e857ed9fc4afc006c5bc9052bea6449ec3adee9a2ba9" + "root": "0x13232b1c92fcfba5f94aee813d7e454764f93d6292215552b8c973ef42c8e396" }, "stateReference": { "l1ToL2MessageTree": { @@ -139,8 +139,8 @@ } } }, - "header": "0x0f5694321be22526e5a7e857ed9fc4afc006c5bc9052bea6449ec3adee9a2ba9000000020000000000000000000000000000000000000000000000000000000000000008006355bc5a5a6353eca00eac5e4aede081b359a25bcf81604aacd84dd194756100e1371045bd7d2c3e1f19cba5f536f0e82042ba4bc257d4ba19c146215e8242009514581058b2b6aae79574cc9129a801904407c6d869a5f168b02cebffecfe026efb6c2a517de2448119d0f1255757265dbec7cdd2952df929ede666e10944000000202494d2575971bca59a28ddc774d19136f4a294951ab67258c7e9c2d8f9805924000002002ed5c359f01d6a1cacfa324bc48b7fcc6fe75a95ad66bdb1a6e32d69075509570000028023a39db7c42fa47a6df2b9deea545155c39f6066cbbc2701a12c60af95b6cdf9000002800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002300000000000000000000000000000000000000000000000000000000672e974be1b76c7e0eb80841fed024c0470d663250bdd96e1f1730e56d57b24d909d5eae3094c83900c3fb2fa90e248dfddb825f2e4e55e8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "publicInputsHash": "0x00ea263f29ec2e0b891daece07ec0eff5ebfcf733ce126a50fc364b81c67f5ad", + "header": "0x13232b1c92fcfba5f94aee813d7e454764f93d6292215552b8c973ef42c8e39600000002000000000000000000000000000000000000000000000000000000000000000800d2d12b4d0c6202124a7625c585097078920e09dd2c650401a91b564234a6b400e1371045bd7d2c3e1f19cba5f536f0e82042ba4bc257d4ba19c146215e8242009514581058b2b6aae79574cc9129a801904407c6d869a5f168b02cebffecfe026efb6c2a517de2448119d0f1255757265dbec7cdd2952df929ede666e10944000000202494d2575971bca59a28ddc774d19136f4a294951ab67258c7e9c2d8f9805924000002002ed5c359f01d6a1cacfa324bc48b7fcc6fe75a95ad66bdb1a6e32d69075509570000028023a39db7c42fa47a6df2b9deea545155c39f6066cbbc2701a12c60af95b6cdf9000002800000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002300000000000000000000000000000000000000000000000000000000673396eda8f1a4313bc15dcd3681ed2b6fdd042f1ee1f8232abdc96d2ec8465dfd2bb7401f90dd3af0db16c3cece57bd5de2b63a3d25140b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "publicInputsHash": "0x0010b7371af5e28ae8d1d0385e2ad3e28322dc403bfab0a6196947e5bb95143b", "numTxs": 8 } } \ No newline at end of file diff --git a/l1-contracts/test/portals/TokenPortal.sol b/l1-contracts/test/portals/TokenPortal.sol index d9bd3280946e..115132e52346 100644 --- a/l1-contracts/test/portals/TokenPortal.sol +++ b/l1-contracts/test/portals/TokenPortal.sol @@ -53,8 +53,10 @@ contract TokenPortal { DataStructures.L2Actor memory actor = DataStructures.L2Actor(l2Bridge, 1); // Hash the message content to be reconstructed in the receiving contract + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. bytes32 contentHash = - Hash.sha256ToField(abi.encodeWithSignature("mint_public(bytes32,uint256)", _to, _amount)); + Hash.sha256ToField(abi.encodeWithSignature("mint_to_public(bytes32,uint256)", _to, _amount)); // Hold the tokens in the portal underlying.safeTransferFrom(msg.sender, address(this), _amount); @@ -87,7 +89,7 @@ contract TokenPortal { // Hash the message content to be reconstructed in the receiving contract - the signature below does not correspond // to a real function. It's just an identifier of an action. bytes32 contentHash = - Hash.sha256ToField(abi.encodeWithSignature("mint_private(uint256)", _amount)); + Hash.sha256ToField(abi.encodeWithSignature("mint_to_private(uint256)", _amount)); // Hold the tokens in the portal underlying.safeTransferFrom(msg.sender, address(this), _amount); @@ -123,6 +125,8 @@ contract TokenPortal { uint256 _leafIndex, bytes32[] calldata _path ) external { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({ sender: DataStructures.L2Actor(l2Bridge, 1), recipient: DataStructures.L1Actor(address(this), block.chainid), diff --git a/l1-contracts/test/portals/TokenPortal.t.sol b/l1-contracts/test/portals/TokenPortal.t.sol index ba5fa33c0c00..da7af0eb534b 100644 --- a/l1-contracts/test/portals/TokenPortal.t.sol +++ b/l1-contracts/test/portals/TokenPortal.t.sol @@ -88,10 +88,12 @@ contract TokenPortalTest is Test { view returns (DataStructures.L1ToL2Msg memory) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. return DataStructures.L1ToL2Msg({ sender: DataStructures.L1Actor(address(tokenPortal), block.chainid), recipient: DataStructures.L2Actor(l2TokenAddress, 1), - content: Hash.sha256ToField(abi.encodeWithSignature("mint_private(uint256)", amount)), + content: Hash.sha256ToField(abi.encodeWithSignature("mint_to_private(uint256)", amount)), secretHash: secretHashForL2MessageConsumption, index: _index }); @@ -102,10 +104,14 @@ contract TokenPortalTest is Test { view returns (DataStructures.L1ToL2Msg memory) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. return DataStructures.L1ToL2Msg({ sender: DataStructures.L1Actor(address(tokenPortal), block.chainid), recipient: DataStructures.L2Actor(l2TokenAddress, 1), - content: Hash.sha256ToField(abi.encodeWithSignature("mint_public(bytes32,uint256)", to, amount)), + content: Hash.sha256ToField( + abi.encodeWithSignature("mint_to_public(bytes32,uint256)", to, amount) + ), secretHash: secretHashForL2MessageConsumption, index: _index }); @@ -169,6 +175,8 @@ contract TokenPortalTest is Test { internal returns (bytes32, bytes32) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. bytes32 l2ToL1Message = Hash.sha256ToField( DataStructures.L2ToL1Msg({ sender: DataStructures.L2Actor({actor: l2TokenAddress, version: 1}), diff --git a/l1-contracts/test/portals/UniswapPortal.sol b/l1-contracts/test/portals/UniswapPortal.sol index a4eb66d8b806..37e02ee69bb6 100644 --- a/l1-contracts/test/portals/UniswapPortal.sol +++ b/l1-contracts/test/portals/UniswapPortal.sol @@ -87,6 +87,8 @@ contract UniswapPortal { { // prevent stack too deep errors + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. vars.contentHash = Hash.sha256ToField( abi.encodeWithSignature( "swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)", @@ -191,6 +193,8 @@ contract UniswapPortal { { // prevent stack too deep errors + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. vars.contentHash = Hash.sha256ToField( abi.encodeWithSignature( "swap_private(address,uint256,uint24,address,uint256,bytes32,address)", diff --git a/l1-contracts/test/portals/UniswapPortal.t.sol b/l1-contracts/test/portals/UniswapPortal.t.sol index bf37ae19e64f..ac646e17bac7 100644 --- a/l1-contracts/test/portals/UniswapPortal.t.sol +++ b/l1-contracts/test/portals/UniswapPortal.t.sol @@ -94,6 +94,8 @@ contract UniswapPortalTest is Test { view returns (bytes32 l2ToL1MessageHash) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({ sender: DataStructures.L2Actor(l2TokenAddress, 1), recipient: DataStructures.L1Actor(address(daiTokenPortal), block.chainid), @@ -116,6 +118,8 @@ contract UniswapPortalTest is Test { view returns (bytes32 l2ToL1MessageHash) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({ sender: DataStructures.L2Actor(l2UniswapAddress, 1), recipient: DataStructures.L1Actor(address(uniswapPortal), block.chainid), @@ -143,6 +147,8 @@ contract UniswapPortalTest is Test { * Set to address(0) if anyone can call. */ function _createUniswapSwapMessagePrivate(address _caller) internal view returns (bytes32) { + // The purpose of including the function selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({ sender: DataStructures.L2Actor(l2UniswapAddress, 1), recipient: DataStructures.L1Actor(address(uniswapPortal), block.chainid), diff --git a/noir-projects/aztec-nr/.gitrepo b/noir-projects/aztec-nr/.gitrepo index df6f10a16172..504278a7cb37 100644 --- a/noir-projects/aztec-nr/.gitrepo +++ b/noir-projects/aztec-nr/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/aztec-nr branch = master - commit = 94008214c5d3678ad62d01c1160b71404809806c + commit = 8d7530b1cd40074c2820832f122f3ad605d57e16 method = merge cmdver = 0.4.6 - parent = fcdf11d871833074e4ebb6e064e1ca64edda6ea9 + parent = 67f86c1feccdbbfd550147c4e1699bf120d848a2 diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 7e4aee502081..ba902167bf40 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -33,12 +33,11 @@ use dep::protocol_types::{ }, address::{AztecAddress, EthAddress}, constants::{ - MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL, + MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_UNENCRYPTED_LOGS_PER_CALL, - PUBLIC_DISPATCH_SELECTOR, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PUBLIC_DISPATCH_SELECTOR, }, header::Header, messaging::l2_to_l1_message::L2ToL1Message, @@ -77,7 +76,7 @@ pub struct PrivateContext { pub note_encrypted_logs_hashes: BoundedVec, pub encrypted_logs_hashes: BoundedVec, - pub unencrypted_logs_hashes: BoundedVec, + pub contract_class_logs_hashes: BoundedVec, // Contains the last key validation request for each key type. This is used to cache the last request and avoid // fetching the same request multiple times. @@ -107,7 +106,7 @@ impl PrivateContext { l2_to_l1_msgs: BoundedVec::new(), note_encrypted_logs_hashes: BoundedVec::new(), encrypted_logs_hashes: BoundedVec::new(), - unencrypted_logs_hashes: BoundedVec::new(), + contract_class_logs_hashes: BoundedVec::new(), last_key_validation_requests: [Option::none(); NUM_KEY_TYPES], } } @@ -196,7 +195,7 @@ impl PrivateContext { end_side_effect_counter: self.side_effect_counter, note_encrypted_logs_hashes: self.note_encrypted_logs_hashes.storage(), encrypted_logs_hashes: self.encrypted_logs_hashes.storage(), - unencrypted_logs_hashes: self.unencrypted_logs_hashes.storage(), + contract_class_logs_hashes: self.contract_class_logs_hashes.storage(), historical_header: self.historical_header, tx_context: self.inputs.tx_context, } @@ -605,7 +604,7 @@ impl Empty for PrivateContext { historical_header: Header::empty(), note_encrypted_logs_hashes: BoundedVec::new(), encrypted_logs_hashes: BoundedVec::new(), - unencrypted_logs_hashes: BoundedVec::new(), + contract_class_logs_hashes: BoundedVec::new(), last_key_validation_requests: [Option::none(); NUM_KEY_TYPES], } } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 099a253e07f2..264f2898ec81 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -14,7 +14,10 @@ use std::{ use crate::{ encrypted_logs::header::EncryptedLogHeader, keys::point_to_symmetric_key::point_to_symmetric_key, - oracle::{notes::{get_app_tag_bytes, increment_app_tagging_secret}, random::random}, + oracle::{ + notes::{get_app_tag_bytes_as_sender, increment_app_tagging_secret_index_as_sender}, + random::random, + }, utils::point::point_to_bytes, }; @@ -128,8 +131,8 @@ fn compute_encrypted_log( // We assume that the sender wants for the recipient to find the tagged note, and therefore that they will cooperate // and use the correct tag. Usage of a bad tag will result in the recipient not being able to find the note // automatically. - let tag_bytes = unsafe { get_app_tag_bytes(sender, recipient) }; - increment_app_tagging_secret(sender, recipient); + let tag_bytes = unsafe { get_app_tag_bytes_as_sender(sender, recipient) }; + increment_app_tagging_secret_index_as_sender(sender, recipient); for i in 0..32 { encrypted_bytes[offset + i] = tag_bytes[i]; @@ -331,13 +334,9 @@ mod test { 0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70c, ); - let _ = OracleMock::mock("getAppTaggingSecret").returns([ - 69420, - 0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70c, - 1337, - ]); + let _ = OracleMock::mock("getAppTaggingSecretAsSender").returns([69420, 1337]); - let _ = OracleMock::mock("incrementAppTaggingSecret"); + let _ = OracleMock::mock("incrementAppTaggingSecretIndexAsSender").returns(()); let log = compute_private_log_payload( contract_address, diff --git a/noir-projects/aztec-nr/aztec/src/macros/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/mod.nr index 9e30b327a2e1..924c5bcf8e01 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/mod.nr @@ -29,11 +29,13 @@ pub comptime fn aztec(m: Module) -> Quoted { generate_compute_note_hash_and_optionally_a_nullifier(); let note_exports = generate_note_exports(); let public_dispatch = generate_public_dispatch(m); + let sync_notes = generate_sync_notes(); quote { $note_exports $interface $compute_note_hash_and_optionally_a_nullifier $public_dispatch + $sync_notes } } @@ -173,3 +175,11 @@ comptime fn generate_note_exports() -> Quoted { }) .join(quote {}) } + +comptime fn generate_sync_notes() -> Quoted { + quote { + unconstrained fn sync_notes() { + aztec::oracle::notes::sync_notes(); + } + } +} diff --git a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr index 52e66b276670..4570d2ce5717 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr @@ -730,7 +730,6 @@ comptime fn generate_finalization_payload( // We append the public value to the log and emit it as unencrypted log let mut finalization_log = [0; $finalization_log_byte_length]; - // Iterate over the partial log and copy it to the final log for i in 0..setup_log.len() { finalization_log[i + 1] = setup_log[i]; diff --git a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr index 85e54210bf4d..3db99d009023 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr @@ -32,15 +32,6 @@ pub fn emit_encrypted_event_log( } } -/// Informs the simulator that an unencrypted log has been emitted, helping it keep track of side-effects and easing -/// debugging. -pub fn emit_unencrypted_log_private(contract_address: AztecAddress, message: T, counter: u32) { - // This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to call. - unsafe { - emit_unencrypted_log_private_oracle_wrapper(contract_address, message, counter) - } -} - unconstrained fn emit_encrypted_note_log_oracle_wrapper( note_hash_counter: u32, encrypted_note: [u8; M], @@ -58,15 +49,7 @@ unconstrained fn emit_encrypted_event_log_oracle_wrapper( emit_encrypted_event_log_oracle(contract_address, randomness, encrypted_event, counter) } -unconstrained fn emit_unencrypted_log_private_oracle_wrapper( - contract_address: AztecAddress, - message: T, - counter: u32, -) { - let _ = emit_unencrypted_log_private_oracle(contract_address, message, counter); -} - -/// Temporary substitute for `emit_unencrypted_log_private` that is used for handling contract class registration. This +/// Temporary substitute that is used for handling contract class registration. This /// variant returns the log hash, which would be too large to compute inside a circuit. pub unconstrained fn emit_contract_class_unencrypted_log_private( contract_address: AztecAddress, @@ -92,14 +75,7 @@ unconstrained fn emit_encrypted_event_log_oracle( _counter: u32, ) {} -#[oracle(emitUnencryptedLog)] -unconstrained fn emit_unencrypted_log_private_oracle( - _contract_address: AztecAddress, - _message: T, - _counter: u32, -) -> Field {} - -#[oracle(emitContractClassUnencryptedLog)] +#[oracle(emitContractClassLog)] unconstrained fn emit_contract_class_unencrypted_log_private_oracle( contract_address: AztecAddress, message: [Field; N], diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index c94c8a3ef7a7..4bbc97be9f9b 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -155,6 +155,7 @@ pub unconstrained fn get_notes, { + sync_notes_oracle_wrapper(); let fields = get_notes_oracle_wrapper( storage_slot, num_selects, @@ -203,27 +204,30 @@ pub unconstrained fn check_nullifier_exists(inner_nullifier: Field) -> bool { #[oracle(checkNullifierExists)] unconstrained fn check_nullifier_exists_oracle(_inner_nullifier: Field) -> Field {} -/// Same as `get_app_tagging_secret`, except it returns the derived tag as an array of bytes, ready to be included in a +/// Same as `get_app_tagging_secret_as_sender`, except it returns the derived tag as an array of bytes, ready to be included in a /// log. -pub unconstrained fn get_app_tag_bytes(sender: AztecAddress, recipient: AztecAddress) -> [u8; 32] { - let tag = get_app_tagging_secret(sender, recipient).compute_tag(); +pub unconstrained fn get_app_tag_bytes_as_sender( + sender: AztecAddress, + recipient: AztecAddress, +) -> [u8; 32] { + let tag = get_app_tagging_secret_as_sender(sender, recipient).compute_tag(recipient); tag.to_be_bytes() } /// Returns the tagging secret for a given sender and recipient pair, siloed for the current contract address. -/// Includes the last known index used for tagging with this secret. +/// Includes the last known index used to send a note tagged with this secret. /// For this to work, PXE must know the ivpsk_m of the sender. /// For the recipient's side, only the address is needed. -pub unconstrained fn get_app_tagging_secret( +pub unconstrained fn get_app_tagging_secret_as_sender( sender: AztecAddress, recipient: AztecAddress, ) -> IndexedTaggingSecret { - let result = get_app_tagging_secret_oracle(sender, recipient); + let result = get_app_tagging_secret_as_sender_oracle(sender, recipient); IndexedTaggingSecret::deserialize(result) } -#[oracle(getAppTaggingSecret)] -unconstrained fn get_app_tagging_secret_oracle( +#[oracle(getAppTaggingSecretAsSender)] +unconstrained fn get_app_tagging_secret_as_sender_oracle( _sender: AztecAddress, _recipient: AztecAddress, ) -> [Field; INDEXED_TAGGING_SECRET_LENGTH] {} @@ -233,38 +237,38 @@ unconstrained fn get_app_tagging_secret_oracle( /// This change should only be persisted in a non-volatile database if the tagged log is found in an actual block - /// otherwise e.g. a reverting transaction can cause the sender to accidentally skip indices and later produce notes /// that are not found by the recipient. -pub fn increment_app_tagging_secret(sender: AztecAddress, recipient: AztecAddress) { +pub fn increment_app_tagging_secret_index_as_sender(sender: AztecAddress, recipient: AztecAddress) { // This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to call. unsafe { - increment_app_tagging_secret_wrapper(sender, recipient); + increment_app_tagging_secret_index_as_sender_wrapper(sender, recipient); } } -unconstrained fn increment_app_tagging_secret_wrapper( +unconstrained fn increment_app_tagging_secret_index_as_sender_wrapper( sender: AztecAddress, recipient: AztecAddress, ) { - increment_app_tagging_secret_oracle(sender, recipient); + increment_app_tagging_secret_index_as_sender_oracle(sender, recipient); } -#[oracle(incrementAppTaggingSecret)] -unconstrained fn increment_app_tagging_secret_oracle( +#[oracle(incrementAppTaggingSecretIndexAsSender)] +unconstrained fn increment_app_tagging_secret_index_as_sender_oracle( _sender: AztecAddress, _recipient: AztecAddress, ) {} -/// Finds new notes that may have been sent to `recipient` in the current contract and makes them available +/// Finds new notes that may have been sent to all registered accounts in PXE in the current contract and makes them available /// for later querying via the `get_notes` oracle. -pub fn sync_notes(recipient: AztecAddress) { +pub fn sync_notes() { // This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to call. unsafe { - sync_notes_oracle_wrapper(recipient); + sync_notes_oracle_wrapper(); } } -unconstrained fn sync_notes_oracle_wrapper(recipient: AztecAddress) { - sync_notes_oracle(recipient); +unconstrained fn sync_notes_oracle_wrapper() { + sync_notes_oracle(); } #[oracle(syncNotes)] -unconstrained fn sync_notes_oracle(_recipient: AztecAddress) {} +unconstrained fn sync_notes_oracle() {} diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr index 003a6d49613c..471ede3d9d56 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr @@ -41,6 +41,8 @@ impl PrivateSet where Note: NoteInterface + NullifiableNote, { + // TODO: This function is still around because of a stale blacklist token. It should most likely be nuked. If you + // need this functionality use partial notes instead. // docs:start:insert_from_public pub fn insert_from_public(self, note: &mut Note) { create_note_hash_from_public(self.context, self.storage_slot, note); diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index fd11c9a9c5dd..d188ebe78dbc 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -96,7 +96,7 @@ contract AppSubscription { assert(tx_count as u64 <= SUBSCRIPTION_TXS as u64); Token::at(storage.subscription_token_address.read_private()) - .transfer_from( + .transfer_in_private( context.msg_sender(), storage.subscription_recipient_address.read_private(), storage.subscription_price.read_private(), diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index e80df65b8a3f..bf1382bc7731 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -640,9 +640,9 @@ contract AvmTest { let _ = l1_to_l2_msg_exists(1, 2); dep::aztec::oracle::debug_log::debug_log("send_l2_to_l1_msg"); let _ = send_l2_to_l1_msg(EthAddress::from_field(0x2020), 1); - dep::aztec::oracle::debug_log::debug_log("nested_call_to_add"); - let _ = nested_call_to_add(1, 2); - dep::aztec::oracle::debug_log::debug_log("nested_static_call_to_add"); - let _ = nested_static_call_to_add(1, 2); + //dep::aztec::oracle::debug_log::debug_log("nested_call_to_add"); + //let _ = nested_call_to_add(1, 2); + //dep::aztec::oracle::debug_log::debug_log("nested_static_call_to_add"); + //let _ = nested_static_call_to_add(1, 2); } } diff --git a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr index 668c2c86e312..edaf81c7cc47 100644 --- a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr @@ -52,7 +52,7 @@ contract Claim { // 4) Finally we mint the reward token to the sender of the transaction Token::at(storage.reward_token.read_private()) - .mint_public(recipient, proof_note.value) + .mint_to_public(recipient, proof_note.value) .enqueue(&mut context); } } diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 58122d06881b..8464b960fb01 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -100,7 +100,7 @@ contract ContractClassRegisterer { public_bytecode_commitment, ], ); - emit_contract_class_unencrypted_log(&mut context, event.serialize()); + emit_contract_class_log(&mut context, event.serialize()); } #[private] @@ -143,7 +143,7 @@ contract ContractClassRegisterer { function_data.metadata_hash, ], ); - emit_contract_class_unencrypted_log(&mut context, event.serialize()); + emit_contract_class_log(&mut context, event.serialize()); } #[private] @@ -179,14 +179,11 @@ contract ContractClassRegisterer { function_data.metadata_hash, ], ); - emit_contract_class_unencrypted_log(&mut context, event.serialize()); + emit_contract_class_log(&mut context, event.serialize()); } #[contract_library_method] - fn emit_contract_class_unencrypted_log( - context: &mut PrivateContext, - log: [Field; N], - ) { + fn emit_contract_class_log(context: &mut PrivateContext, log: [Field; N]) { let contract_address = context.this_address(); let counter = context.next_counter(); @@ -203,7 +200,7 @@ contract ContractClassRegisterer { let log_hash = emit_contract_class_unencrypted_log_private(contract_address, log, counter); // 40 = addr (32) + raw log len (4) + processed log len (4) - context.unencrypted_logs_hashes.push( + context.contract_class_logs_hashes.push( LogHash { value: log_hash, counter, length: 40 + (N as Field) * 32 }, ); } diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index 4ce03ebb6e12..44c129f8710d 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -3,16 +3,14 @@ use dep::aztec::macros::aztec; #[aztec] contract ContractInstanceDeployer { use dep::aztec::{ - hash::compute_unencrypted_log_hash, macros::{events::event, functions::private}, - oracle::logs::emit_unencrypted_log_private, utils::to_bytes::arr_to_be_bytes_arr, }; use dep::aztec::protocol_types::{ - abis::log_hash::LogHash, address::{AztecAddress, PartialAddress, PublicKeysHash}, constants::DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, contract_class_id::ContractClassId, + hash::sha256_to_field, public_keys::PublicKeys, traits::Serialize, }; @@ -119,20 +117,14 @@ contract ContractInstanceDeployer { let payload = event.serialize(); dep::aztec::oracle::debug_log::debug_log_format("ContractInstanceDeployed: {}", payload); - let contract_address = context.this_address(); - let counter = context.next_counter(); - // @todo This is very inefficient, we are doing a lot of back and forth conversions. let serialized_log = arr_to_be_bytes_arr(payload); - let log_hash = compute_unencrypted_log_hash(contract_address, serialized_log); - // 40 = addr (32) + raw log len (4) + processed log len (4) - let len = 40 + serialized_log.len().to_field(); - let side_effect = LogHash { value: log_hash, counter, length: len }; + let log_hash = sha256_to_field(serialized_log); - // We manually push the unencrypted log to the context and inform the execution environment about this because - // PrivateContext does not expose an `emit_unencrypted_log` method - this mechanism is considered error-prone - // and only some canonical contracts use it. - context.unencrypted_logs_hashes.push(side_effect); - emit_unencrypted_log_private(contract_address, payload, counter); + // Note: we are cheating a bit here because this is actually not encrypted + // but needs to be emitted from private, where we have removed unencrypted_logs, + // and has 15 fields (the max enc log len is 8). + // TODO(Miranda): split into 2 logs + context.emit_raw_event_log_with_masked_address(0, serialized_log, log_hash); } } diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index 92e89729e74a..991b10c40a4a 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -77,7 +77,7 @@ contract Crowdfunding { // 2) Transfer the donation tokens from donor to this contract let donor = context.msg_sender(); Token::at(storage.donation_token.read_private()) - .transfer_from(donor, context.this_address(), amount as Field, 0) + .transfer_in_private(donor, context.this_address(), amount as Field, 0) .call(&mut context); // docs:end:do-transfer // 3) Create a value note for the donor so that he can later on claim a rewards token in the Claim diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr index 6f77d74b16e9..35179d962e15 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr @@ -11,17 +11,19 @@ pub fn get_bridge_gas_msg_hash(owner: AztecAddress, amount: Field) -> Field { let recipient_bytes: [u8; 32] = owner.to_field().to_be_bytes(); let amount_bytes: [u8; 32] = amount.to_be_bytes(); + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { std::hash::keccak256("claim(bytes32,uint256)".as_bytes(), 22) }; + + for i in 0..4 { + hash_bytes[i] = selector[i]; + } + for i in 0..32 { hash_bytes[i + 4] = recipient_bytes[i]; hash_bytes[i + 36] = amount_bytes[i]; } - // Function selector: 0x63f44968 keccak256('claim(bytes32,uint256)') - hash_bytes[0] = 0x63; - hash_bytes[1] = 0xf4; - hash_bytes[2] = 0x49; - hash_bytes[3] = 0x68; - let content_hash = sha256_to_field(hash_bytes); content_hash } diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index 9a9376abfc9f..ab1ffdc47534 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -58,7 +58,7 @@ contract FPC { #[internal] fn prepare_fee(from: AztecAddress, amount: Field, asset: AztecAddress, nonce: Field) { // docs:start:public_call - Token::at(asset).transfer_public(from, context.this_address(), amount, nonce).call( + Token::at(asset).transfer_in_public(from, context.this_address(), amount, nonce).call( &mut context, ); // docs:end:public_call @@ -69,7 +69,7 @@ contract FPC { fn pay_refund(refund_address: AztecAddress, amount: Field, asset: AztecAddress) { // Just do public refunds for the present let refund = compute_rebate(context, amount); - Token::at(asset).transfer_public(context.this_address(), refund_address, refund, 0).call( + Token::at(asset).transfer_in_public(context.this_address(), refund_address, refund, 0).call( &mut context, ); } diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index 938d403c8033..b5781af3b207 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -129,7 +129,7 @@ contract Lending { collateral_asset: AztecAddress, ) { let _ = Token::at(collateral_asset) - .transfer_public(context.msg_sender(), context.this_address(), amount, nonce) + .transfer_in_public(context.msg_sender(), context.this_address(), amount, nonce) .call(&mut context); let _ = Lending::at(context.this_address()) ._deposit(AztecAddress::from_field(on_behalf_of), amount, collateral_asset) @@ -199,7 +199,7 @@ contract Lending { // @todo @LHerskind Support both shielding and transfers (for now just transfer) let collateral_asset = storage.collateral_asset.read(); let _ = Token::at(collateral_asset) - .transfer_public(context.this_address(), recipient, amount, 0) + .transfer_in_public(context.this_address(), recipient, amount, 0) .call(&mut context); } @@ -248,7 +248,7 @@ contract Lending { // @todo @LHerskind Need to support both private and public minting. let stable_coin = storage.stable_coin.read(); - let _ = Token::at(stable_coin).mint_public(to, amount).call(&mut context); + let _ = Token::at(stable_coin).mint_to_public(to, amount).call(&mut context); } #[private] @@ -263,7 +263,7 @@ contract Lending { let on_behalf_of = compute_identifier(secret, on_behalf_of, context.msg_sender().to_field()); // docs:start:private_call - let _ = Token::at(stable_coin).burn(from, amount, nonce).call(&mut context); + let _ = Token::at(stable_coin).burn_private(from, amount, nonce).call(&mut context); // docs:end:private_call let _ = Lending::at(context.this_address()) ._repay(AztecAddress::from_field(on_behalf_of), amount, stable_coin) diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index 401e5b015ede..ccefcbef97f7 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -150,8 +150,8 @@ contract NFT { let nft = NFT::at(context.this_address()); - // We prepare the transfer. - let hiding_point_slot = _prepare_transfer_to_private(to, &mut context, storage); + // We prepare the private balance increase. + let hiding_point_slot = _prepare_private_balance_increase(to, &mut context, storage); // At last we finalize the transfer. Usafe of the `unsafe` method here is safe because we set the `from` // function argument to a message sender, guaranteeing that he can transfer only his own NFTs. @@ -160,20 +160,20 @@ contract NFT { ); } - /// Prepares a transfer to a private balance of `to`. The transfer then needs to be - /// finalized by calling `finalize_transfer_to_private`. Returns a hiding point slot. + /// Prepares an increase of private balance of `to` (partial note). The increase needs to be finalized by calling + /// `finalize_transfer_to_private. Returns a hiding point slot. #[private] - fn prepare_transfer_to_private(to: AztecAddress) -> Field { - _prepare_transfer_to_private(to, &mut context, storage) + fn prepare_private_balance_increase(to: AztecAddress) -> Field { + _prepare_private_balance_increase(to, &mut context, storage) } - /// This function exists separately from `prepare_transfer_to_private` solely as an optimization as it allows + /// This function exists separately from `prepare_private_balance_increase` solely as an optimization as it allows /// us to have it inlined in the `transfer_to_private` function which results in one less kernel iteration. /// /// TODO(#9180): Consider adding macro support for functions callable both as an entrypoint and as an internal /// function. #[contract_library_method] - fn _prepare_transfer_to_private( + fn _prepare_private_balance_increase( to: AztecAddress, context: &mut PrivateContext, storage: Storage<&mut PrivateContext>, @@ -235,7 +235,7 @@ contract NFT { } /// Finalizes a transfer of NFT with `token_id` from public balance of `from` to a private balance of `to`. - /// The transfer must be prepared by calling `prepare_transfer_to_private` first and the resulting + /// The transfer must be prepared by calling `prepare_private_balance_increase` first and the resulting /// `hiding_point_slot` must be passed as an argument to this function. #[public] fn finalize_transfer_to_private(token_id: Field, hiding_point_slot: Field) { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr index 742109682dc5..03f59109aec9 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }; use std::test::OracleMock; -/// Internal orchestration means that the calls to `prepare_transfer_to_private` +/// Internal orchestration means that the calls to `prepare_private_balance_increase` /// and `finalize_transfer_to_private` are done by the NFT contract itself. /// In this test's case this is done by the `NFT::transfer_to_private(...)` function called /// in `utils::setup_mint_and_transfer_to_private`. @@ -40,7 +40,7 @@ unconstrained fn transfer_to_private_external_orchestration() { // We prepare the transfer let hiding_point_slot: Field = NFT::at(nft_contract_address) - .prepare_transfer_to_private(recipient) + .prepare_private_balance_increase(recipient) .call(&mut env.private()); // Finalize the transfer of the NFT (message sender owns the NFT in public) @@ -96,7 +96,7 @@ unconstrained fn transfer_to_private_failure_not_an_owner() { // as the NFT owner check is before we use the value but that would made the test less robust against changes // in the contract.) let hiding_point_slot: Field = NFT::at(nft_contract_address) - .prepare_transfer_to_private(not_owner) + .prepare_private_balance_increase(not_owner) .call(&mut env.private()); // Try transferring someone else's public NFT diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 723239b18d0b..8a8091e64222 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -34,7 +34,7 @@ contract Test { utils::comparison::Comparator, }; use dep::token_portal_content_hash_lib::{ - get_mint_private_content_hash, get_mint_public_content_hash, + get_mint_to_private_content_hash, get_mint_to_public_content_hash, }; use dep::value_note::value_note::ValueNote; // TODO investigate why the macros require EmbeddedCurvePoint and EmbeddedCurveScalar @@ -372,27 +372,27 @@ contract Test { } #[public] - fn consume_mint_public_message( + fn consume_mint_to_public_message( to: AztecAddress, amount: Field, secret: Field, message_leaf_index: Field, portal_address: EthAddress, ) { - let content_hash = get_mint_public_content_hash(to, amount); + let content_hash = get_mint_to_public_content_hash(to, amount); // Consume message and emit nullifier context.consume_l1_to_l2_message(content_hash, secret, portal_address, message_leaf_index); } #[private] - fn consume_mint_private_message( + fn consume_mint_to_private_message( amount: Field, secret_for_L1_to_L2_message_consumption: Field, portal_address: EthAddress, message_leaf_index: Field, ) { // Consume L1 to L2 message and emit nullifier - let content_hash = get_mint_private_content_hash(amount); + let content_hash = get_mint_to_private_content_hash(amount); context.consume_l1_to_l2_message( content_hash, secret_for_L1_to_L2_message_consumption, diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index b5a75ad1623c..0c20ba058322 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -12,7 +12,8 @@ contract TokenBridge { use dep::aztec::prelude::{AztecAddress, EthAddress, SharedImmutable}; use dep::token_portal_content_hash_lib::{ - get_mint_private_content_hash, get_mint_public_content_hash, get_withdraw_content_hash, + get_mint_to_private_content_hash, get_mint_to_public_content_hash, + get_withdraw_content_hash, }; use dep::token::Token; @@ -54,7 +55,7 @@ contract TokenBridge { // Consumes a L1->L2 message and calls the token contract to mint the appropriate amount publicly #[public] fn claim_public(to: AztecAddress, amount: Field, secret: Field, message_leaf_index: Field) { - let content_hash = get_mint_public_content_hash(to, amount); + let content_hash = get_mint_to_public_content_hash(to, amount); // Consume message and emit nullifier context.consume_l1_to_l2_message( @@ -65,7 +66,7 @@ contract TokenBridge { ); // Mint tokens - Token::at(storage.token.read_public()).mint_public(to, amount).call(&mut context); + Token::at(storage.token.read_public()).mint_to_public(to, amount).call(&mut context); } // docs:end:claim_public @@ -103,7 +104,7 @@ contract TokenBridge { message_leaf_index: Field, ) { // Consume L1 to L2 message and emit nullifier - let content_hash = get_mint_private_content_hash(amount); + let content_hash = get_mint_to_private_content_hash(amount); context.consume_l1_to_l2_message( content_hash, secret_for_L1_to_L2_message_consumption, @@ -143,7 +144,7 @@ contract TokenBridge { TokenBridge::at(context.this_address())._assert_token_is_same(token).enqueue(&mut context); // docs:end:call_assert_token_is_same // Burn tokens - Token::at(token).burn(context.msg_sender(), amount, nonce).call(&mut context); + Token::at(token).burn_private(context.msg_sender(), amount, nonce).call(&mut context); } /// docs:end:exit_to_l1_private // docs:start:get_token diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index d7d33b87c644..e327690b2f16 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -22,11 +22,8 @@ contract Token { context::{PrivateCallInterface, PrivateContext}, encrypted_logs::{ encrypted_event_emission::encode_and_encrypt_event_unconstrained, - encrypted_note_emission::{ - encode_and_encrypt_note, encode_and_encrypt_note_unconstrained, - }, + encrypted_note_emission::encode_and_encrypt_note_unconstrained, }, - hash::compute_secret_hash, keys::getters::get_public_keys, macros::{ events::event, @@ -35,11 +32,9 @@ contract Token { }, oracle::random::random, prelude::{ - AztecAddress, FunctionSelector, Map, NoteGetterOptions, PrivateSet, PublicContext, - PublicMutable, SharedImmutable, + AztecAddress, FunctionSelector, Map, PublicContext, PublicMutable, SharedImmutable, }, protocol_types::{point::Point, traits::Serialize}, - utils::comparison::Comparator, }; use dep::uint_note::uint_note::UintNote; @@ -51,7 +46,7 @@ contract Token { }; // docs:end:import_authwit - use crate::types::{balance_set::BalanceSet, transparent_note::TransparentNote}; + use crate::types::balance_set::BalanceSet; // docs:end::imports @@ -85,9 +80,6 @@ contract Token { balances: Map, Context>, // docs:end:storage_balances total_supply: PublicMutable, - // docs:start:storage_pending_shields - pending_shields: PrivateSet, - // docs:end:storage_pending_shields public_balances: Map, Context>, symbol: SharedImmutable, name: SharedImmutable, @@ -111,6 +103,7 @@ contract Token { // docs:end:initialize_decimals } // docs:end:constructor + // docs:start:set_admin #[public] fn set_admin(new_admin: AztecAddress) { @@ -120,6 +113,7 @@ contract Token { // docs:end:write_admin } // docs:end:set_admin + #[public] #[view] fn public_get_name() -> FieldCompressedString { @@ -131,16 +125,19 @@ contract Token { fn private_get_name() -> FieldCompressedString { storage.name.read_private() } + #[public] #[view] fn public_get_symbol() -> pub FieldCompressedString { storage.symbol.read_public() } + #[private] #[view] fn private_get_symbol() -> pub FieldCompressedString { storage.symbol.read_private() } + #[public] #[view] fn public_get_decimals() -> pub u8 { @@ -155,6 +152,7 @@ contract Token { storage.decimals.read_private() // docs:end:read_decimals_private } + // docs:start:admin #[public] #[view] @@ -162,6 +160,7 @@ contract Token { storage.admin.read().to_field() } // docs:end:admin + // docs:start:is_minter #[public] #[view] @@ -169,6 +168,7 @@ contract Token { storage.minters.at(minter).read() } // docs:end:is_minter + // docs:start:total_supply #[public] #[view] @@ -176,6 +176,7 @@ contract Token { storage.total_supply.read().to_integer() } // docs:end:total_supply + // docs:start:balance_of_public #[public] #[view] @@ -183,6 +184,7 @@ contract Token { storage.public_balances.at(owner).read().to_integer() } // docs:end:balance_of_public + // docs:start:set_minter #[public] fn set_minter(minter: AztecAddress, approve: bool) { @@ -194,9 +196,10 @@ contract Token { // docs:end:write_minter } // docs:end:set_minter - // docs:start:mint_public + + // docs:start:mint_to_public #[public] - fn mint_public(to: AztecAddress, amount: Field) { + fn mint_to_public(to: AztecAddress, amount: Field) { // docs:start:read_minter assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter"); // docs:end:read_minter @@ -206,41 +209,11 @@ contract Token { storage.public_balances.at(to).write(new_balance); storage.total_supply.write(supply); } - // docs:end:mint_public - // docs:start:mint_private - // TODO(benesjan): To be nuked in a followup PR. - #[public] - fn mint_private_old(amount: Field, secret_hash: Field) { - assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter"); - let pending_shields = storage.pending_shields; - let mut note = TransparentNote::new(amount, secret_hash); - let supply = storage.total_supply.read().add(U128::from_integer(amount)); - storage.total_supply.write(supply); - // docs:start:insert_from_public - pending_shields.insert_from_public(&mut note); - // docs:end:insert_from_public - } - // docs:end:mint_private - // docs:start:shield - #[public] - fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) { - if (!from.eq(context.msg_sender())) { - // The redeem is only spendable once, so we need to ensure that you cannot insert multiple shields from the same message. - assert_current_call_valid_authwit_public(&mut context, from); - } else { - assert(nonce == 0, "invalid nonce"); - } - let amount = U128::from_integer(amount); - let from_balance = storage.public_balances.at(from).read().sub(amount); - let pending_shields = storage.pending_shields; - let mut note = TransparentNote::new(amount.to_field(), secret_hash); - storage.public_balances.at(from).write(from_balance); - pending_shields.insert_from_public(&mut note); - } - // docs:end:shield - // docs:start:transfer_public + // docs:end:mint_to_public + + // docs:start:transfer_in_public #[public] - fn transfer_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { + fn transfer_in_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit_public(&mut context, from); } else { @@ -252,7 +225,8 @@ contract Token { let to_balance = storage.public_balances.at(to).read().add(amount); storage.public_balances.at(to).write(to_balance); } - // docs:end:transfer_public + // docs:end:transfer_in_public + // docs:start:burn_public #[public] fn burn_public(from: AztecAddress, amount: Field, nonce: Field) { @@ -270,32 +244,7 @@ contract Token { storage.total_supply.write(new_supply); } // docs:end:burn_public - // docs:start:redeem_shield - #[private] - fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) { - let secret_hash = compute_secret_hash(secret); - // Pop 1 note (set_limit(1)) which has an amount stored in a field with index 0 (select(0, amount)) and - // a secret_hash stored in a field with index 1 (select(1, secret_hash)). - let mut options = NoteGetterOptions::new(); - options = options - .select(TransparentNote::properties().amount, Comparator.EQ, amount) - .select(TransparentNote::properties().secret_hash, Comparator.EQ, secret_hash) - .set_limit(1); - let notes = storage.pending_shields.pop_notes(options); - assert(notes.len() == 1, "note not popped"); - // Add the token note to user's balances set - // Note: Using context.msg_sender() as a sender below makes this incompatible with escrows because we send - // outgoing logs to that address and to send outgoing logs you need to get a hold of ovsk_m. - let from = context.msg_sender(); - let from_ovpk_m = get_public_keys(from).ovpk_m; - storage.balances.at(to).add(to, U128::from_integer(amount)).emit(encode_and_encrypt_note( - &mut context, - from_ovpk_m, - to, - context.msg_sender(), - )); - } - // docs:end:redeem_shield + // docs:start:transfer_to_public #[private] fn transfer_to_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { @@ -314,6 +263,7 @@ contract Token { Token::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context); } // docs:end:transfer_to_public + // docs:start:transfer #[private] fn transfer(to: AztecAddress, amount: Field) { @@ -347,7 +297,7 @@ contract Token { to, from, )); - // We don't constrain encryption of the note log in `transfer` (unlike in `transfer_from`) because the transfer + // We don't constrain encryption of the note log in `transfer` (unlike in `transfer_in_private`) because the transfer // function is only designed to be used in situations where the event is not strictly necessary (e.g. payment to // another person where the payment is considered to be successful when the other party successfully decrypts a // note). @@ -356,6 +306,7 @@ contract Token { ); } // docs:end:transfer + #[contract_library_method] fn subtract_balance( context: &mut PrivateContext, @@ -380,6 +331,7 @@ contract Token { compute_recurse_subtract_balance_call(*context, account, remaining).call(context) } } + // TODO(#7729): apply no_predicates to the contract interface method directly instead of having to use a wrapper // like we do here. #[no_predicates] @@ -391,6 +343,7 @@ contract Token { ) -> PrivateCallInterface<25, U128> { Token::at(context.this_address())._recurse_subtract_balance(account, remaining.to_field()) } + // TODO(#7728): even though the amount should be a U128, we can't have that type in a contract interface due to // serialization issues. #[internal] @@ -404,6 +357,7 @@ contract Token { RECURSIVE_TRANSFER_CALL_MAX_NOTES, ) } + /** * Cancel a private authentication witness. * @param inner_hash The inner hash of the authwit to cancel. @@ -416,9 +370,10 @@ contract Token { context.push_nullifier(nullifier); } // docs:end:cancel_authwit - // docs:start:transfer_from + + // docs:start:transfer_in_private #[private] - fn transfer_from(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { + fn transfer_in_private(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { // docs:start:assert_current_call_valid_authwit if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); @@ -450,10 +405,11 @@ contract Token { from, )); } - // docs:end:transfer_from - // docs:start:burn + // docs:end:transfer_in_private + + // docs:start:burn_private #[private] - fn burn(from: AztecAddress, amount: Field, nonce: Field) { + fn burn_private(from: AztecAddress, amount: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); } else { @@ -467,18 +423,18 @@ contract Token { ); Token::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } - // docs:end:burn + // docs:end:burn_private + // docs:start:transfer_to_private // Transfers token `amount` from public balance of message sender to a private balance of `to`. #[private] fn transfer_to_private(to: AztecAddress, amount: Field) { - // We check the minter permissions in the enqueued call as that allows us to avoid the need for `SharedMutable` - // which is less efficient. + // `from` is the owner of the public balance from which we'll subtract the `amount`. let from = context.msg_sender(); let token = Token::at(context.this_address()); - // We prepare the transfer. - let hiding_point_slot = _prepare_transfer_to_private(from, to, &mut context, storage); + // We prepare the private balance increase (the partial note). + let hiding_point_slot = _prepare_private_balance_increase(from, to, &mut context, storage); // At last we finalize the transfer. Usage of the `unsafe` method here is safe because we set the `from` // function argument to a message sender, guaranteeing that he can transfer only his own tokens. @@ -486,22 +442,24 @@ contract Token { &mut context, ); } + // docs:end:transfer_to_private - /// Prepares a transfer to a private balance of `to`. The transfer then needs to be - /// finalized by calling `finalize_transfer_to_private`. Returns a hiding point slot. + /// Prepares an increase of private balance of `to` (partial note). The increase needs to be finalized by calling + /// some of the finalization functions (`finalize_transfer_to_private`, `finalize_mint_to_private`). + /// Returns a hiding point slot. #[private] - fn prepare_transfer_to_private(to: AztecAddress) -> Field { + fn prepare_private_balance_increase(to: AztecAddress) -> Field { let from = context.msg_sender(); - _prepare_transfer_to_private(from, to, &mut context, storage) + _prepare_private_balance_increase(from, to, &mut context, storage) } - /// This function exists separately from `prepare_transfer_to_private` solely as an optimization as it allows + /// This function exists separately from `prepare_private_balance_increase` solely as an optimization as it allows /// us to have it inlined in the `transfer_to_private` function which results in one less kernel iteration. /// /// TODO(#9180): Consider adding macro support for functions callable both as an entrypoint and as an internal /// function. #[contract_library_method] - fn _prepare_transfer_to_private( + fn _prepare_private_balance_increase( from: AztecAddress, // recipient of the outgoing: TODO(#9887): this is not great? to: AztecAddress, context: &mut PrivateContext, @@ -547,7 +505,7 @@ contract Token { } /// Finalizes a transfer of token `amount` from public balance of `from` to a private balance of `to`. - /// The transfer must be prepared by calling `prepare_transfer_to_private` first and the resulting + /// The transfer must be prepared by calling `prepare_private_balance_increase` first and the resulting /// `hiding_point_slot` must be passed as an argument to this function. #[public] fn finalize_transfer_to_private(amount: Field, hiding_point_slot: Field) { @@ -588,6 +546,7 @@ contract Token { finalization_payload.emit(); } + // docs:start:mint_to_private /// Mints token `amount` to a private balance of `to`. Message sender has to have minter permissions (checked /// in the enqueud call). #[private] @@ -598,8 +557,8 @@ contract Token { ) { let token = Token::at(context.this_address()); - // We prepare the transfer. - let hiding_point_slot = _prepare_transfer_to_private(from, to, &mut context, storage); + // We prepare the partial note to which we'll "send" the minted amount. + let hiding_point_slot = _prepare_private_balance_increase(from, to, &mut context, storage); // At last we finalize the mint. Usage of the `unsafe` method here is safe because we set the `from` // function argument to a message sender, guaranteeing that only a message sender with minter permissions @@ -608,12 +567,13 @@ contract Token { ._finalize_mint_to_private_unsafe(context.msg_sender(), amount, hiding_point_slot) .enqueue(&mut context); } + // docs:end:mint_to_private /// Finalizes a mint of token `amount` to a private balance of `to`. The mint must be prepared by calling - /// `prepare_transfer_to_private` first and the resulting + /// `prepare_private_balance_increase` first and the resulting /// `hiding_point_slot` must be passed as an argument to this function. /// - /// Note: This function is only an optimization as it could be replaced by a combination of `mint_public` + /// Note: This function is only an optimization as it could be replaced by a combination of `mint_to_public` /// and `finalize_transfer_to_private`. It is however used very commonly so it makes sense to optimize it /// (e.g. used during token bridging, in AMM liquidity token etc.). #[public] @@ -707,62 +667,14 @@ contract Token { user, )); - // 4. Now we get the partial payloads - // TODO(#7775): Manually fetching the randomness here is not great. If we decide to include randomness in all - // notes we could just inject it in macros. - let fee_payer_randomness = unsafe { random() }; - let user_randomness = unsafe { random() }; - - let fee_payer_setup_payload = UintNote::setup_payload().new( - fee_payer, - fee_payer_randomness, - storage.balances.at(fee_payer).set.storage_slot, - ); + // 4. We prepare the partial notes + // TODO(#9887): In each `_prepare_private_balance_increase` call we fetch the user's ovpk_m 2 more times. This is + // very inefficient. + let fee_payer_point_slot = + _prepare_private_balance_increase(user, fee_payer, &mut context, storage); + let user_point_slot = _prepare_private_balance_increase(user, user, &mut context, storage); - let user_setup_payload = UintNote::setup_payload().new( - user, - user_randomness, - storage.balances.at(user).set.storage_slot, - ); - - // 5. We get transient storage slots - // Using the x-coordinate as a hiding point slot is safe against someone else interfering with it because - // we have a guarantee that the public functions of the transaction are executed right after the private ones - // and for this reason the protocol guarantees that nobody can front-run us in consuming the hiding point. - // This guarantee would break if `finalize_transfer_to_private` was not called in the same transaction. This - // however is not the flow we are currently concerned with. To support the multi-transaction flow we could - // introduce a `from` function argument, hash the x-coordinate with it and then repeat the hashing in - // `finalize_transfer_to_private`. - // - // We can also be sure that the `hiding_point_slot` will not overwrite any other value in the storage because - // in our state variables we derive slots using a different hash function from multi scalar multiplication - // (MSM). - let fee_payer_point_slot = fee_payer_setup_payload.hiding_point.x; - let user_point_slot = user_setup_payload.hiding_point.x; - - // 6. We compute setup logs - let fee_payer_setup_log = - fee_payer_setup_payload.encrypt_log(&mut context, user_ovpk, fee_payer, fee_payer); - let user_setup_log = - user_setup_payload.encrypt_log(&mut context, user_ovpk, user, fee_payer); - - // 7. We store the hiding points an logs in transients storage - Token::at(context.this_address()) - ._store_payload_in_transient_storage_unsafe( - fee_payer_point_slot, - fee_payer_setup_payload.hiding_point, - fee_payer_setup_log, - ) - .enqueue(&mut context); - Token::at(context.this_address()) - ._store_payload_in_transient_storage_unsafe( - user_point_slot, - user_setup_payload.hiding_point, - user_setup_log, - ) - .enqueue(&mut context); - - // 8. Set the public teardown function to `complete_refund(...)`. Public teardown is the only time when a public + // 5. Set the public teardown function to `complete_refund(...)`. Public teardown is the only time when a public // function has access to the final transaction fee, which is needed to compute the actual refund amount. context.set_public_teardown_function( context.this_address(), @@ -828,6 +740,7 @@ contract Token { storage.public_balances.at(to).write(new_balance); } // docs:end:increase_public_balance + // docs:start:reduce_total_supply #[public] #[internal] @@ -837,6 +750,7 @@ contract Token { storage.total_supply.write(new_supply); } // docs:end:reduce_total_supply + /// Unconstrained /// // docs:start:balance_of_private pub(crate) unconstrained fn balance_of_private(owner: AztecAddress) -> pub Field { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test.nr index 35a4c1f1aff6..1ed2b177ced8 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test.nr @@ -1,11 +1,12 @@ mod access_control; -mod burn; -mod utils; -mod transfer_public; -mod transfer_private; +mod burn_private; +mod burn_public; +mod mint_to_public; +mod reading_constants; +mod refunds; +mod transfer; +mod transfer_in_private; +mod transfer_in_public; mod transfer_to_private; mod transfer_to_public; -mod refunds; -mod minting; -mod reading_constants; -mod shielding; +mod utils; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr deleted file mode 100644 index 151ef95a5066..000000000000 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr +++ /dev/null @@ -1,188 +0,0 @@ -use crate::test::utils; -use crate::Token; -use dep::authwit::cheatcodes as authwit_cheatcodes; -use dep::aztec::oracle::random::random; - -#[test] -unconstrained fn burn_public_success() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - let burn_amount = mint_amount / 10; - - // Burn less than balance - Token::at(token_contract_address).burn_public(owner, burn_amount, 0).call(&mut env.public()); - utils::check_public_balance(token_contract_address, owner, mint_amount - burn_amount); -} - -#[test] -unconstrained fn burn_public_on_behalf_of_other() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let burn_amount = mint_amount / 10; - - // Burn on behalf of other - let burn_call_interface = - Token::at(token_contract_address).burn_public(owner, burn_amount, random()); - authwit_cheatcodes::add_public_authwit_from_call_interface( - owner, - recipient, - burn_call_interface, - ); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Burn tokens - burn_call_interface.call(&mut env.public()); - utils::check_public_balance(token_contract_address, owner, mint_amount - burn_amount); -} - -#[test(should_fail_with = "attempt to subtract with underflow")] -unconstrained fn burn_public_failure_more_than_balance() { - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - - // Burn more than balance - let burn_amount = mint_amount * 10; - // Try to burn - Token::at(token_contract_address).burn_public(owner, burn_amount, 0).call(&mut env.public()); -} - -#[test(should_fail_with = "invalid nonce")] -unconstrained fn burn_public_failure_on_behalf_of_self_non_zero_nonce() { - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - - // Burn on behalf of self with non-zero nonce - let burn_amount = mint_amount / 10; - // Try to burn - Token::at(token_contract_address).burn_public(owner, burn_amount, random()).call( - &mut env.public(), - ); -} - -#[test(should_fail_with = "unauthorized")] -unconstrained fn burn_public_failure_on_behalf_of_other_without_approval() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - - // Burn on behalf of other without approval - let burn_amount = mint_amount / 10; - let burn_call_interface = - Token::at(token_contract_address).burn_public(owner, burn_amount, random()); - // Impersonate recipient to perform the call - env.impersonate(recipient); - burn_call_interface.call(&mut env.public()); -} - -#[test(should_fail_with = "unauthorized")] -unconstrained fn burn_public_failure_on_behalf_of_other_wrong_caller() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - - // Burn on behalf of other, wrong designated caller - let burn_amount = mint_amount / 10; - let burn_call_interface = - Token::at(token_contract_address).burn_public(owner, burn_amount, random()); - authwit_cheatcodes::add_public_authwit_from_call_interface(owner, owner, burn_call_interface); - // Impersonate recipient to perform the call - env.impersonate(recipient); - burn_call_interface.call(&mut env.public()); -} - -#[test] -unconstrained fn burn_private_on_behalf_of_self() { - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); - let burn_amount = mint_amount / 10; - - // Burn less than balance - Token::at(token_contract_address).burn(owner, burn_amount, 0).call(&mut env.private()); - utils::check_private_balance(token_contract_address, owner, mint_amount - burn_amount); -} - -#[test] -unconstrained fn burn_private_on_behalf_of_other() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); - let burn_amount = mint_amount / 10; - - // Burn on behalf of other - let burn_call_interface = Token::at(token_contract_address).burn(owner, burn_amount, random()); - authwit_cheatcodes::add_private_authwit_from_call_interface( - owner, - recipient, - burn_call_interface, - ); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Burn tokens - burn_call_interface.call(&mut env.private()); - utils::check_private_balance(token_contract_address, owner, mint_amount - burn_amount); -} - -#[test(should_fail_with = "Balance too low")] -unconstrained fn burn_private_failure_more_than_balance() { - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - - // Burn more than balance - let burn_amount = mint_amount * 10; - Token::at(token_contract_address).burn(owner, burn_amount, 0).call(&mut env.private()); -} - -#[test(should_fail_with = "invalid nonce")] -unconstrained fn burn_private_failure_on_behalf_of_self_non_zero_nonce() { - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - - // Burn more than balance - let burn_amount = mint_amount / 10; - Token::at(token_contract_address).burn(owner, burn_amount, random()).call(&mut env.private()); -} - -#[test(should_fail_with = "Balance too low")] -unconstrained fn burn_private_failure_on_behalf_of_other_more_than_balance() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - - // Burn more than balance - let burn_amount = mint_amount * 10; - // Burn on behalf of other - let burn_call_interface = Token::at(token_contract_address).burn(owner, burn_amount, random()); - authwit_cheatcodes::add_private_authwit_from_call_interface( - owner, - recipient, - burn_call_interface, - ); - // Impersonate recipient to perform the call - env.impersonate(recipient); - burn_call_interface.call(&mut env.private()); -} - -#[test(should_fail_with = "Authorization not found for message hash")] -unconstrained fn burn_private_failure_on_behalf_of_other_without_approval() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - - // Burn more than balance - let burn_amount = mint_amount / 10; - // Burn on behalf of other - let burn_call_interface = Token::at(token_contract_address).burn(owner, burn_amount, 3); - // Impersonate recipient to perform the call - env.impersonate(recipient); - burn_call_interface.call(&mut env.private()); -} - -#[test(should_fail_with = "Authorization not found for message hash")] -unconstrained fn burn_private_failure_on_behalf_of_other_wrong_designated_caller() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - - // Burn more than balance - let burn_amount = mint_amount / 10; - // Burn on behalf of other - let burn_call_interface = Token::at(token_contract_address).burn(owner, burn_amount, 3); - authwit_cheatcodes::add_private_authwit_from_call_interface(owner, owner, burn_call_interface); - // Impersonate recipient to perform the call - env.impersonate(recipient); - burn_call_interface.call(&mut env.private()); -} diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_private.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_private.nr new file mode 100644 index 000000000000..a3ac58f79a12 --- /dev/null +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_private.nr @@ -0,0 +1,107 @@ +use crate::test::utils; +use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::oracle::random::random; + +#[test] +unconstrained fn burn_private_on_behalf_of_self() { + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ false); + let burn_amount = mint_amount / 10; + + // Burn less than balance + Token::at(token_contract_address).burn_private(owner, burn_amount, 0).call(&mut env.private()); + utils::check_private_balance(token_contract_address, owner, mint_amount - burn_amount); +} + +#[test] +unconstrained fn burn_private_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ true); + let burn_amount = mint_amount / 10; + + // Burn on behalf of other + let burn_call_interface = + Token::at(token_contract_address).burn_private(owner, burn_amount, random()); + authwit_cheatcodes::add_private_authwit_from_call_interface( + owner, + recipient, + burn_call_interface, + ); + // Impersonate recipient to perform the call + env.impersonate(recipient); + // Burn tokens + burn_call_interface.call(&mut env.private()); + utils::check_private_balance(token_contract_address, owner, mint_amount - burn_amount); +} + +#[test(should_fail_with = "Balance too low")] +unconstrained fn burn_private_failure_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ false); + + // Burn more than balance + let burn_amount = mint_amount * 10; + Token::at(token_contract_address).burn_private(owner, burn_amount, 0).call(&mut env.private()); +} + +#[test(should_fail_with = "invalid nonce")] +unconstrained fn burn_private_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ false); + + // Burn more than balance + let burn_amount = mint_amount / 10; + Token::at(token_contract_address).burn_private(owner, burn_amount, random()).call( + &mut env.private(), + ); +} + +#[test(should_fail_with = "Balance too low")] +unconstrained fn burn_private_failure_on_behalf_of_other_more_than_balance() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + + // Burn more than balance + let burn_amount = mint_amount * 10; + // Burn on behalf of other + let burn_call_interface = + Token::at(token_contract_address).burn_private(owner, burn_amount, random()); + authwit_cheatcodes::add_private_authwit_from_call_interface( + owner, + recipient, + burn_call_interface, + ); + // Impersonate recipient to perform the call + env.impersonate(recipient); + burn_call_interface.call(&mut env.private()); +} + +#[test(should_fail_with = "Authorization not found for message hash")] +unconstrained fn burn_private_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + + // Burn more than balance + let burn_amount = mint_amount / 10; + // Burn on behalf of other + let burn_call_interface = Token::at(token_contract_address).burn_private(owner, burn_amount, 3); + // Impersonate recipient to perform the call + env.impersonate(recipient); + burn_call_interface.call(&mut env.private()); +} + +#[test(should_fail_with = "Authorization not found for message hash")] +unconstrained fn burn_private_failure_on_behalf_of_other_wrong_designated_caller() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + + // Burn more than balance + let burn_amount = mint_amount / 10; + // Burn on behalf of other + let burn_call_interface = Token::at(token_contract_address).burn_private(owner, burn_amount, 3); + authwit_cheatcodes::add_private_authwit_from_call_interface(owner, owner, burn_call_interface); + // Impersonate recipient to perform the call + env.impersonate(recipient); + burn_call_interface.call(&mut env.private()); +} diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_public.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_public.nr new file mode 100644 index 000000000000..1d427ff30ffa --- /dev/null +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn_public.nr @@ -0,0 +1,89 @@ +use crate::test::utils; +use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::oracle::random::random; + +#[test] +unconstrained fn burn_public_success() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ false); + let burn_amount = mint_amount / 10; + + // Burn less than balance + Token::at(token_contract_address).burn_public(owner, burn_amount, 0).call(&mut env.public()); + utils::check_public_balance(token_contract_address, owner, mint_amount - burn_amount); +} + +#[test] +unconstrained fn burn_public_on_behalf_of_other() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + let burn_amount = mint_amount / 10; + + // Burn on behalf of other + let burn_call_interface = + Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + authwit_cheatcodes::add_public_authwit_from_call_interface( + owner, + recipient, + burn_call_interface, + ); + // Impersonate recipient to perform the call + env.impersonate(recipient); + // Burn tokens + burn_call_interface.call(&mut env.public()); + utils::check_public_balance(token_contract_address, owner, mint_amount - burn_amount); +} + +#[test(should_fail_with = "attempt to subtract with underflow")] +unconstrained fn burn_public_failure_more_than_balance() { + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ false); + + // Burn more than balance + let burn_amount = mint_amount * 10; + // Try to burn + Token::at(token_contract_address).burn_public(owner, burn_amount, 0).call(&mut env.public()); +} + +#[test(should_fail_with = "invalid nonce")] +unconstrained fn burn_public_failure_on_behalf_of_self_non_zero_nonce() { + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ false); + + // Burn on behalf of self with non-zero nonce + let burn_amount = mint_amount / 10; + // Try to burn + Token::at(token_contract_address).burn_public(owner, burn_amount, random()).call( + &mut env.public(), + ); +} + +#[test(should_fail_with = "unauthorized")] +unconstrained fn burn_public_failure_on_behalf_of_other_without_approval() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + + // Burn on behalf of other without approval + let burn_amount = mint_amount / 10; + let burn_call_interface = + Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + // Impersonate recipient to perform the call + env.impersonate(recipient); + burn_call_interface.call(&mut env.public()); +} + +#[test(should_fail_with = "unauthorized")] +unconstrained fn burn_public_failure_on_behalf_of_other_wrong_caller() { + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_public(/* with_account_contracts */ true); + + // Burn on behalf of other, wrong designated caller + let burn_amount = mint_amount / 10; + let burn_call_interface = + Token::at(token_contract_address).burn_public(owner, burn_amount, random()); + authwit_cheatcodes::add_public_authwit_from_call_interface(owner, owner, burn_call_interface); + // Impersonate recipient to perform the call + env.impersonate(recipient); + burn_call_interface.call(&mut env.public()); +} diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/mint_to_public.nr similarity index 58% rename from noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr rename to noir-projects/noir-contracts/contracts/token_contract/src/test/mint_to_public.nr index bc4f877d2a3a..c4cb9055ac0e 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/mint_to_public.nr @@ -1,14 +1,12 @@ -use crate::test::utils; -use crate::{Token, types::transparent_note::TransparentNote}; -use dep::aztec::{oracle::random::random, test::helpers::cheatcodes}; +use crate::{test::utils, Token}; #[test] -unconstrained fn mint_public_success() { +unconstrained fn mint_to_public_success() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, _) = utils::setup(/* with_account_contracts */ false); let mint_amount = 10000; - Token::at(token_contract_address).mint_public(owner, mint_amount).call(&mut env.public()); + Token::at(token_contract_address).mint_to_public(owner, mint_amount).call(&mut env.public()); utils::check_public_balance(token_contract_address, owner, mint_amount); @@ -17,7 +15,7 @@ unconstrained fn mint_public_success() { } #[test] -unconstrained fn mint_public_failures() { +unconstrained fn mint_to_public_failures() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, recipient) = utils::setup(/* with_account_contracts */ false); @@ -25,9 +23,9 @@ unconstrained fn mint_public_failures() { // As non-minter let mint_amount = 10000; env.impersonate(recipient); - let mint_public_call_interface = - Token::at(token_contract_address).mint_public(owner, mint_amount); - env.assert_public_call_fails(mint_public_call_interface); + let mint_to_public_call_interface = + Token::at(token_contract_address).mint_to_public(owner, mint_amount); + env.assert_public_call_fails(mint_to_public_call_interface); utils::check_public_balance(token_contract_address, owner, 0); @@ -35,23 +33,23 @@ unconstrained fn mint_public_failures() { // Overflow recipient let mint_amount = 2.pow_32(128); - let mint_public_call_interface = - Token::at(token_contract_address).mint_public(owner, mint_amount); - env.assert_public_call_fails(mint_public_call_interface); + let mint_to_public_call_interface = + Token::at(token_contract_address).mint_to_public(owner, mint_amount); + env.assert_public_call_fails(mint_to_public_call_interface); utils::check_public_balance(token_contract_address, owner, 0); // Overflow total supply let mint_for_recipient_amount = 1000; - Token::at(token_contract_address).mint_public(recipient, mint_for_recipient_amount).call( + Token::at(token_contract_address).mint_to_public(recipient, mint_for_recipient_amount).call( &mut env.public(), ); let mint_amount = 2.pow_32(128) - mint_for_recipient_amount; - let mint_public_call_interface = - Token::at(token_contract_address).mint_public(owner, mint_amount); - env.assert_public_call_fails(mint_public_call_interface); + let mint_to_public_call_interface = + Token::at(token_contract_address).mint_to_public(owner, mint_amount); + env.assert_public_call_fails(mint_to_public_call_interface); utils::check_public_balance(token_contract_address, recipient, mint_for_recipient_amount); utils::check_public_balance(token_contract_address, owner, 0); diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr index 2990163baae9..d326fe250be1 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr @@ -7,7 +7,7 @@ use std::test::OracleMock; #[test] unconstrained fn setup_refund_success() { let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(true); + utils::setup_and_mint_to_private(true); // Renaming owner and recipient to match naming in Token let user = owner; @@ -65,7 +65,7 @@ unconstrained fn setup_refund_success() { #[test(should_fail_with = "Balance too low")] unconstrained fn setup_refund_insufficient_funded_amount() { let (env, token_contract_address, owner, recipient, _mint_amount) = - utils::setup_and_mint_private(true); + utils::setup_and_mint_to_private(true); // Renaming owner and recipient to match naming in Token let user = owner; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr deleted file mode 100644 index aef1d98f9cc2..000000000000 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr +++ /dev/null @@ -1,179 +0,0 @@ -use crate::test::utils; -use crate::{Token, types::transparent_note::TransparentNote}; -use dep::authwit::cheatcodes as authwit_cheatcodes; -use dep::aztec::{hash::compute_secret_hash, oracle::random::random}; - -#[test] -unconstrained fn shielding_on_behalf_of_self() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens - let shield_amount = mint_amount / 10; - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0).call( - &mut env.public(), - ); - - // We need to manually add the note to TXE because `TransparentNote` does not support automatic note log delivery. - env.add_note( - &mut TransparentNote::new(shield_amount, secret_hash), - Token::storage_layout().pending_shields.slot, - token_contract_address, - ); - - // Redeem our shielded tokens - Token::at(token_contract_address).redeem_shield(owner, shield_amount, secret).call( - &mut env.private(), - ); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount - shield_amount); - utils::check_private_balance(token_contract_address, owner, shield_amount); -} - -#[test] -unconstrained fn shielding_on_behalf_of_other() { - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - - // Shield tokens on behalf of owner - let shield_amount = 1000; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0); - authwit_cheatcodes::add_public_authwit_from_call_interface( - owner, - recipient, - shield_call_interface, - ); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Shield tokens - shield_call_interface.call(&mut env.public()); - - // Become owner again - env.impersonate(owner); - // We need to manually add the note to TXE because `TransparentNote` does not support automatic note log delivery. - env.add_note( - &mut TransparentNote::new(shield_amount, secret_hash), - Token::storage_layout().pending_shields.slot, - token_contract_address, - ); - - // Redeem our shielded tokens - Token::at(token_contract_address).redeem_shield(owner, shield_amount, secret).call( - &mut env.private(), - ); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount - shield_amount); - utils::check_private_balance(token_contract_address, owner, shield_amount); -} - -#[test] -unconstrained fn shielding_failure_on_behalf_of_self_more_than_balance() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens - let shield_amount = mint_amount + 1; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0); - env.assert_public_call_fails(shield_call_interface); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount); - utils::check_private_balance(token_contract_address, owner, 0); -} - -#[test] -unconstrained fn shielding_failure_on_behalf_of_self_invalid_nonce() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens - let shield_amount = mint_amount / 10; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, random()); - env.assert_public_call_fails(shield_call_interface); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount); - utils::check_private_balance(token_contract_address, owner, 0); -} - -#[test] -unconstrained fn shielding_failure_on_behalf_of_other_more_than_balance() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens on behalf of owner - let shield_amount = mint_amount + 1; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0); - authwit_cheatcodes::add_public_authwit_from_call_interface( - owner, - recipient, - shield_call_interface, - ); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Shield tokens - env.assert_public_call_fails(shield_call_interface); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount); - utils::check_private_balance(token_contract_address, owner, 0); -} - -#[test] -unconstrained fn shielding_failure_on_behalf_of_other_wrong_caller() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens on behalf of owner - let shield_amount = mint_amount + 1; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0); - authwit_cheatcodes::add_public_authwit_from_call_interface(owner, owner, shield_call_interface); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Shield tokens - env.assert_public_call_fails(shield_call_interface); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount); - utils::check_private_balance(token_contract_address, owner, 0); -} - -#[test] -unconstrained fn shielding_failure_on_behalf_of_other_without_approval() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); - let secret = random(); - let secret_hash = compute_secret_hash(secret); - // Shield tokens on behalf of owner - let shield_amount = mint_amount + 1; - let shield_call_interface = - Token::at(token_contract_address).shield(owner, shield_amount, secret_hash, 0); - // Impersonate recipient to perform the call - env.impersonate(recipient); - // Shield tokens - env.assert_public_call_fails(shield_call_interface); - - // Check balances - utils::check_public_balance(token_contract_address, owner, mint_amount); - utils::check_private_balance(token_contract_address, owner, 0); -} diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr new file mode 100644 index 000000000000..24015869d66a --- /dev/null +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer.nr @@ -0,0 +1,64 @@ +use crate::test::utils; +use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::test::helpers::cheatcodes; + +#[test] +unconstrained fn transfer_private() { + // Setup without account contracts. We are not using authwits here, so dummy accounts are enough + let (env, token_contract_address, owner, recipient, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ false); + + // docs:start:txe_test_transfer_private + // Transfer tokens + let transfer_amount = 1000; + Token::at(token_contract_address).transfer(recipient, transfer_amount).call(&mut env.private()); + // docs:end:txe_test_transfer_private + // Check balances + utils::check_private_balance(token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance(token_contract_address, recipient, transfer_amount); +} + +#[test] +unconstrained fn transfer_private_to_self() { + // Setup without account contracts. We are not using authwits here, so dummy accounts are enough + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ false); + // Transfer tokens + let transfer_amount = 1000; + Token::at(token_contract_address).transfer(owner, transfer_amount).call(&mut env.private()); + + // Check balances + utils::check_private_balance(token_contract_address, owner, mint_amount); +} + +#[test] +unconstrained fn transfer_private_to_non_deployed_account() { + // Setup without account contracts. We are not using authwits here, so dummy accounts are enough + let (env, token_contract_address, owner, _, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ false); + let not_deployed = cheatcodes::create_account(); + // Transfer tokens + let transfer_amount = 1000; + Token::at(token_contract_address).transfer(not_deployed.address, transfer_amount).call( + &mut env.private(), + ); + + // Check balances + utils::check_private_balance(token_contract_address, owner, mint_amount - transfer_amount); + utils::check_private_balance( + token_contract_address, + not_deployed.address, + transfer_amount, + ); +} + +#[test(should_fail_with = "Balance too low")] +unconstrained fn transfer_private_failure_more_than_balance() { + // Setup without account contracts. We are not using authwits here, so dummy accounts are enough + let (env, token_contract_address, _, recipient, mint_amount) = + utils::setup_and_mint_to_private(/* with_account_contracts */ false); + // Transfer tokens + let transfer_amount = mint_amount + 1; + Token::at(token_contract_address).transfer(recipient, transfer_amount).call(&mut env.private()); +} diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr similarity index 51% rename from noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr rename to noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr index 11f32bba6eca..e7113a7aa447 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_private.nr @@ -1,68 +1,17 @@ use crate::test::utils; use crate::Token; use dep::authwit::cheatcodes as authwit_cheatcodes; -use dep::aztec::test::helpers::cheatcodes; - -#[test] -unconstrained fn transfer_private() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); - - // docs:start:txe_test_transfer_private - // Transfer tokens - let transfer_amount = 1000; - Token::at(token_contract_address).transfer(recipient, transfer_amount).call(&mut env.private()); - // docs:end:txe_test_transfer_private - // Check balances - utils::check_private_balance(token_contract_address, owner, mint_amount - transfer_amount); - utils::check_private_balance(token_contract_address, recipient, transfer_amount); -} - -#[test] -unconstrained fn transfer_private_to_self() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); - // Transfer tokens - let transfer_amount = 1000; - Token::at(token_contract_address).transfer(owner, transfer_amount).call(&mut env.private()); - - // Check balances - utils::check_private_balance(token_contract_address, owner, mint_amount); -} - -#[test] -unconstrained fn transfer_private_to_non_deployed_account() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); - let not_deployed = cheatcodes::create_account(); - // Transfer tokens - let transfer_amount = 1000; - Token::at(token_contract_address).transfer(not_deployed.address, transfer_amount).call( - &mut env.private(), - ); - - // Check balances - utils::check_private_balance(token_contract_address, owner, mint_amount - transfer_amount); - utils::check_private_balance( - token_contract_address, - not_deployed.address, - transfer_amount, - ); -} #[test] unconstrained fn transfer_private_on_behalf_of_other() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); // Add authwit // docs:start:private_authwit let transfer_amount = 1000; let transfer_private_from_call_interface = - Token::at(token_contract_address).transfer_from(owner, recipient, transfer_amount, 1); + Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_private_authwit_from_call_interface( owner, recipient, @@ -78,26 +27,16 @@ unconstrained fn transfer_private_on_behalf_of_other() { utils::check_private_balance(token_contract_address, recipient, transfer_amount); } -#[test(should_fail_with = "Balance too low")] -unconstrained fn transfer_private_failure_more_than_balance() { - // Setup without account contracts. We are not using authwits here, so dummy accounts are enough - let (env, token_contract_address, _, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); - // Transfer tokens - let transfer_amount = mint_amount + 1; - Token::at(token_contract_address).transfer(recipient, transfer_amount).call(&mut env.private()); -} - // docs:start:fail_with_message #[test(should_fail_with = "invalid nonce")] unconstrained fn transfer_private_failure_on_behalf_of_self_non_zero_nonce() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, recipient, _) = - utils::setup_and_mint_private(/* with_account_contracts */ false); + utils::setup_and_mint_to_private(/* with_account_contracts */ false); // Add authwit let transfer_amount = 1000; let transfer_private_from_call_interface = - Token::at(token_contract_address).transfer_from(owner, recipient, transfer_amount, 1); + Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_private_authwit_from_call_interface( owner, recipient, @@ -112,11 +51,11 @@ unconstrained fn transfer_private_failure_on_behalf_of_self_non_zero_nonce() { unconstrained fn transfer_private_failure_on_behalf_of_more_than_balance() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); // Add authwit let transfer_amount = mint_amount + 1; let transfer_private_from_call_interface = - Token::at(token_contract_address).transfer_from(owner, recipient, transfer_amount, 1); + Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_private_authwit_from_call_interface( owner, recipient, @@ -132,11 +71,11 @@ unconstrained fn transfer_private_failure_on_behalf_of_more_than_balance() { unconstrained fn transfer_private_failure_on_behalf_of_other_without_approval() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, _) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); // Add authwit let transfer_amount = 1000; let transfer_private_from_call_interface = - Token::at(token_contract_address).transfer_from(owner, recipient, transfer_amount, 1); + Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1); // Impersonate recipient to perform the call env.impersonate(recipient); // Transfer tokens @@ -147,11 +86,11 @@ unconstrained fn transfer_private_failure_on_behalf_of_other_without_approval() unconstrained fn transfer_private_failure_on_behalf_of_other_wrong_caller() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, _) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); // Add authwit let transfer_amount = 1000; let transfer_private_from_call_interface = - Token::at(token_contract_address).transfer_from(owner, recipient, transfer_amount, 1); + Token::at(token_contract_address).transfer_in_private(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_private_authwit_from_call_interface( owner, owner, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr similarity index 70% rename from noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr rename to noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr index 5dddac325736..aa8ba0376fb3 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_in_public.nr @@ -7,10 +7,10 @@ use dep::aztec::oracle::random::random; unconstrained fn public_transfer() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // Transfer tokens let transfer_amount = mint_amount / 10; - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 0).call( + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 0).call( &mut env.public(), ); @@ -23,11 +23,11 @@ unconstrained fn public_transfer() { unconstrained fn public_transfer_to_self() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // Transfer tokens let transfer_amount = mint_amount / 10; // docs:start:call_public - Token::at(token_contract_address).transfer_public(owner, owner, transfer_amount, 0).call( + Token::at(token_contract_address).transfer_in_public(owner, owner, transfer_amount, 0).call( &mut env.public(), ); // docs:end:call_public @@ -39,19 +39,19 @@ unconstrained fn public_transfer_to_self() { unconstrained fn public_transfer_on_behalf_of_other() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); + utils::setup_and_mint_to_public(/* with_account_contracts */ true); let transfer_amount = mint_amount / 10; - let public_transfer_from_call_interface = - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 1); + let public_transfer_in_private_call_interface = + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_public_authwit_from_call_interface( owner, recipient, - public_transfer_from_call_interface, + public_transfer_in_private_call_interface, ); // Impersonate recipient to perform the call env.impersonate(recipient); // Transfer tokens - public_transfer_from_call_interface.call(&mut env.public()); + public_transfer_in_private_call_interface.call(&mut env.public()); // Check balances utils::check_public_balance(token_contract_address, owner, mint_amount - transfer_amount); utils::check_public_balance(token_contract_address, recipient, transfer_amount); @@ -61,11 +61,11 @@ unconstrained fn public_transfer_on_behalf_of_other() { unconstrained fn public_transfer_failure_more_than_balance() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // Transfer tokens let transfer_amount = mint_amount + 1; let public_transfer_call_interface = - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 0); + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 0); // Try to transfer tokens public_transfer_call_interface.call(&mut env.public()); } @@ -74,10 +74,10 @@ unconstrained fn public_transfer_failure_more_than_balance() { unconstrained fn public_transfer_failure_on_behalf_of_self_non_zero_nonce() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // Transfer tokens let transfer_amount = mint_amount / 10; - let public_transfer_call_interface = Token::at(token_contract_address).transfer_public( + let public_transfer_call_interface = Token::at(token_contract_address).transfer_in_public( owner, recipient, transfer_amount, @@ -96,52 +96,52 @@ unconstrained fn public_transfer_failure_on_behalf_of_self_non_zero_nonce() { unconstrained fn public_transfer_failure_on_behalf_of_other_without_approval() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); + utils::setup_and_mint_to_public(/* with_account_contracts */ true); let transfer_amount = mint_amount / 10; - let public_transfer_from_call_interface = - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 1); + let public_transfer_in_private_call_interface = + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1); // Impersonate recipient to perform the call env.impersonate(recipient); // Try to transfer tokens - public_transfer_from_call_interface.call(&mut env.public()); + public_transfer_in_private_call_interface.call(&mut env.public()); } #[test(should_fail_with = "attempt to subtract with underflow")] unconstrained fn public_transfer_failure_on_behalf_of_other_more_than_balance() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); + utils::setup_and_mint_to_public(/* with_account_contracts */ true); let transfer_amount = mint_amount + 1; // docs:start:public_authwit - let public_transfer_from_call_interface = - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 1); + let public_transfer_in_private_call_interface = + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_public_authwit_from_call_interface( owner, recipient, - public_transfer_from_call_interface, + public_transfer_in_private_call_interface, ); // docs:end:public_authwit // Impersonate recipient to perform the call env.impersonate(recipient); // Try to transfer tokens - public_transfer_from_call_interface.call(&mut env.public()); + public_transfer_in_private_call_interface.call(&mut env.public()); } #[test(should_fail_with = "unauthorized")] unconstrained fn public_transfer_failure_on_behalf_of_other_wrong_caller() { // Setup with account contracts. Slower since we actually deploy them, but needed for authwits. let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_public(/* with_account_contracts */ true); + utils::setup_and_mint_to_public(/* with_account_contracts */ true); let transfer_amount = mint_amount / 10; - let public_transfer_from_call_interface = - Token::at(token_contract_address).transfer_public(owner, recipient, transfer_amount, 1); + let public_transfer_in_private_call_interface = + Token::at(token_contract_address).transfer_in_public(owner, recipient, transfer_amount, 1); authwit_cheatcodes::add_public_authwit_from_call_interface( owner, owner, - public_transfer_from_call_interface, + public_transfer_in_private_call_interface, ); // Impersonate recipient to perform the call env.impersonate(recipient); // Try to transfer tokens - public_transfer_from_call_interface.call(&mut env.public()); + public_transfer_in_private_call_interface.call(&mut env.public()); } diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_private.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_private.nr index a02f4f3d4a21..f48bfb6127e5 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_private.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_private.nr @@ -1,21 +1,18 @@ use crate::{test::utils, Token}; -use dep::aztec::{ - keys::getters::get_public_keys, oracle::random::random, - protocol_types::storage::map::derive_storage_slot_in_map, -}; +use dep::aztec::oracle::random::random; use std::test::OracleMock; -/// Internal orchestration means that the calls to `prepare_transfer_to_private` +/// Internal orchestration means that the calls to `prepare_private_balance_increase` /// and `finalize_transfer_to_private` are done by the TOKEN contract itself. /// In this test's case this is done by the `Token::transfer_to_private(...)` function called /// in `utils::setup_mint_and_transfer_to_private`. #[test] unconstrained fn transfer_to_private_internal_orchestration() { - // The transfer to private is done in `utils::setup_and_mint_private` and for this reason + // The transfer to private is done in `utils::setup_and_mint_to_private` and for this reason // in this test we just call it and check the outcome. // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (_, token_contract_address, user, _, amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); + utils::setup_and_mint_to_private(/* with_account_contracts */ false); // User's private balance should be equal to the amount utils::check_private_balance(token_contract_address, user, amount); @@ -27,7 +24,7 @@ unconstrained fn transfer_to_private_internal_orchestration() { unconstrained fn transfer_to_private_external_orchestration() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, _, recipient, amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); let note_randomness = random(); @@ -36,7 +33,7 @@ unconstrained fn transfer_to_private_external_orchestration() { // We prepare the transfer let hiding_point_slot: Field = Token::at(token_contract_address) - .prepare_transfer_to_private(recipient) + .prepare_private_balance_increase(recipient) .call(&mut env.private()); // Finalize the transfer of the tokens (message sender owns the tokens in public) @@ -61,7 +58,7 @@ unconstrained fn transfer_to_private_external_orchestration() { unconstrained fn transfer_to_private_transfer_not_prepared() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, _, _, amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // Transfer was not prepared so we can use random value for the hiding point slot let hiding_point_slot = random(); @@ -76,13 +73,13 @@ unconstrained fn transfer_to_private_transfer_not_prepared() { unconstrained fn transfer_to_private_failure_not_an_owner() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, _, not_owner, amount) = - utils::setup_and_mint_public(/* with_account_contracts */ false); + utils::setup_and_mint_to_public(/* with_account_contracts */ false); // (For this specific test we could set a random value for the commitment and not do the call to `prepare...` // as the token balance check is before we use the value but that would made the test less robust against changes // in the contract.) let hiding_point_slot: Field = Token::at(token_contract_address) - .prepare_transfer_to_private(not_owner) + .prepare_private_balance_increase(not_owner) .call(&mut env.private()); // Try transferring someone else's token balance diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_public.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_public.nr index 63f84481c749..7789bf8aeb44 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_public.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_to_public.nr @@ -7,7 +7,7 @@ use dep::aztec::oracle::random::random; unconstrained fn transfer_to_public_on_behalf_of_self() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); + utils::setup_and_mint_to_private(/* with_account_contracts */ false); let transfer_to_public_amount = mint_amount / 10; Token::at(token_contract_address) @@ -24,7 +24,7 @@ unconstrained fn transfer_to_public_on_behalf_of_self() { #[test] unconstrained fn transfer_to_public_on_behalf_of_other() { let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); let transfer_to_public_amount = mint_amount / 10; let transfer_to_public_call_interface = Token::at(token_contract_address).transfer_to_public( @@ -54,7 +54,7 @@ unconstrained fn transfer_to_public_on_behalf_of_other() { unconstrained fn transfer_to_public_failure_more_than_balance() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); + utils::setup_and_mint_to_private(/* with_account_contracts */ false); let transfer_to_public_amount = mint_amount + 1; Token::at(token_contract_address) @@ -66,7 +66,7 @@ unconstrained fn transfer_to_public_failure_more_than_balance() { unconstrained fn transfer_to_public_failure_on_behalf_of_self_non_zero_nonce() { // Setup without account contracts. We are not using authwits here, so dummy accounts are enough let (env, token_contract_address, owner, _, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ false); + utils::setup_and_mint_to_private(/* with_account_contracts */ false); let transfer_to_public_amount = mint_amount + 1; Token::at(token_contract_address) @@ -77,7 +77,7 @@ unconstrained fn transfer_to_public_failure_on_behalf_of_self_non_zero_nonce() { #[test(should_fail_with = "Balance too low")] unconstrained fn transfer_to_public_failure_on_behalf_of_other_more_than_balance() { let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); let transfer_to_public_amount = mint_amount + 1; let transfer_to_public_call_interface = Token::at(token_contract_address).transfer_to_public( @@ -100,7 +100,7 @@ unconstrained fn transfer_to_public_failure_on_behalf_of_other_more_than_balance #[test(should_fail_with = "Authorization not found for message hash")] unconstrained fn transfer_to_public_failure_on_behalf_of_other_invalid_designated_caller() { let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); let transfer_to_public_amount = mint_amount + 1; let transfer_to_public_call_interface = Token::at(token_contract_address).transfer_to_public( @@ -123,7 +123,7 @@ unconstrained fn transfer_to_public_failure_on_behalf_of_other_invalid_designate #[test(should_fail_with = "Authorization not found for message hash")] unconstrained fn transfer_to_public_failure_on_behalf_of_other_no_approval() { let (env, token_contract_address, owner, recipient, mint_amount) = - utils::setup_and_mint_private(/* with_account_contracts */ true); + utils::setup_and_mint_to_private(/* with_account_contracts */ true); let transfer_to_public_amount = mint_amount + 1; let transfer_to_public_call_interface = Token::at(token_contract_address).transfer_to_public( diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr index 893e659706fe..9ccc8ed6b7b2 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr @@ -44,19 +44,19 @@ pub unconstrained fn setup( (&mut env, token_contract_address, owner, recipient) } -pub unconstrained fn setup_and_mint_public( +pub unconstrained fn setup_and_mint_to_public( with_account_contracts: bool, ) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { // Setup let (env, token_contract_address, owner, recipient) = setup(with_account_contracts); let mint_amount = 10000; // Mint some tokens - Token::at(token_contract_address).mint_public(owner, mint_amount).call(&mut env.public()); + Token::at(token_contract_address).mint_to_public(owner, mint_amount).call(&mut env.public()); (env, token_contract_address, owner, recipient, mint_amount) } -pub unconstrained fn setup_and_mint_private( +pub unconstrained fn setup_and_mint_to_private( with_account_contracts: bool, ) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { // Setup the tokens and mint public balance @@ -64,12 +64,12 @@ pub unconstrained fn setup_and_mint_private( // Mint some tokens let mint_amount = 10000; - mint_private(env, token_contract_address, owner, mint_amount); + mint_to_private(env, token_contract_address, owner, mint_amount); (env, token_contract_address, owner, recipient, mint_amount) } -pub unconstrained fn mint_private( +pub unconstrained fn mint_to_private( env: &mut TestEnvironment, token_contract_address: AztecAddress, recipient: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types.nr index cad3fda646e0..1bc5f644e4ff 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types.nr @@ -1,2 +1 @@ -pub(crate) mod transparent_note; pub(crate) mod balance_set; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr deleted file mode 100644 index ed1f08e0d744..000000000000 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ /dev/null @@ -1,63 +0,0 @@ -// docs:start:token_types_all -use dep::aztec::{ - macros::notes::note, - note::utils::compute_note_hash_for_nullify, - prelude::{NoteHeader, NullifiableNote, PrivateContext}, - protocol_types::{ - constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, -}; - -use dep::std::mem::zeroed; - -// Transparent note represents a note that is created in the clear (public execution), but can only be spent by those -// that know the preimage of the "secret_hash" (the secret). This is typically used when shielding a token balance. -// Owner of the tokens provides a "secret_hash" as an argument to the public "shield" function and then the tokens -// can be redeemed in private by presenting the preimage of the "secret_hash" (the secret). -#[note] -pub struct TransparentNote { - amount: Field, - secret_hash: Field, -} - -impl NullifiableNote for TransparentNote { - // Computing a nullifier in a transparent note is not guarded by making secret a part of the nullifier preimage (as - // is common in other cases) and instead is guarded by the functionality of "redeem_shield" function. There we do - // the following: - // 1) We pass the secret as an argument to the function and use it to compute a secret hash, - // 2) we fetch a note via the "get_notes" oracle which accepts the secret hash as an argument, - // 3) the "get_notes" oracle constrains that the secret hash in the returned note matches the one computed in - // circuit. - // This achieves that the note can only be spent by the party that knows the secret. - fn compute_nullifier( - self, - _context: &mut PrivateContext, - _note_hash_for_nullify: Field, - ) -> Field { - let note_hash_for_nullify = compute_note_hash_for_nullify(self); - poseidon2_hash_with_separator( - [note_hash_for_nullify], - GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ) - } - - unconstrained fn compute_nullifier_without_context(self) -> Field { - // compute_nullifier ignores both of its parameters so we can reuse it here - self.compute_nullifier(zeroed(), zeroed()) - } -} - -impl TransparentNote { - // CONSTRUCTORS - pub fn new(amount: Field, secret_hash: Field) -> Self { - TransparentNote { amount, secret_hash, header: NoteHeader::empty() } - } -} - -impl Eq for TransparentNote { - fn eq(self, other: Self) -> bool { - (self.amount == other.amount) & (self.secret_hash == other.secret_hash) - } -} - -// docs:end:token_types_all diff --git a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr index c31f6c4e0a93..682e80ce5f12 100644 --- a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr @@ -1,53 +1,57 @@ -// docs:start:mint_public_content_hash_nr +// docs:start:mint_to_public_content_hash_nr use dep::aztec::prelude::{AztecAddress, EthAddress}; use dep::aztec::protocol_types::hash::sha256_to_field; -// Computes a content hash of a deposit/mint_public message. +// Computes a content hash of a deposit/mint_to_public message. // Refer TokenPortal.sol for reference on L1. -pub fn get_mint_public_content_hash(owner: AztecAddress, amount: Field) -> Field { +pub fn get_mint_to_public_content_hash(owner: AztecAddress, amount: Field) -> Field { let mut hash_bytes = [0; 68]; let recipient_bytes:[u8; 32] = owner.to_field().to_be_bytes(); let amount_bytes:[u8; 32] = amount.to_be_bytes(); + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { std::hash::keccak256("mint_to_public(bytes32,uint256)".as_bytes(), 31) }; + + for i in 0..4 { + hash_bytes[i] = selector[i]; + } + for i in 0..32 { hash_bytes[i + 4] = recipient_bytes[i]; hash_bytes[i + 36] = amount_bytes[i]; } - // Function selector: 0x3e87b9be keccak256('mint_public(bytes32,uint256)') - hash_bytes[0] = 0x3e; - hash_bytes[1] = 0x87; - hash_bytes[2] = 0xb9; - hash_bytes[3] = 0xbe; - let content_hash = sha256_to_field(hash_bytes); content_hash } -// docs:end:mint_public_content_hash_nr +// docs:end:mint_to_public_content_hash_nr -// docs:start:get_mint_private_content_hash -// Computes a content hash of a deposit/mint_private message. +// docs:start:get_mint_to_private_content_hash +// Computes a content hash of a deposit/mint_to_private message. // Refer TokenPortal.sol for reference on L1. -pub fn get_mint_private_content_hash( +pub fn get_mint_to_private_content_hash( amount: Field ) -> Field { let mut hash_bytes = [0; 36]; let amount_bytes:[u8; 32] = amount.to_be_bytes(); + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { std::hash::keccak256("mint_to_private(uint256)".as_bytes(), 24) }; + + for i in 0..4 { + hash_bytes[i] = selector[i]; + } + for i in 0..32 { hash_bytes[i + 4] = amount_bytes[i]; } - // Function selector: 0xb81559e2 keccak256('mint_private(uint256)') - hash_bytes[0] = 0xb8; - hash_bytes[1] = 0x15; - hash_bytes[2] = 0x59; - hash_bytes[3] = 0xe2; - let content_hash = sha256_to_field(hash_bytes); content_hash } -// docs:end:get_mint_private_content_hash +// docs:end:get_mint_to_private_content_hash // docs:start:get_withdraw_content_hash // Computes a content hash of a withdraw message. @@ -61,11 +65,13 @@ pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, caller_on let amount_bytes: [u8; 32] = amount.to_be_bytes(); let caller_on_l1_bytes: [u8; 32] = caller_on_l1.to_field().to_be_bytes(); - // 0x69328dec, selector for "withdraw(address,uint256,address)" - hash_bytes[0] = 0x69; - hash_bytes[1] = 0x32; - hash_bytes[2] = 0x8d; - hash_bytes[3] = 0xec; + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { std::hash::keccak256("withdraw(address,uint256,address)".as_bytes(), 33) }; + + for i in 0..4 { + hash_bytes[i] = selector[i]; + } for i in 0..32 { hash_bytes[i + 4] = recipient_bytes[i]; diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index f95c986983d8..e1fd634121f6 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -62,7 +62,7 @@ contract Uniswap { // Transfer funds to this contract Token::at(input_asset) - .transfer_public( + .transfer_in_public( sender, context.this_address(), input_amount, diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr index a0e2ca12774b..dc5605d7fd09 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr @@ -27,11 +27,19 @@ pub fn compute_swap_public_content_hash( secret_hash_for_L1_to_l2_message.to_be_bytes(); let caller_on_L1_bytes: [u8; 32] = caller_on_L1.to_field().to_be_bytes(); - // function selector: 0xf18186d8 keccak256("swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)") - hash_bytes[0] = 0xf1; - hash_bytes[1] = 0x81; - hash_bytes[2] = 0x86; - hash_bytes[3] = 0xd8; + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { + std::hash::keccak256( + "swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)".as_bytes(), + 75, + ) + }; + + hash_bytes[0] = selector[0]; + hash_bytes[1] = selector[1]; + hash_bytes[2] = selector[2]; + hash_bytes[3] = selector[3]; for i in 0..32 { hash_bytes[i + 4] = input_token_portal_bytes[i]; @@ -73,11 +81,19 @@ pub fn compute_swap_private_content_hash( secret_hash_for_L1_to_l2_message.to_be_bytes(); let caller_on_L1_bytes: [u8; 32] = caller_on_L1.to_field().to_be_bytes(); - // function selector: 0x84e55078 keccak256("swap_private(address,uint256,uint24,address,uint256,bytes32,address)") - hash_bytes[0] = 0x84; - hash_bytes[1] = 0xe5; - hash_bytes[2] = 0x50; - hash_bytes[3] = 0x78; + // The purpose of including the following selector is to make the message unique to that specific call. Note that + // it has nothing to do with calling the function. + let selector = comptime { + std::hash::keccak256( + "swap_private(address,uint256,uint24,address,uint256,bytes32,address)".as_bytes(), + 68, + ) + }; + + hash_bytes[0] = selector[0]; + hash_bytes[1] = selector[1]; + hash_bytes[2] = selector[2]; + hash_bytes[3] = selector[3]; for i in 0..32 { hash_bytes[i + 4] = input_token_portal_bytes[i]; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr index df372aa9751a..0d20c84272fc 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr @@ -19,7 +19,7 @@ use dep::types::{ side_effect::{Ordered, RangeOrdered}, }, address::AztecAddress, - constants::MAX_FIELD_VALUE, + constants::{MAX_FIELD_VALUE, REGISTERER_CONTRACT_ADDRESS}, transaction::tx_request::TxRequest, utils::arrays::find_index_hint, }; @@ -218,9 +218,16 @@ impl PrivateCallDataValidator { "encrypted_logs_hashes must be empty for static calls", ); assert_eq( - self.array_lengths.unencrypted_logs_hashes, + self.array_lengths.contract_class_logs_hashes, 0, - "unencrypted_logs_hashes must be empty for static calls", + "contract_class_logs_hashes must be empty for static calls", + ); + } + if (self.array_lengths.contract_class_logs_hashes != 0) { + assert_eq( + call_context.contract_address, + REGISTERER_CONTRACT_ADDRESS, + "only the class registerer may emit contract class logs", ); } } @@ -351,8 +358,8 @@ impl PrivateCallDataValidator { validate_incrementing_counters_within_range( counter_start, counter_end, - public_inputs.unencrypted_logs_hashes, - self.array_lengths.unencrypted_logs_hashes, + public_inputs.contract_class_logs_hashes, + self.array_lengths.contract_class_logs_hashes, ); validate_incrementing_counter_ranges_within_range( counter_start, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr index ab4d9245ec0b..66eee01a1b9b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr @@ -242,9 +242,9 @@ impl PrivateKernelCircuitOutputValidator { array_lengths.encrypted_logs_hashes, ); assert_array_prepended( - self.output.end.unencrypted_logs_hashes, - previous_kernel.end.unencrypted_logs_hashes, - array_lengths.unencrypted_logs_hashes, + self.output.end.contract_class_logs_hashes, + previous_kernel.end.contract_class_logs_hashes, + array_lengths.contract_class_logs_hashes, ); assert_array_prepended( self.output.end.public_call_requests, @@ -324,10 +324,10 @@ impl PrivateKernelCircuitOutputValidator { contract_address, ); assert_array_appended_scoped( - self.output.end.unencrypted_logs_hashes, - private_call.unencrypted_logs_hashes, - array_lengths.unencrypted_logs_hashes, - offsets.unencrypted_logs_hashes, + self.output.end.contract_class_logs_hashes, + private_call.contract_class_logs_hashes, + array_lengths.contract_class_logs_hashes, + offsets.contract_class_logs_hashes, contract_address, ); assert_array_appended( diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr index 7e58f15693ca..09d6d7944f19 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr @@ -76,8 +76,8 @@ impl PrivateKernelCircuitPublicInputsComposer { public_inputs.end.note_encrypted_logs_hashes = array_to_bounded_vec(start.note_encrypted_logs_hashes); public_inputs.end.encrypted_logs_hashes = array_to_bounded_vec(start.encrypted_logs_hashes); - public_inputs.end.unencrypted_logs_hashes = - array_to_bounded_vec(start.unencrypted_logs_hashes); + public_inputs.end.contract_class_logs_hashes = + array_to_bounded_vec(start.contract_class_logs_hashes); public_inputs.end.public_call_requests = array_to_bounded_vec(start.public_call_requests); public_inputs.end.private_call_stack = array_to_bounded_vec(start.private_call_stack); @@ -102,8 +102,8 @@ impl PrivateKernelCircuitPublicInputsComposer { // Note hashes, nullifiers, note_encrypted_logs_hashes, and encrypted_logs_hashes are sorted in the reset circuit. self.public_inputs.end.l2_to_l1_msgs.storage = sort_by_counter_asc(self.public_inputs.end.l2_to_l1_msgs.storage); - self.public_inputs.end.unencrypted_logs_hashes.storage = - sort_by_counter_asc(self.public_inputs.end.unencrypted_logs_hashes.storage); + self.public_inputs.end.contract_class_logs_hashes.storage = + sort_by_counter_asc(self.public_inputs.end.contract_class_logs_hashes.storage); self.public_inputs.end.public_call_requests.storage = sort_by_counter_desc(self.public_inputs.end.public_call_requests.storage); } @@ -237,11 +237,11 @@ impl PrivateKernelCircuitPublicInputsComposer { } } - let unencrypted_logs = private_call.unencrypted_logs_hashes; - for i in 0..unencrypted_logs.len() { - let log = unencrypted_logs[i]; + let contract_class_logs = private_call.contract_class_logs_hashes; + for i in 0..contract_class_logs.len() { + let log = contract_class_logs[i]; if !is_empty(log) { - self.public_inputs.end.unencrypted_logs_hashes.push(log.scope( + self.public_inputs.end.contract_class_logs_hashes.push(log.scope( private_call.call_context.contract_address, )); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr index c126b1ebf5b1..e6bd20cde906 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr @@ -78,8 +78,8 @@ impl Gas { metered_da_bytes += data.encrypted_log_preimages_length as u32; metered_l2_gas += data.encrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; - metered_da_bytes += data.unencrypted_log_preimages_length as u32; - metered_l2_gas += data.unencrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; + metered_da_bytes += data.contract_class_log_preimages_length as u32; + metered_l2_gas += data.contract_class_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; Gas::new(metered_da_bytes * DA_GAS_PER_BYTE, metered_l2_gas) + Gas::tx_overhead() } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr index 4c3df11c4a80..458a65a26f0e 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr @@ -10,7 +10,7 @@ use dep::types::{ log_hash::{NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, }, messaging::l2_to_l1_message::ScopedL2ToL1Message, - traits::is_empty, + traits::{is_empty, is_empty_array}, utils::arrays::assert_exposed_sorted_transformed_value_array, }; @@ -39,6 +39,10 @@ impl TailOutputValidator { fn validate_empty_values(self) { assert(is_empty(self.output.start_state), "start_state must be empty"); assert_eq(self.output.revert_code, 0, "revert_code must be empty"); + assert( + is_empty_array(self.output.end.unencrypted_logs_hashes), + "unencrypted logs in private must be empty", + ); } fn validate_propagated_values(self) { @@ -115,13 +119,12 @@ impl TailOutputValidator { |prev: ScopedL2ToL1Message, out: ScopedL2ToL1Message| out == prev.expose_to_public(), self.hints.sorted_l2_to_l1_msg_hints, ); - - // unencrypted_log_hashes + // contract_class_logs assert_exposed_sorted_transformed_value_array( - self.previous_kernel.end.unencrypted_logs_hashes, - self.output.end.unencrypted_logs_hashes, + self.previous_kernel.end.contract_class_logs_hashes, + self.output.end.contract_class_logs_hashes, |prev: ScopedLogHash, out: ScopedLogHash| out == prev.expose_to_public(), - self.hints.sorted_unencrypted_log_hash_hints, + self.hints.sorted_contract_class_log_hash_hints, ); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr index 459c68948b5c..73f199f7a747 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr @@ -1,15 +1,15 @@ use dep::types::{ abis::{kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, log_hash::ScopedLogHash}, - constants::{MAX_L2_TO_L1_MSGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX}, + constants::{MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX}, utils::arrays::{get_order_hints_asc, OrderHint, sort_by_counter_asc}, }; pub struct TailOutputHints { // L2 to l1 msgs. sorted_l2_to_l1_msg_hints: [OrderHint; MAX_L2_TO_L1_MSGS_PER_TX], - // Unencrypted log hashes. - sorted_unencrypted_log_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], - sorted_unencrypted_log_hash_hints: [OrderHint; MAX_UNENCRYPTED_LOGS_PER_TX], + // Contract class log hashes. + sorted_contract_class_log_hashes: [ScopedLogHash; MAX_CONTRACT_CLASS_LOGS_PER_TX], + sorted_contract_class_log_hash_hints: [OrderHint; MAX_CONTRACT_CLASS_LOGS_PER_TX], } pub unconstrained fn generate_tail_output_hints( @@ -18,15 +18,15 @@ pub unconstrained fn generate_tail_output_hints( // l2_to_l1_msgs let sorted_l2_to_l1_msg_hints = get_order_hints_asc(previous_kernel.end.l2_to_l1_msgs); - // unencrypted_logs - let sorted_unencrypted_log_hashes = - sort_by_counter_asc(previous_kernel.end.unencrypted_logs_hashes); - let sorted_unencrypted_log_hash_hints = - get_order_hints_asc(previous_kernel.end.unencrypted_logs_hashes); + // contract_class_logs + let sorted_contract_class_log_hashes = + sort_by_counter_asc(previous_kernel.end.contract_class_logs_hashes); + let sorted_contract_class_log_hash_hints = + get_order_hints_asc(previous_kernel.end.contract_class_logs_hashes); TailOutputHints { sorted_l2_to_l1_msg_hints, - sorted_unencrypted_log_hashes, - sorted_unencrypted_log_hash_hints, + sorted_contract_class_log_hashes, + sorted_contract_class_log_hash_hints, } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr index 54cd0bf3aa90..c12b75696b5c 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr @@ -37,10 +37,10 @@ fn meter_accumulated_data_gas_used(data: PrivateToPublicAccumulatedData) -> Gas metered_da_bytes += encrypted_log_preimages_length as u32; metered_l2_gas += encrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; - let unencrypted_log_preimages_length = - data.unencrypted_logs_hashes.fold(0, |len, l: ScopedLogHash| len + l.log_hash.length); - metered_da_bytes += unencrypted_log_preimages_length as u32; - metered_l2_gas += unencrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; + let contract_class_log_preimages_length = + data.contract_class_logs_hashes.fold(0, |len, l: ScopedLogHash| len + l.log_hash.length); + metered_da_bytes += contract_class_log_preimages_length as u32; + metered_l2_gas += contract_class_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; metered_l2_gas += array_length(data.public_call_requests) * FIXED_AVM_STARTUP_L2_GAS; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr index ad944b4cd0b0..5d723d0804db 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr @@ -73,15 +73,15 @@ pub unconstrained fn split_to_public( } } - let unencrypted_logs_hashes = data.unencrypted_logs_hashes; - for i in 0..unencrypted_logs_hashes.max_len() { - if i < unencrypted_logs_hashes.len() { - let unencrypted_log_hash = unencrypted_logs_hashes.get_unchecked(i); - let public_log_hash = unencrypted_log_hash.expose_to_public(); - if unencrypted_log_hash.counter() < min_revertible_side_effect_counter { - non_revertible_builder.unencrypted_logs_hashes.push(public_log_hash); + let contract_class_logs_hashes = data.contract_class_logs_hashes; + for i in 0..contract_class_logs_hashes.max_len() { + if i < contract_class_logs_hashes.len() { + let contract_class_log_hash = contract_class_logs_hashes.get_unchecked(i); + let public_log_hash = contract_class_log_hash.expose_to_public(); + if contract_class_log_hash.counter() < min_revertible_side_effect_counter { + non_revertible_builder.contract_class_logs_hashes.push(public_log_hash); } else { - revertible_builder.unencrypted_logs_hashes.push(public_log_hash); + revertible_builder.contract_class_logs_hashes.push(public_log_hash); } } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr index ddfde23c0249..ef1437dafc18 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr @@ -124,14 +124,14 @@ impl TailToPublicOutputValidator { hints.sorted_l2_to_l1_msg_hints, ); - // unencrypted_logs_hashes + // contract_class_logs_hashes assert_split_sorted_transformed_value_arrays_asc( - prev_data.unencrypted_logs_hashes, - prev_data.unencrypted_logs_hashes.map(|log: ScopedLogHash| log.expose_to_public()), + prev_data.contract_class_logs_hashes, + prev_data.contract_class_logs_hashes.map(|log: ScopedLogHash| log.expose_to_public()), split_counter, - output_non_revertible.unencrypted_logs_hashes, - output_revertible.unencrypted_logs_hashes, - hints.sorted_unencrypted_log_hash_hints, + output_non_revertible.contract_class_logs_hashes, + output_revertible.contract_class_logs_hashes, + hints.sorted_contract_class_log_hash_hints, ); // public_call_requests diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr index 0918eaa04b24..231c175a269c 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr @@ -1,14 +1,16 @@ use dep::types::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - constants::{MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX}, + constants::{ + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, + }, utils::arrays::{get_split_order_hints_asc, get_split_order_hints_desc, SplitOrderHints}, }; pub struct TailToPublicOutputHints { // L2 to l1 msgs. sorted_l2_to_l1_msg_hints: SplitOrderHints, - // Unencrypted log hashes. - sorted_unencrypted_log_hash_hints: SplitOrderHints, + // Contract class log hashes. + sorted_contract_class_log_hash_hints: SplitOrderHints, // Public call requests. sorted_public_call_request_hints: SplitOrderHints, } @@ -22,9 +24,11 @@ pub unconstrained fn generate_tail_to_public_output_hints( let sorted_l2_to_l1_msg_hints = get_split_order_hints_asc(previous_kernel.end.l2_to_l1_msgs, split_counter); - // unencrypted_logs - let sorted_unencrypted_log_hash_hints = - get_split_order_hints_asc(previous_kernel.end.unencrypted_logs_hashes, split_counter); + // contract_class_logs + let sorted_contract_class_log_hash_hints = get_split_order_hints_asc( + previous_kernel.end.contract_class_logs_hashes, + split_counter, + ); // public_call_requests let sorted_public_call_request_hints = @@ -32,7 +36,7 @@ pub unconstrained fn generate_tail_to_public_output_hints( TailToPublicOutputHints { sorted_l2_to_l1_msg_hints, - sorted_unencrypted_log_hash_hints, + sorted_contract_class_log_hash_hints, sorted_public_call_request_hints, } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index 02d68f077705..08eae183bd0b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -57,9 +57,10 @@ mod tests { use dep::types::{ abis::{ gas::Gas, kernel_circuit_public_inputs::KernelCircuitPublicInputs, - log_hash::ScopedLogHash, max_block_number::MaxBlockNumber, + max_block_number::MaxBlockNumber, }, address::{AztecAddress, EthAddress}, + messaging::l2_to_l1_message::ScopedL2ToL1Message, point::Point, tests::fixture_builder::FixtureBuilder, traits::is_empty, @@ -122,60 +123,57 @@ mod tests { // Logs for the previous call stack. let prev_encrypted_logs_hash = 80; let prev_encrypted_log_preimages_length = 13; - let prev_unencrypted_logs_hash = 956; - let prev_unencrypted_log_preimages_length = 24; + let prev_contract_class_logs_hash = 956; + let prev_contract_class_log_preimages_length = 24; builder.previous_kernel.add_masked_encrypted_log_hash( prev_encrypted_logs_hash, prev_encrypted_log_preimages_length, ); - builder.previous_kernel.add_unencrypted_log_hash( - prev_unencrypted_logs_hash, - prev_unencrypted_log_preimages_length, + builder.previous_kernel.add_contract_class_log_hash( + prev_contract_class_logs_hash, + prev_contract_class_log_preimages_length, ); // Logs for the current call stack. - let unencrypted_logs_hash = 26; - let unencrypted_log_preimages_length = 50; - builder.previous_kernel.add_unencrypted_log_hash( - unencrypted_logs_hash, - unencrypted_log_preimages_length, + let encrypted_logs_hash = 26; + let encrypted_log_preimages_length = 50; + builder.previous_kernel.add_masked_encrypted_log_hash( + encrypted_logs_hash, + encrypted_log_preimages_length, ); let public_inputs = builder.execute(); assert_eq( public_inputs.end.encrypted_log_preimages_length, - prev_encrypted_log_preimages_length, + prev_encrypted_log_preimages_length + encrypted_log_preimages_length, ); assert_eq( - public_inputs.end.unencrypted_log_preimages_length, - unencrypted_log_preimages_length + prev_unencrypted_log_preimages_length, + public_inputs.end.contract_class_log_preimages_length, + prev_contract_class_log_preimages_length, ); } #[test] - fn ordering_of_unencrypted_logs() { + fn ordering_of_msgs() { let mut builder = PrivateKernelTailInputsBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(2); + builder.previous_kernel.append_l2_to_l1_msgs(2); - // Reorder the logs - let original_logs = builder.previous_kernel.unencrypted_logs_hashes.storage; - let mut reversed_logs = [ScopedLogHash::empty(); 2]; - for i in 0..reversed_logs.len() { - reversed_logs[i] = builder.previous_kernel.unencrypted_logs_hashes.pop(); + // Reorder the msgs + let original_msgs = builder.previous_kernel.l2_to_l1_msgs.storage; + let mut reversed_msgs = [ScopedL2ToL1Message::empty(); 2]; + for i in 0..reversed_msgs.len() { + reversed_msgs[i] = builder.previous_kernel.l2_to_l1_msgs.pop(); } - builder.previous_kernel.unencrypted_logs_hashes.extend_from_array(reversed_logs); + builder.previous_kernel.l2_to_l1_msgs.extend_from_array(reversed_msgs); let public_inputs = builder.execute(); - let resulting_encrypted_logs = public_inputs.end.unencrypted_logs_hashes; + let resulting_msgs = public_inputs.end.l2_to_l1_msgs; assert_eq( - resulting_encrypted_logs, - original_logs.map(|mut log: ScopedLogHash| { - log.log_hash.counter = 0; - log - }), + resulting_msgs, + original_msgs.map(|mut msg: ScopedL2ToL1Message| msg.expose_to_public()), ); } @@ -277,10 +275,9 @@ mod tests { let mut builder = PrivateKernelTailInputsBuilder::new(); builder.previous_kernel.add_masked_encrypted_log_hash(42, 3); builder.previous_kernel.add_masked_encrypted_log_hash(42, 4); - builder.previous_kernel.add_unencrypted_log_hash(42, 5); + builder.previous_kernel.add_contract_class_log_hash(42, 12); builder.previous_kernel.end_setup(); builder.previous_kernel.add_masked_encrypted_log_hash(42, 6); - builder.previous_kernel.add_unencrypted_log_hash(42, 7); let public_inputs = builder.execute(); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index 1765f6f6254e..fdc7a788ce9e 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -326,14 +326,13 @@ mod tests { let mut builder = PrivateKernelTailToPublicInputsBuilder::new(); builder.previous_kernel.add_masked_encrypted_log_hash(42, 3); builder.previous_kernel.add_masked_encrypted_log_hash(42, 4); - builder.previous_kernel.add_unencrypted_log_hash(42, 5); + builder.previous_kernel.add_contract_class_log_hash(42, 12); builder.previous_kernel.end_setup(); builder.previous_kernel.add_masked_encrypted_log_hash(42, 6); - builder.previous_kernel.add_unencrypted_log_hash(42, 7); let public_inputs = builder.execute(); - let num_log_bytes = 3 + 4 + 5 + 6 + 7; + let num_log_bytes = 3 + 4 + 12 + 6; let da_gas = (1 * DA_BYTES_PER_FIELD + num_log_bytes) * DA_GAS_PER_BYTE; let l2_gas = FIXED_AVM_STARTUP_L2_GAS + 1 * L2_GAS_PER_NULLIFIER diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_arrays.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_arrays.nr index 4e376e0f6356..10daa7a993a3 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_arrays.nr @@ -109,13 +109,3 @@ fn validate_arrays_malformed_encrypted_logs_hashes_fails() { builder.validate(); } - -#[test(should_fail_with = "invalid array")] -fn validate_arrays_malformed_unencrypted_logs_hashes_fails() { - let mut builder = PrivateCallDataValidatorBuilder::new(); - - builder.private_call.append_unencrypted_log_hashes(1); - unshift_empty_item(&mut builder.private_call.unencrypted_logs_hashes); - - builder.validate(); -} diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_call.nr index 22504557f461..37b5c400c238 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/validate_call.nr @@ -57,11 +57,22 @@ fn validate_call_is_static_creating_encrypted_logs_hashes_fails() { builder.validate(); } -#[test(should_fail_with = "unencrypted_logs_hashes must be empty for static calls")] -fn validate_call_is_static_creating_unencrypted_logs_hashes_fails() { +#[test(should_fail_with = "contract_class_logs_hashes must be empty for static calls")] +fn validate_call_is_static_creating_contract_class_logs_hashes_fails() { let mut builder = PrivateCallDataValidatorBuilder::new().is_static_call(); - builder.private_call.append_unencrypted_log_hashes(1); + builder.private_call.add_contract_class_log_hash(1, 2); + + builder.validate(); +} + +#[test(should_fail_with = "only the class registerer may emit contract class logs")] +fn validate_call_is_from_class_registerer_fails() { + let mut builder = PrivateCallDataValidatorBuilder::new(); + + builder.private_call.add_contract_class_log_hash(1, 2); + // set the contract address to be some msg sender (!= REGISTERER_CONTRACT_ADDRESS) + builder.private_call.contract_address = builder.private_call.msg_sender; builder.validate(); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_previous_kernel.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_previous_kernel.nr index dbc0b8e954ce..b7bb2d4ea67d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_previous_kernel.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_previous_kernel.nr @@ -262,25 +262,24 @@ fn validate_propagated_from_previous_kernel_encrypted_log_hashes_less_than_fails } /** - * unencrypted_log_hashes + * contract_class_log_hashes */ #[test] -fn validate_propagated_from_previous_kernel_unencrypted_log_hashes_succeeds() { +fn validate_propagated_from_previous_kernel_contract_class_log_hashes_succeeds() { let mut builder = PrivateKernelCircuitOutputValidatorBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(2); - builder.output.append_unencrypted_log_hashes(2); + builder.previous_kernel.add_contract_class_log_hash(2, 1); + builder.output.add_contract_class_log_hash(2, 1); builder.validate_as_inner_call(); } -#[test(should_fail_with = "source item does not prepend to dest")] -fn validate_propagated_from_previous_kernel_unencrypted_log_hashes_less_than_fails() { +#[test(should_fail_with = "output should be appended with empty items")] +fn validate_propagated_from_previous_kernel_contract_class_log_hashes_less_than_fails() { let mut builder = PrivateKernelCircuitOutputValidatorBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(2); // Propagate 1 less item to the output. - builder.output.append_unencrypted_log_hashes(1); + builder.output.add_contract_class_log_hash(2, 1); builder.validate_as_inner_call(); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_private_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_private_call.nr index 897267ba89f2..9028ded0bb6b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_private_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/validate_propagated_from_private_call.nr @@ -369,25 +369,24 @@ fn validate_propagated_from_private_call_encrypted_log_hashes_output_one_more_fa } /** - * unencrypted_log_hashes + * contract_class_log_hashes */ #[test] -fn validate_propagated_from_private_call_unencrypted_log_hashes_succeeds() { +fn validate_propagated_from_private_call_contract_class_log_hashes_succeeds() { let mut builder = PrivateKernelCircuitOutputValidatorBuilder::new(); - builder.private_call.append_unencrypted_log_hashes(2); - builder.output.append_unencrypted_log_hashes(2); + builder.private_call.add_contract_class_log_hash(2, 1); + builder.output.add_contract_class_log_hash(2, 1); builder.validate_as_inner_call(); } #[test(should_fail_with = "output should be appended with empty items")] -fn validate_propagated_from_private_call_unencrypted_log_hashes_output_one_more_fails() { +fn validate_propagated_from_private_call_contract_class_log_hashes_output_one_more_fails() { let mut builder = PrivateKernelCircuitOutputValidatorBuilder::new(); - builder.private_call.append_unencrypted_log_hashes(2); // Propagate 1 more item to the output. - builder.output.append_unencrypted_log_hashes(3); + builder.output.add_contract_class_log_hash(2, 1); builder.validate_as_inner_call(); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr index d11b387c074b..5a2b04052f75 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr @@ -225,20 +225,15 @@ fn new_from_previous_kernel_with_private_call_encrypted_log_hashes_succeeds() { } #[test] -fn new_from_previous_kernel_with_private_call_unencrypted_log_hashes_succeeds() { +fn new_from_previous_kernel_with_private_call_contract_class_log_hashes_succeeds() { let mut builder = PrivateKernelCircuitPublicInputsComposerBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(2); - let prev = builder.previous_kernel.unencrypted_logs_hashes.storage; - builder.private_call.append_unencrypted_log_hashes(2); - let curr = builder.private_call.unencrypted_logs_hashes.storage; + builder.private_call.add_contract_class_log_hash(2, 200); + let curr = builder.private_call.contract_class_logs_hashes.storage; let output = builder.compose_from_previous_kernel(); - assert_array_eq( - output.end.unencrypted_logs_hashes, - [prev[0], prev[1], curr[0], curr[1]], - ); + assert_array_eq(output.end.contract_class_logs_hashes, [curr[0]]); } #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr index 07094557fd32..0206f75d3892 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr @@ -161,15 +161,15 @@ fn propagate_from_private_call_encrypted_log_hashes_succeeds() { } #[test] -fn propagate_from_private_call_unencrypted_log_hashes_succeeds() { +fn propagate_from_private_call_contract_class_log_hashes_succeeds() { let mut builder = PrivateKernelCircuitPublicInputsComposerBuilder::new(); - builder.private_call.append_unencrypted_log_hashes(2); - let res = builder.private_call.unencrypted_logs_hashes.storage; + builder.private_call.add_contract_class_log_hash(2, 200); + let res = builder.private_call.contract_class_logs_hashes.storage; let output = builder.compose_from_tx_request(); - assert_array_eq(output.end.unencrypted_logs_hashes, [res[0], res[1]]); + assert_array_eq(output.end.contract_class_logs_hashes, [res[0]]); } #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr index 9759093dafac..82fff15a88dd 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr @@ -58,10 +58,6 @@ fn meter_gas_used_everything_succeeds() { metered_da_bytes += 6; computed_l2_gas += 6 * L2_GAS_PER_LOG_BYTE; - builder.add_unencrypted_log_hash(3001, 51); - metered_da_bytes += 51; - computed_l2_gas += 51 * L2_GAS_PER_LOG_BYTE; - let data = builder.to_combined_accumulated_data(); let gas = meter_gas_used(data); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_empty_values.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_empty_values.nr index 0ba030cc9141..2e4be7bed2f0 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_empty_values.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_empty_values.nr @@ -24,3 +24,12 @@ fn validate_empty_values_non_empty_revert_code_fails() { builder.validate(); } +#[test(should_fail_with = "unencrypted logs in private must be empty")] +fn validate_empty_values_non_empty_unencrypted_log_fails() { + let mut builder = TailOutputValidatorBuilder::new(); + + builder.output.add_unencrypted_log_hash(1, 2); + + builder.validate(); +} + diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_propagated_sorted_values.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_propagated_sorted_values.nr index e927ed83e6a1..68924be6824d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_propagated_sorted_values.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/validate_propagated_sorted_values.nr @@ -38,40 +38,26 @@ fn validate_propagated_sorted_values_l2_to_l1_msgs_mismatch_hash_fails() { } /** - * unencrypted_log_hashes + * contract_class_log_hashes */ #[test] -fn validate_propagated_sorted_values_unencrypted_log_hashes_succeeds() { +fn validate_propagated_sorted_values_contract_class_log_hashes_succeeds() { let mut builder = TailOutputValidatorBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(3); - builder.output.append_unencrypted_log_hashes(3); - builder.output.hash_unencrypted_log_hashes(); - - builder.validate(); -} - -#[test] -fn validate_propagated_sorted_values_unencrypted_log_hashes_unordered_succeeds() { - let mut builder = TailOutputValidatorBuilder::new(); - - builder.previous_kernel.append_unencrypted_log_hashes(3); - // Swap the items at index 0 and 2. - swap_items(&mut builder.previous_kernel.unencrypted_logs_hashes, 0, 2); - builder.output.append_unencrypted_log_hashes(3); - builder.output.hash_unencrypted_log_hashes(); + builder.previous_kernel.add_contract_class_log_hash(3, 2); + builder.output.add_contract_class_log_hash(3, 2); builder.validate(); } #[test(should_fail_with = "incorrect transformed value")] -fn validate_propagated_sorted_values_unencrypted_log_hashes_wrong_order_fails() { +fn validate_propagated_sorted_values_contract_class_log_hashes_mismatch_fails() { let mut builder = TailOutputValidatorBuilder::new(); - builder.previous_kernel.append_unencrypted_log_hashes(3); - builder.output.append_unencrypted_log_hashes(3); - // Swap the items in the output, making them out of order - swap_items(&mut builder.output.unencrypted_logs_hashes, 0, 2); + builder.previous_kernel.add_contract_class_log_hash(3, 2); + builder.output.add_contract_class_log_hash(3, 2); + // Tweak the content in the output. + builder.output.contract_class_logs_hashes.storage[0].log_hash.value += 1; builder.validate(); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr index d6352017f30b..1257df167032 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr @@ -52,6 +52,7 @@ fn meter_gas_used_everything_succeeds() { non_revertible_builder.append_l2_to_l1_msgs(0); non_revertible_builder.add_note_encrypted_log_hash(1001, 12, 0); non_revertible_builder.add_encrypted_log_hash(2001, 2); + non_revertible_builder.add_contract_class_log_hash(3001, 51); non_revertible_builder.append_public_call_requests(1); revertible_builder.append_note_hashes(1); @@ -60,7 +61,6 @@ fn meter_gas_used_everything_succeeds() { revertible_builder.add_note_encrypted_log_hash(1002, 8, 0); revertible_builder.add_note_encrypted_log_hash(1003, 20, 0); revertible_builder.add_encrypted_log_hash(2002, 6); - revertible_builder.add_unencrypted_log_hash(3001, 51); revertible_builder.append_public_call_requests(1); let non_revertible_data = non_revertible_builder.to_private_to_public_accumulated_data(); @@ -82,7 +82,7 @@ fn meter_gas_used_everything_succeeds() { + 20 // note_encrypted_log_hash + 2 + 6 // encrypted_log_hash - + 51; // unencrypted_log_hash + + 51; // contract_class_log_hash let computed_da_gas = (total_num_side_effects * DA_BYTES_PER_FIELD + total_log_length) * DA_GAS_PER_BYTE; let computed_l2_gas = 4 * L2_GAS_PER_NOTE_HASH diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/split_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/split_to_public.nr index 5faddeca1dcb..6617e5abbfab 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/split_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/split_to_public.nr @@ -11,7 +11,7 @@ fn split_to_public_succeeds() { builder.append_l2_to_l1_msgs(1); builder.append_note_encrypted_log_hashes(3); builder.append_encrypted_log_hashes(2); - builder.append_unencrypted_log_hashes(1); + builder.add_contract_class_log_hash(2, 200); builder.append_public_call_requests(1); builder.end_setup(); // Revertibles. @@ -20,7 +20,6 @@ fn split_to_public_succeeds() { builder.append_l2_to_l1_msgs(1); builder.append_note_encrypted_log_hashes(1); builder.append_encrypted_log_hashes(2); - builder.append_unencrypted_log_hashes(1); builder.append_public_call_requests(2); let combined_data = builder.to_private_to_public_accumulated_data(); @@ -65,10 +64,10 @@ fn split_to_public_succeeds() { ); assert_array_eq(revertible.encrypted_logs_hashes, [expected[2], expected[3]]); - // unencrypted_logs_hashes - let expected = combined_data.unencrypted_logs_hashes; - assert_array_eq(non_revertible.unencrypted_logs_hashes, [expected[0]]); - assert_array_eq(revertible.unencrypted_logs_hashes, [expected[1]]); + // contract_class_logs_hashes + let expected = combined_data.contract_class_logs_hashes; + assert_array_eq(non_revertible.contract_class_logs_hashes, [expected[0]]); + assert_array_eq(revertible.contract_class_logs_hashes, []); // public_call_requests let call_requests = combined_data.public_call_requests; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr index a96d4da43c3a..ea5e7c6362db 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr @@ -27,8 +27,7 @@ fn tail_to_public_output_composer_succeeds() { builder.previous_kernel.add_masked_encrypted_log_hash(2001, 2); - builder.previous_kernel.add_unencrypted_log_hash(3001, 51); - builder.previous_kernel.add_unencrypted_log_hash(3002, 9); + builder.previous_kernel.add_contract_class_log_hash(3002, 9); builder.previous_kernel.append_public_call_requests(2); @@ -48,8 +47,6 @@ fn tail_to_public_output_composer_succeeds() { builder.previous_kernel.add_masked_encrypted_log_hash(2002, 6); builder.previous_kernel.add_masked_encrypted_log_hash(2003, 24); - builder.previous_kernel.add_unencrypted_log_hash(3002, 4); - builder.previous_kernel.append_public_call_requests(3); // Get ordered items before shuffling for verifying with the output later. @@ -57,7 +54,6 @@ fn tail_to_public_output_composer_succeeds() { // Shuffle ordered items. swap_items(&mut builder.previous_kernel.l2_to_l1_msgs, 0, 1); - swap_items(&mut builder.previous_kernel.unencrypted_logs_hashes, 0, 2); swap_items(&mut builder.previous_kernel.public_call_requests, 1, 2); // Output. @@ -115,15 +111,11 @@ fn tail_to_public_output_composer_succeeds() { [log_hashes[1], log_hashes[2]], ); - // unencrypted_logs_hashes - let log_hashes = data.unencrypted_logs_hashes; - assert_array_eq( - output.non_revertible_accumulated_data.unencrypted_logs_hashes, - [log_hashes[0], log_hashes[1]], - ); + // contract_class_logs_hashes + let log_hashes = data.contract_class_logs_hashes; assert_array_eq( - output.revertible_accumulated_data.unencrypted_logs_hashes, - [log_hashes[2]], + output.non_revertible_accumulated_data.contract_class_logs_hashes, + [log_hashes[0]], ); // public_call_requests @@ -146,8 +138,7 @@ fn tail_to_public_output_composer_succeeds() { let mut total_log_length = 12 + 8 // note_encrypted_log_hash + 2 // encrypted_log_hash - + 51 - + 9; // unencrypted_log_hash + + 9; // contract_class_log_hash // Gas: revertible { num_note_hashes += 2; @@ -156,8 +147,7 @@ fn tail_to_public_output_composer_succeeds() { num_msgs += 1; total_log_length += 20 // note_encrypted_log_hash + 6 - + 24 // encrypted_log_hash - + 4; // unencrypted_log_hash + + 24; // encrypted_log_hash } let num_da_effects = num_note_hashes + num_nullifiers + num_msgs; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr index a418eb90428f..8c9c4ca3dc08 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr @@ -7,7 +7,7 @@ use dep::types::{ public_data_update_request::PublicDataUpdateRequest, public_data_write::PublicDataWrite, }, - constants::MAX_NOTE_HASHES_PER_TX, + constants::{MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX}, hash::silo_note_hash, utils::arrays::{array_merge, dedupe_array, sort_by_counter_asc}, }; @@ -79,9 +79,11 @@ pub unconstrained fn combine_data( note_encrypted_logs_hashes, encrypted_logs_hashes, unencrypted_logs_hashes, + contract_class_logs_hashes: [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], note_encrypted_log_preimages_length, encrypted_log_preimages_length, unencrypted_log_preimages_length, + contract_class_log_preimages_length: 0, public_data_writes, } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr index 0f31631c0c3b..4e3fa619a5a1 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr @@ -13,7 +13,6 @@ use dep::types::{ abis::{ accumulated_data::CombinedAccumulatedData, combined_constant_data::CombinedConstantData, - gas::Gas, log_hash::{LogHash, ScopedLogHash}, }, constants::{ @@ -67,10 +66,20 @@ impl PublicBaseRollupInputs { from_private.revertible_accumulated_data.encrypted_logs_hashes, ) }; + let contract_class_logs_hashes = if reverted { + from_private.non_revertible_accumulated_data.contract_class_logs_hashes + } else { + array_merge( + from_private.non_revertible_accumulated_data.contract_class_logs_hashes, + from_private.revertible_accumulated_data.contract_class_logs_hashes, + ) + }; let note_encrypted_log_preimages_length = note_encrypted_logs_hashes.fold(0, |len, l: LogHash| len + l.length); let encrypted_log_preimages_length = encrypted_logs_hashes.fold(0, |len, l: ScopedLogHash| len + l.log_hash.length); + let contract_class_log_preimages_length = + contract_class_logs_hashes.fold(0, |len, l: ScopedLogHash| len + l.log_hash.length); let unencrypted_log_preimages_length = from_public .accumulated_data .unencrypted_logs_hashes @@ -82,9 +91,11 @@ impl PublicBaseRollupInputs { note_encrypted_logs_hashes, encrypted_logs_hashes, unencrypted_logs_hashes: from_public.accumulated_data.unencrypted_logs_hashes, + contract_class_logs_hashes, note_encrypted_log_preimages_length, encrypted_log_preimages_length, unencrypted_log_preimages_length, + contract_class_log_preimages_length, public_data_writes: from_public.accumulated_data.public_data_writes, }; @@ -105,7 +116,7 @@ impl PublicBaseRollupInputs { end, start_state, revert_code, - gas_used: Gas::empty(), // gas_used is not used in rollup circuits. + gas_used: from_public.end_gas_used, fee_payer: from_private.fee_payer, } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 8f9fcbe2c8b3..7dbe6021d88e 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -12,13 +12,12 @@ use dep::types::{ public_data_write::PublicDataWrite, }, constants::{ - AZTEC_MAX_EPOCH_DURATION, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, - MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + AZTEC_MAX_EPOCH_DURATION, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, + MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, }, hash::{ - accumulate_sha256, compute_tx_logs_hash, compute_tx_note_logs_hash, silo_encrypted_log_hash, - silo_unencrypted_log_hash, + accumulate_sha256, compute_tx_logs_hash, silo_encrypted_log_hash, silo_unencrypted_log_hash, }, merkle_tree::VariableMerkleTree, traits::is_empty, @@ -200,8 +199,8 @@ pub fn compute_txs_effects_hash(previous_rollup_data: [PreviousRollupData; 2]) - ]) } -fn silo_and_hash_unencrypted_logs( - unencrypted_logs_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], +fn silo_and_hash_unencrypted_logs( + unencrypted_logs_hashes: [ScopedLogHash; N], ) -> Field { let siloed_logs = unencrypted_logs_hashes.map(|log: ScopedLogHash| { LogHash { @@ -235,20 +234,22 @@ fn silo_and_hash_encrypted_logs( // MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX public data update requests -> MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 fields // __ // 1 note encrypted logs length --> 1 field | -// 1 encrypted logs length --> 1 field | -> 3 types of logs - 3 fields for its lengths -// 1 unencrypted logs length --> 1 field __| -// __ -// 1 note encrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! | -// 1 encrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! | -> 3 types of logs - 3 fields for its hashes -// 1 unencrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! __| +// 1 encrypted logs length --> 1 field | -> 4 types of logs - 4 fields for its lengths +// 1 unencrypted logs length --> 1 field | +// 1 contract class logs length --> 1 field __| +// __ +// 1 note encrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! | +// 1 encrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! | -> 4 types of logs - 4 fields for its hashes +// 1 unencrypted logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! | +// 1 contract class logs hash --> 1 sha256 hash -> 31 bytes -> 1 fields | Beware when populating bytes that we fill (prepend) to 32! __| global TX_EFFECTS_HASH_INPUT_FIELDS = 1 + 1 + MAX_NOTE_HASHES_PER_TX + MAX_NULLIFIERS_PER_TX + 1 + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 - + 3 - + 3; + + 4 + + 4; // Computes the tx effects hash for a base rollup (a single transaction) pub fn compute_tx_effects_hash( @@ -270,9 +271,12 @@ pub fn compute_tx_effects_hash( let note_logs_length = combined.note_encrypted_log_preimages_length; let encrypted_logs_length = combined.encrypted_log_preimages_length; let unencrypted_logs_length = combined.unencrypted_log_preimages_length; - let note_encrypted_logs_hash = compute_tx_note_logs_hash(combined.note_encrypted_logs_hashes); + let contract_class_logs_length = combined.contract_class_log_preimages_length; + let note_encrypted_logs_hash = compute_tx_logs_hash(combined.note_encrypted_logs_hashes); let encrypted_logs_hash = silo_and_hash_encrypted_logs(combined.encrypted_logs_hashes); let unencrypted_logs_hash = silo_and_hash_unencrypted_logs(combined.unencrypted_logs_hashes); + let contract_class_logs_hash = + silo_and_hash_unencrypted_logs(combined.contract_class_logs_hashes); let mut offset = 0; @@ -320,6 +324,10 @@ pub fn compute_tx_effects_hash( tx_effects_hash_input[offset] = unencrypted_logs_length; offset += 1; + // CONTRACT CLASS LOGS LENGTH + tx_effects_hash_input[offset] = contract_class_logs_length; + offset += 1; + // NOTE ENCRYPTED LOGS HASH tx_effects_hash_input[offset] = note_encrypted_logs_hash; offset += 1; @@ -332,6 +340,10 @@ pub fn compute_tx_effects_hash( tx_effects_hash_input[offset] = unencrypted_logs_hash; offset += 1; + // CONTRACT CLASS LOGS HASH + tx_effects_hash_input[offset] = contract_class_logs_hash; + offset += 1; + assert_eq(offset, TX_EFFECTS_HASH_INPUT_FIELDS); // Sanity check let mut hash_input_flattened = [0; TX_EFFECTS_HASH_INPUT_FIELDS * 32]; for offset in 0..TX_EFFECTS_HASH_INPUT_FIELDS { @@ -367,8 +379,8 @@ fn consistent_TX_EFFECTS_HASH_INPUT_FIELDS() { + MAX_NULLIFIERS_PER_TX + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + 1 // out hash - + 3 // logs lengths - + 3; // logs hashes + + 4 // logs lengths + + 4; // logs hashes assert( TX_EFFECTS_HASH_INPUT_FIELDS == expected_size, "tx effects hash input size is incorrect", diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr index ae51db5c9d89..440dbcfa3cb8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr @@ -1,9 +1,9 @@ use crate::{ abis::{log_hash::{LogHash, ScopedLogHash}, public_data_write::PublicDataWrite}, constants::{ - COMBINED_ACCUMULATED_DATA_LENGTH, MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + COMBINED_ACCUMULATED_DATA_LENGTH, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::{Deserialize, Empty, Serialize}, @@ -18,12 +18,14 @@ pub struct CombinedAccumulatedData { pub note_encrypted_logs_hashes: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX], pub encrypted_logs_hashes: [ScopedLogHash; MAX_ENCRYPTED_LOGS_PER_TX], pub unencrypted_logs_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], + pub contract_class_logs_hashes: [ScopedLogHash; MAX_CONTRACT_CLASS_LOGS_PER_TX], // Here so that the gas cost of this request can be measured by circuits, without actually needing to feed in the // variable-length data. pub note_encrypted_log_preimages_length: Field, pub encrypted_log_preimages_length: Field, pub unencrypted_log_preimages_length: Field, + pub contract_class_log_preimages_length: Field, pub public_data_writes: [PublicDataWrite; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], } @@ -37,9 +39,11 @@ impl Empty for CombinedAccumulatedData { note_encrypted_logs_hashes: [LogHash::empty(); MAX_NOTE_ENCRYPTED_LOGS_PER_TX], encrypted_logs_hashes: [ScopedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_TX], unencrypted_logs_hashes: [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], + contract_class_logs_hashes: [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], note_encrypted_log_preimages_length: 0, encrypted_log_preimages_length: 0, unencrypted_log_preimages_length: 0, + contract_class_log_preimages_length: 0, public_data_writes: [PublicDataWrite::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], } } @@ -63,9 +67,13 @@ impl Serialize for CombinedAccumulatedData { for i in 0..self.unencrypted_logs_hashes.len() { fields.extend_from_array(self.unencrypted_logs_hashes[i].serialize()); } + for i in 0..self.contract_class_logs_hashes.len() { + fields.extend_from_array(self.contract_class_logs_hashes[i].serialize()); + } fields.push(self.note_encrypted_log_preimages_length); fields.push(self.encrypted_log_preimages_length); fields.push(self.unencrypted_log_preimages_length); + fields.push(self.contract_class_log_preimages_length); for i in 0..MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX { fields.extend_from_array(self.public_data_writes[i].serialize()); @@ -100,9 +108,14 @@ impl Deserialize for CombinedAccumulatedData { ScopedLogHash::deserialize, [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], ), + contract_class_logs_hashes: reader.read_struct_array( + ScopedLogHash::deserialize, + [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], + ), note_encrypted_log_preimages_length: reader.read(), encrypted_log_preimages_length: reader.read(), unencrypted_log_preimages_length: reader.read(), + contract_class_log_preimages_length: reader.read(), public_data_writes: reader.read_struct_array( PublicDataWrite::deserialize, [PublicDataWrite::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], @@ -121,12 +134,17 @@ impl Eq for CombinedAccumulatedData { & (self.note_encrypted_logs_hashes == other.note_encrypted_logs_hashes) & (self.encrypted_logs_hashes == other.encrypted_logs_hashes) & (self.unencrypted_logs_hashes == other.unencrypted_logs_hashes) + & (self.contract_class_logs_hashes == other.contract_class_logs_hashes) & ( self.note_encrypted_log_preimages_length == other.note_encrypted_log_preimages_length ) & (self.encrypted_log_preimages_length == other.encrypted_log_preimages_length) & (self.unencrypted_log_preimages_length == other.unencrypted_log_preimages_length) + & ( + self.contract_class_log_preimages_length + == other.contract_class_log_preimages_length + ) & (self.public_data_writes == other.public_data_writes) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr index 79212470e6b1..2cbe86491a7b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr @@ -12,10 +12,9 @@ use crate::{ utils::reader::Reader, }; use crate::constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, - PRIVATE_ACCUMULATED_DATA_LENGTH, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, PRIVATE_ACCUMULATED_DATA_LENGTH, }; pub struct PrivateAccumulatedData { @@ -25,7 +24,7 @@ pub struct PrivateAccumulatedData { pub note_encrypted_logs_hashes: [NoteLogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX], pub encrypted_logs_hashes: [ScopedEncryptedLogHash; MAX_ENCRYPTED_LOGS_PER_TX], - pub unencrypted_logs_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], + pub contract_class_logs_hashes: [ScopedLogHash; MAX_CONTRACT_CLASS_LOGS_PER_TX], pub public_call_requests: [Counted; MAX_ENQUEUED_CALLS_PER_TX], pub private_call_stack: [PrivateCallRequest; MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX], @@ -55,8 +54,8 @@ impl Serialize for PrivateAccumulatedData { fields.extend_from_array(self.encrypted_logs_hashes[i].serialize()); } - for i in 0..MAX_UNENCRYPTED_LOGS_PER_TX { - fields.extend_from_array(self.unencrypted_logs_hashes[i].serialize()); + for i in 0..MAX_CONTRACT_CLASS_LOGS_PER_TX { + fields.extend_from_array(self.contract_class_logs_hashes[i].serialize()); } for i in 0..MAX_ENQUEUED_CALLS_PER_TX { @@ -98,9 +97,9 @@ impl Deserialize for PrivateAccumulatedData { ScopedEncryptedLogHash::deserialize, [ScopedEncryptedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_TX], ), - unencrypted_logs_hashes: reader.read_struct_array( + contract_class_logs_hashes: reader.read_struct_array( ScopedLogHash::deserialize, - [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], + [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], ), public_call_requests: reader.read_struct_array( Counted::deserialize, @@ -123,7 +122,7 @@ impl Eq for PrivateAccumulatedData { & (self.l2_to_l1_msgs == other.l2_to_l1_msgs) & (self.note_encrypted_logs_hashes == other.note_encrypted_logs_hashes) & (self.encrypted_logs_hashes == other.encrypted_logs_hashes) - & (self.unencrypted_logs_hashes == other.unencrypted_logs_hashes) + & (self.contract_class_logs_hashes == other.contract_class_logs_hashes) & (self.public_call_requests == other.public_call_requests) & (self.private_call_stack == other.private_call_stack) } @@ -137,7 +136,7 @@ impl Empty for PrivateAccumulatedData { l2_to_l1_msgs: [ScopedL2ToL1Message::empty(); MAX_L2_TO_L1_MSGS_PER_TX], note_encrypted_logs_hashes: [NoteLogHash::empty(); MAX_NOTE_ENCRYPTED_LOGS_PER_TX], encrypted_logs_hashes: [ScopedEncryptedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_TX], - unencrypted_logs_hashes: [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], + contract_class_logs_hashes: [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], public_call_requests: [Counted::empty(); MAX_ENQUEUED_CALLS_PER_TX], private_call_stack: [PrivateCallRequest::empty(); MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX], } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr index b6f56128de73..c40714138007 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr @@ -9,9 +9,9 @@ use crate::{ side_effect::Counted, }, constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::Empty, @@ -24,7 +24,7 @@ pub struct PrivateAccumulatedDataBuilder { pub note_encrypted_logs_hashes: BoundedVec, pub encrypted_logs_hashes: BoundedVec, - pub unencrypted_logs_hashes: BoundedVec, + pub contract_class_logs_hashes: BoundedVec, pub public_call_requests: BoundedVec, MAX_ENQUEUED_CALLS_PER_TX>, pub private_call_stack: BoundedVec, @@ -38,7 +38,7 @@ impl PrivateAccumulatedDataBuilder { l2_to_l1_msgs: self.l2_to_l1_msgs.storage(), note_encrypted_logs_hashes: self.note_encrypted_logs_hashes.storage(), encrypted_logs_hashes: self.encrypted_logs_hashes.storage(), - unencrypted_logs_hashes: self.unencrypted_logs_hashes.storage(), + contract_class_logs_hashes: self.contract_class_logs_hashes.storage(), public_call_requests: self.public_call_requests.storage(), private_call_stack: self.private_call_stack.storage(), } @@ -53,7 +53,7 @@ impl Empty for PrivateAccumulatedDataBuilder { l2_to_l1_msgs: BoundedVec::new(), note_encrypted_logs_hashes: BoundedVec::new(), encrypted_logs_hashes: BoundedVec::new(), - unencrypted_logs_hashes: BoundedVec::new(), + contract_class_logs_hashes: BoundedVec::new(), public_call_requests: BoundedVec::new(), private_call_stack: BoundedVec::new(), } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data.nr index ee7ce56dbea6..9b80a20cf364 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data.nr @@ -5,9 +5,9 @@ use crate::{ utils::reader::Reader, }; use crate::constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH, }; pub struct PrivateToPublicAccumulatedData { @@ -16,7 +16,7 @@ pub struct PrivateToPublicAccumulatedData { pub l2_to_l1_msgs: [ScopedL2ToL1Message; MAX_L2_TO_L1_MSGS_PER_TX], pub note_encrypted_logs_hashes: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX], pub encrypted_logs_hashes: [ScopedLogHash; MAX_ENCRYPTED_LOGS_PER_TX], - pub unencrypted_logs_hashes: [ScopedLogHash; MAX_UNENCRYPTED_LOGS_PER_TX], + pub contract_class_logs_hashes: [ScopedLogHash; MAX_CONTRACT_CLASS_LOGS_PER_TX], pub public_call_requests: [PublicCallRequest; MAX_ENQUEUED_CALLS_PER_TX], } @@ -28,7 +28,7 @@ impl Empty for PrivateToPublicAccumulatedData { l2_to_l1_msgs: [ScopedL2ToL1Message::empty(); MAX_L2_TO_L1_MSGS_PER_TX], note_encrypted_logs_hashes: [LogHash::empty(); MAX_NOTE_ENCRYPTED_LOGS_PER_TX], encrypted_logs_hashes: [ScopedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_TX], - unencrypted_logs_hashes: [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], + contract_class_logs_hashes: [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], public_call_requests: [PublicCallRequest::empty(); MAX_ENQUEUED_CALLS_PER_TX], } } @@ -41,7 +41,7 @@ impl Eq for PrivateToPublicAccumulatedData { & (self.l2_to_l1_msgs == other.l2_to_l1_msgs) & (self.note_encrypted_logs_hashes == other.note_encrypted_logs_hashes) & (self.encrypted_logs_hashes == other.encrypted_logs_hashes) - & (self.unencrypted_logs_hashes == other.unencrypted_logs_hashes) + & (self.contract_class_logs_hashes == other.contract_class_logs_hashes) & (self.public_call_requests == other.public_call_requests) } } @@ -62,8 +62,8 @@ impl Serialize for PrivateToPublicAcc for i in 0..self.encrypted_logs_hashes.len() { fields.extend_from_array(self.encrypted_logs_hashes[i].serialize()); } - for i in 0..self.unencrypted_logs_hashes.len() { - fields.extend_from_array(self.unencrypted_logs_hashes[i].serialize()); + for i in 0..self.contract_class_logs_hashes.len() { + fields.extend_from_array(self.contract_class_logs_hashes[i].serialize()); } for i in 0..self.public_call_requests.len() { fields.extend_from_array(self.public_call_requests[i].serialize()); @@ -96,9 +96,9 @@ impl Deserialize for PrivateToPublicA ScopedLogHash::deserialize, [ScopedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_TX], ), - unencrypted_logs_hashes: reader.read_struct_array( + contract_class_logs_hashes: reader.read_struct_array( ScopedLogHash::deserialize, - [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX], + [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX], ), public_call_requests: reader.read_struct_array( PublicCallRequest::deserialize, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data_builder.nr index 5f2567d999db..18090601cd5a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_to_public_accumulated_data_builder.nr @@ -5,9 +5,9 @@ use crate::{ public_call_request::PublicCallRequest, }, constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::Empty, @@ -20,7 +20,7 @@ pub struct PrivateToPublicAccumulatedDataBuilder { l2_to_l1_msgs: BoundedVec, note_encrypted_logs_hashes: BoundedVec, encrypted_logs_hashes: BoundedVec, - unencrypted_logs_hashes: BoundedVec, + contract_class_logs_hashes: BoundedVec, public_call_requests: BoundedVec, } @@ -32,7 +32,7 @@ impl PrivateToPublicAccumulatedDataBuilder { l2_to_l1_msgs: array_to_bounded_vec(data.l2_to_l1_msgs), note_encrypted_logs_hashes: array_to_bounded_vec(data.note_encrypted_logs_hashes), encrypted_logs_hashes: array_to_bounded_vec(data.encrypted_logs_hashes), - unencrypted_logs_hashes: array_to_bounded_vec(data.unencrypted_logs_hashes), + contract_class_logs_hashes: array_to_bounded_vec(data.contract_class_logs_hashes), public_call_requests: array_to_bounded_vec(data.public_call_requests), } } @@ -44,7 +44,7 @@ impl PrivateToPublicAccumulatedDataBuilder { l2_to_l1_msgs: self.l2_to_l1_msgs.storage(), note_encrypted_logs_hashes: self.note_encrypted_logs_hashes.storage(), encrypted_logs_hashes: self.encrypted_logs_hashes.storage(), - unencrypted_logs_hashes: self.unencrypted_logs_hashes.storage(), + contract_class_logs_hashes: self.contract_class_logs_hashes.storage(), public_call_requests: self.public_call_requests.storage(), } } @@ -58,7 +58,7 @@ impl Empty for PrivateToPublicAccumulatedDataBuilder { l2_to_l1_msgs: BoundedVec::new(), note_encrypted_logs_hashes: BoundedVec::new(), encrypted_logs_hashes: BoundedVec::new(), - unencrypted_logs_hashes: BoundedVec::new(), + contract_class_logs_hashes: BoundedVec::new(), public_call_requests: BoundedVec::new(), } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/avm_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/avm_circuit_public_inputs.nr index 6f13d86177c1..1ce06e8f53ad 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/avm_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/avm_circuit_public_inputs.nr @@ -35,6 +35,7 @@ pub struct AvmCircuitPublicInputs { /////////////////////////////////// // Outputs. end_tree_snapshots: TreeSnapshots, + end_gas_used: Gas, accumulated_data: AvmAccumulatedData, transaction_fee: Field, reverted: bool, @@ -55,6 +56,7 @@ impl Empty for AvmCircuitPublicInputs { previous_non_revertible_accumulated_data: PrivateToAvmAccumulatedData::empty(), previous_revertible_accumulated_data: PrivateToAvmAccumulatedData::empty(), end_tree_snapshots: TreeSnapshots::empty(), + end_gas_used: Gas::empty(), accumulated_data: AvmAccumulatedData::empty(), transaction_fee: 0, reverted: false, @@ -88,6 +90,7 @@ impl Eq for AvmCircuitPublicInputs { == other.previous_revertible_accumulated_data ) & (self.end_tree_snapshots == other.end_tree_snapshots) + & (self.end_gas_used == other.end_gas_used) & (self.accumulated_data == other.accumulated_data) & (self.transaction_fee == other.transaction_fee) & (self.reverted == other.reverted) @@ -116,6 +119,7 @@ impl Serialize for AvmCircuitPublicInputs { fields.extend_from_array(self.previous_non_revertible_accumulated_data.serialize()); fields.extend_from_array(self.previous_revertible_accumulated_data.serialize()); fields.extend_from_array(self.end_tree_snapshots.serialize()); + fields.extend_from_array(self.end_gas_used.serialize()); fields.extend_from_array(self.accumulated_data.serialize()); fields.push(self.transaction_fee); fields.push(self.reverted as Field); @@ -156,6 +160,7 @@ impl Deserialize for AvmCircuitPublicInputs { PrivateToAvmAccumulatedData::deserialize, ), end_tree_snapshots: reader.read_struct(TreeSnapshots::deserialize), + end_gas_used: reader.read_struct(Gas::deserialize), accumulated_data: reader.read_struct(AvmAccumulatedData::deserialize), transaction_fee: reader.read(), reverted: reader.read() as bool, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr index b43f9d2f4c40..c99ace67a292 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr @@ -18,7 +18,7 @@ pub struct PrivateKernelCircuitPublicInputsArrayLengths { l2_to_l1_msgs: u32, note_encrypted_logs_hashes: u32, encrypted_logs_hashes: u32, - unencrypted_logs_hashes: u32, + contract_class_logs_hashes: u32, public_call_requests: u32, private_call_stack: u32, } @@ -40,7 +40,7 @@ impl PrivateKernelCircuitPublicInputsArrayLengths { l2_to_l1_msgs: array_length(public_inputs.end.l2_to_l1_msgs), note_encrypted_logs_hashes: array_length(public_inputs.end.note_encrypted_logs_hashes), encrypted_logs_hashes: array_length(public_inputs.end.encrypted_logs_hashes), - unencrypted_logs_hashes: array_length(public_inputs.end.unencrypted_logs_hashes), + contract_class_logs_hashes: array_length(public_inputs.end.contract_class_logs_hashes), public_call_requests: array_length(public_inputs.end.public_call_requests), private_call_stack: array_length(public_inputs.end.private_call_stack), } @@ -56,7 +56,7 @@ impl PrivateKernelCircuitPublicInputsArrayLengths { l2_to_l1_msgs: 0, note_encrypted_logs_hashes: 0, encrypted_logs_hashes: 0, - unencrypted_logs_hashes: 0, + contract_class_logs_hashes: 0, public_call_requests: 0, private_call_stack: 0, } @@ -76,7 +76,7 @@ impl Eq for PrivateKernelCircuitPublicInputsArrayLengths { & (self.l2_to_l1_msgs == other.l2_to_l1_msgs) & (self.note_encrypted_logs_hashes == other.note_encrypted_logs_hashes) & (self.encrypted_logs_hashes == other.encrypted_logs_hashes) - & (self.unencrypted_logs_hashes == other.unencrypted_logs_hashes) + & (self.contract_class_logs_hashes == other.contract_class_logs_hashes) & (self.public_call_requests == other.public_call_requests) & (self.private_call_stack == other.private_call_stack) } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr index 1e34a3503e6b..78dad89c218a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr @@ -12,12 +12,11 @@ use crate::{ validation_requests::KeyValidationRequestAndGenerator, }, constants::{ - MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL, + MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_UNENCRYPTED_LOGS_PER_CALL, - PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, }, header::Header, messaging::l2_to_l1_message::L2ToL1Message, @@ -37,7 +36,7 @@ pub struct PrivateCircuitPublicInputsArrayLengths { public_call_requests: u32, note_encrypted_logs_hashes: u32, encrypted_logs_hashes: u32, - unencrypted_logs_hashes: u32, + contract_class_logs_hashes: u32, } impl PrivateCircuitPublicInputsArrayLengths { @@ -55,7 +54,7 @@ impl PrivateCircuitPublicInputsArrayLengths { public_call_requests: validate_array(public_inputs.public_call_requests), note_encrypted_logs_hashes: validate_array(public_inputs.note_encrypted_logs_hashes), encrypted_logs_hashes: validate_array(public_inputs.encrypted_logs_hashes), - unencrypted_logs_hashes: validate_array(public_inputs.unencrypted_logs_hashes), + contract_class_logs_hashes: validate_array(public_inputs.contract_class_logs_hashes), } } } @@ -87,7 +86,7 @@ pub struct PrivateCircuitPublicInputs { pub end_side_effect_counter: u32, pub note_encrypted_logs_hashes: [NoteLogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_CALL], pub encrypted_logs_hashes: [EncryptedLogHash; MAX_ENCRYPTED_LOGS_PER_CALL], - pub unencrypted_logs_hashes: [LogHash; MAX_UNENCRYPTED_LOGS_PER_CALL], + pub contract_class_logs_hashes: [LogHash; MAX_CONTRACT_CLASS_LOGS_PER_CALL], // Header of a block whose state is used during private execution (not the block the transaction is included in). pub historical_header: Header, @@ -121,7 +120,7 @@ impl Eq for PrivateCircuitPublicInputs { & (self.end_side_effect_counter == other.end_side_effect_counter) & (self.note_encrypted_logs_hashes == other.note_encrypted_logs_hashes) & (self.encrypted_logs_hashes == other.encrypted_logs_hashes) - & (self.unencrypted_logs_hashes == other.unencrypted_logs_hashes) + & (self.contract_class_logs_hashes == other.contract_class_logs_hashes) & self.historical_header.eq(other.historical_header) & self.tx_context.eq(other.tx_context) } @@ -172,8 +171,8 @@ impl Serialize for PrivateCircuitPublicInp for i in 0..self.encrypted_logs_hashes.len() { fields.extend_from_array(self.encrypted_logs_hashes[i].serialize()); } - for i in 0..self.unencrypted_logs_hashes.len() { - fields.extend_from_array(self.unencrypted_logs_hashes[i].serialize()); + for i in 0..self.contract_class_logs_hashes.len() { + fields.extend_from_array(self.contract_class_logs_hashes[i].serialize()); } fields.extend_from_array(self.historical_header.serialize()); fields.extend_from_array(self.tx_context.serialize()); @@ -238,9 +237,9 @@ impl Deserialize for PrivateCircuitPublicI EncryptedLogHash::deserialize, [EncryptedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_CALL], ), - unencrypted_logs_hashes: reader.read_struct_array( + contract_class_logs_hashes: reader.read_struct_array( LogHash::deserialize, - [LogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_CALL], + [LogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_CALL], ), historical_header: reader.read_struct(Header::deserialize), tx_context: reader.read_struct(TxContext::deserialize), @@ -277,7 +276,7 @@ impl Empty for PrivateCircuitPublicInputs { end_side_effect_counter: 0 as u32, note_encrypted_logs_hashes: [NoteLogHash::empty(); MAX_NOTE_ENCRYPTED_LOGS_PER_CALL], encrypted_logs_hashes: [EncryptedLogHash::empty(); MAX_ENCRYPTED_LOGS_PER_CALL], - unencrypted_logs_hashes: [LogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_CALL], + contract_class_logs_hashes: [LogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_CALL], historical_header: Header::empty(), tx_context: TxContext::empty(), } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 800d4e74d347..b7542af13b3f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -41,6 +41,7 @@ pub global MAX_KEY_VALIDATION_REQUESTS_PER_CALL: u32 = 16; pub global MAX_NOTE_ENCRYPTED_LOGS_PER_CALL: u32 = 16; pub global MAX_ENCRYPTED_LOGS_PER_CALL: u32 = 4; pub global MAX_UNENCRYPTED_LOGS_PER_CALL: u32 = 4; +pub global MAX_CONTRACT_CLASS_LOGS_PER_CALL: u32 = 1; // TREES RELATED CONSTANTS pub global ARCHIVE_HEIGHT: u32 = 29; @@ -94,6 +95,7 @@ pub global MAX_KEY_VALIDATION_REQUESTS_PER_TX: u32 = 64; pub global MAX_NOTE_ENCRYPTED_LOGS_PER_TX: u32 = 64; pub global MAX_ENCRYPTED_LOGS_PER_TX: u32 = 8; pub global MAX_UNENCRYPTED_LOGS_PER_TX: u32 = 8; +pub global MAX_CONTRACT_CLASS_LOGS_PER_TX: u32 = 1; // docs:end:constants // KERNEL CIRCUIT PRIVATE INPUTS CONSTANTS @@ -322,7 +324,7 @@ pub global PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH + 2 + (NOTE_LOG_HASH_LENGTH * MAX_NOTE_ENCRYPTED_LOGS_PER_CALL) + (ENCRYPTED_LOG_HASH_LENGTH * MAX_ENCRYPTED_LOGS_PER_CALL) - + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + + (LOG_HASH_LENGTH * MAX_CONTRACT_CLASS_LOGS_PER_CALL) + HEADER_LENGTH + TX_CONTEXT_LENGTH; pub global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH @@ -374,8 +376,9 @@ pub global COMBINED_ACCUMULATED_DATA_LENGTH: u32 = MAX_NOTE_HASHES_PER_TX + (MAX_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (LOG_HASH_LENGTH * MAX_NOTE_ENCRYPTED_LOGS_PER_TX) + (SCOPED_LOG_HASH_LENGTH * MAX_ENCRYPTED_LOGS_PER_TX) - + 3 - + (MAX_UNENCRYPTED_LOGS_PER_TX * SCOPED_LOG_HASH_LENGTH) + + 4 + + (SCOPED_LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_TX) + + (SCOPED_LOG_HASH_LENGTH * MAX_CONTRACT_CLASS_LOGS_PER_TX) + (MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * PUBLIC_DATA_WRITE_LENGTH); pub global TX_CONSTANT_DATA_LENGTH: u32 = HEADER_LENGTH + TX_CONTEXT_LENGTH @@ -388,7 +391,7 @@ pub global PRIVATE_ACCUMULATED_DATA_LENGTH: u32 = (SCOPED_NOTE_HASH_LENGTH * MAX + (MAX_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (NOTE_LOG_HASH_LENGTH * MAX_NOTE_ENCRYPTED_LOGS_PER_TX) + (SCOPED_ENCRYPTED_LOG_HASH_LENGTH * MAX_ENCRYPTED_LOGS_PER_TX) - + (SCOPED_LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_TX) + + (SCOPED_LOG_HASH_LENGTH * MAX_CONTRACT_CLASS_LOGS_PER_TX) + (PRIVATE_CALL_REQUEST_LENGTH * MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX) + (COUNTED_PUBLIC_CALL_REQUEST_LENGTH * MAX_ENQUEUED_CALLS_PER_TX); pub global PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = TX_CONSTANT_DATA_LENGTH @@ -414,7 +417,7 @@ pub global PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH: u32 = MAX_NOTE_HASHES_PER_ + (MAX_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (MAX_NOTE_ENCRYPTED_LOGS_PER_TX * LOG_HASH_LENGTH) + (MAX_ENCRYPTED_LOGS_PER_TX * SCOPED_LOG_HASH_LENGTH) - + (MAX_UNENCRYPTED_LOGS_PER_TX * SCOPED_LOG_HASH_LENGTH) + + (MAX_CONTRACT_CLASS_LOGS_PER_TX * SCOPED_LOG_HASH_LENGTH) + (MAX_ENQUEUED_CALLS_PER_TX * PUBLIC_CALL_REQUEST_LENGTH); pub global PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH: u32 = MAX_NOTE_HASHES_PER_TX @@ -476,10 +479,10 @@ pub global AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = GLOBAL_VARIABLES_LENGTH + PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH /* previous_non_revertible_accumulated_data */ + PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH /* previous_revertible_accumulated_data */ + TREE_SNAPSHOTS_LENGTH /* end_tree_snapshots */ + + GAS_LENGTH /* end_gas_used */ + AVM_ACCUMULATED_DATA_LENGTH + 1 /* transaction_fee */ - + 1 /* reverted */ -; + + 1 /* reverted */; pub global CONSTANT_ROLLUP_DATA_LENGTH: u32 = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 1 /* vk_tree_root */ @@ -537,7 +540,7 @@ pub global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 2 + 21 * 4; // `AVM_PROOF_LENGTH_IN_FIELDS` must be updated when AVM circuit changes. // To determine latest value, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` // in barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp -pub global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4266; +pub global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4291; pub global AVM_PUBLIC_COLUMN_MAX_SIZE: u32 = 1024; pub global AVM_PUBLIC_INPUTS_FLATTENED_SIZE: u32 = 2 * AVM_PUBLIC_COLUMN_MAX_SIZE + PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr index de890c057543..84004c7c2f49 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr @@ -10,7 +10,7 @@ use crate::{ constants::{ FUNCTION_TREE_HEIGHT, GENERATOR_INDEX__NOTE_HASH_NONCE, GENERATOR_INDEX__OUTER_NULLIFIER, GENERATOR_INDEX__SILOED_NOTE_HASH, GENERATOR_INDEX__UNIQUE_NOTE_HASH, - MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, }, merkle_tree::root::root_from_sibling_path, messaging::l2_to_l1_message::{L2ToL1Message, ScopedL2ToL1Message}, @@ -199,34 +199,10 @@ pub fn accumulate_sha256(input: [Field; 2]) -> Field { } // Computes the final logs hash for a tx. -// NB: this assumes MAX_ENCRYPTED_LOGS_PER_TX == MAX_UNENCRYPTED_LOGS_PER_TX -// to avoid doubling code, since we can't define the byte len to be 32*N directly. -pub fn compute_tx_logs_hash(logs: [LogHash; MAX_ENCRYPTED_LOGS_PER_TX]) -> Field { +pub fn compute_tx_logs_hash(logs: [LogHash; N]) -> Field { // Convert each field element into a byte array and append the bytes to `hash_input_flattened` - let mut hash_input_flattened = [0; MAX_ENCRYPTED_LOGS_PER_TX * 32]; - for offset in 0..MAX_ENCRYPTED_LOGS_PER_TX { - // TODO: This is not checking that the decomposition is smaller than P - let input_as_bytes: [u8; 32] = logs[offset].value.to_be_radix(256); - for byte_index in 0..32 { - hash_input_flattened[offset * 32 + byte_index] = input_as_bytes[byte_index]; - } - } - // Ideally we would push to a slice then hash, but there is no sha_slice - // Hardcode to 256 bytes for now - let mut hash = sha256_to_field(hash_input_flattened); - // Not having a 0 value hash for empty logs causes issues with empty txs - // used for padding. Returning early is currently unsupported. - // We always provide sorted logs here, so 0 being empty means all are empty. - if is_empty(logs[0]) { - hash = 0; - } - hash -} - -pub fn compute_tx_note_logs_hash(logs: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX]) -> Field { - // Convert each field element into a byte array and append the bytes to `hash_input_flattened` - let mut hash_input_flattened = [0; MAX_NOTE_ENCRYPTED_LOGS_PER_TX * 32]; - for offset in 0..MAX_NOTE_ENCRYPTED_LOGS_PER_TX { + let mut hash_input_flattened = [0; N * 32]; + for offset in 0..N { // TODO: This is not checking that the decomposition is smaller than P let input_as_bytes: [u8; 32] = logs[offset].value.to_be_radix(256); for byte_index in 0..32 { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr b/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr index 3ea0310ef922..89837964cff3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr @@ -2,19 +2,16 @@ use crate::traits::{Deserialize, Serialize}; use super::{address::aztec_address::AztecAddress, hash::poseidon2_hash}; use std::meta::derive; -pub global INDEXED_TAGGING_SECRET_LENGTH: u32 = 3; +pub global INDEXED_TAGGING_SECRET_LENGTH: u32 = 2; #[derive(Serialize, Deserialize)] pub struct IndexedTaggingSecret { secret: Field, - recipient: AztecAddress, index: u32, } impl IndexedTaggingSecret { - pub fn compute_tag(self) -> Field { - poseidon2_hash( - [self.secret, self.recipient.to_field(), self.index as Field], - ) + pub fn compute_tag(self, recipient: AztecAddress) -> Field { + poseidon2_hash([self.secret, recipient.to_field(), self.index as Field]) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index 14924b0d2678..96fd4a771d66 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -44,8 +44,8 @@ use crate::{ address::{AztecAddress, EthAddress, SaltedInitializationHash}, constants::{ CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, FUNCTION_TREE_HEIGHT, - MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_FIELD_VALUE, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, + MAX_FIELD_VALUE, MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, @@ -118,12 +118,14 @@ pub struct FixtureBuilder { pub note_encrypted_logs_hashes: BoundedVec, pub encrypted_logs_hashes: BoundedVec, pub unencrypted_logs_hashes: BoundedVec, + pub contract_class_logs_hashes: BoundedVec, pub note_encrypted_logs_hash: Field, pub encrypted_logs_hash: Field, pub unencrypted_logs_hash: Field, pub note_encrypted_log_preimages_length: Field, pub encrypted_log_preimages_length: Field, pub unencrypted_log_preimages_length: Field, + pub contract_class_log_preimages_length: Field, pub public_data_writes: BoundedVec, pub public_data_update_requests: BoundedVec, pub private_call_requests: BoundedVec, @@ -375,7 +377,7 @@ impl FixtureBuilder { encrypted_logs_hashes: subarray(self.encrypted_logs_hashes.storage().map( |l: ScopedEncryptedLogHash| l.log_hash, )), - unencrypted_logs_hashes: subarray(self.unencrypted_logs_hashes.storage().map( + contract_class_logs_hashes: subarray(self.contract_class_logs_hashes.storage().map( |l: ScopedLogHash| l.log_hash, )), historical_header: self.historical_header, @@ -405,7 +407,7 @@ impl FixtureBuilder { l2_to_l1_msgs: self.l2_to_l1_msgs, note_encrypted_logs_hashes: self.note_encrypted_logs_hashes, encrypted_logs_hashes: self.encrypted_logs_hashes, - unencrypted_logs_hashes: self.unencrypted_logs_hashes, + contract_class_logs_hashes: self.contract_class_logs_hashes, public_call_requests: self.public_call_requests, private_call_stack: vec_reverse(self.private_call_requests), } @@ -473,9 +475,9 @@ impl FixtureBuilder { encrypted_logs_hashes: self.encrypted_logs_hashes.storage().map( |l: ScopedEncryptedLogHash| l.expose_to_public(), ), - unencrypted_logs_hashes: self.unencrypted_logs_hashes.storage().map(|l: ScopedLogHash| { - l.expose_to_public() - }), + contract_class_logs_hashes: self.contract_class_logs_hashes.storage().map( + |l: ScopedLogHash| l.expose_to_public(), + ), public_call_requests: self.public_call_requests.storage().map( |cr: Counted| cr.inner, ), @@ -498,9 +500,13 @@ impl FixtureBuilder { unencrypted_logs_hashes: self.unencrypted_logs_hashes.storage().map(|l: ScopedLogHash| { l.expose_to_public() }), + contract_class_logs_hashes: self.contract_class_logs_hashes.storage.map( + |l: ScopedLogHash| l.expose_to_public(), + ), note_encrypted_log_preimages_length: self.note_encrypted_log_preimages_length, encrypted_log_preimages_length: self.encrypted_log_preimages_length, unencrypted_log_preimages_length: self.unencrypted_log_preimages_length, + contract_class_log_preimages_length: self.contract_class_log_preimages_length, public_data_writes: self.public_data_writes.storage(), } } @@ -1028,6 +1034,12 @@ impl FixtureBuilder { self.unencrypted_logs_hash = compute_tx_logs_hash(log_hashes); } + pub fn add_contract_class_log_hash(&mut self, hash: Field, length: Field) { + let log_hash = LogHash { value: hash, counter: self.next_counter(), length }; + self.contract_class_logs_hashes.push(log_hash.scope(self.contract_address)); + self.contract_class_log_preimages_length += length; + } + pub fn set_encrypted_logs_hash(&mut self, hash: Field, preimages_length: Field) { self.encrypted_logs_hash = hash; self.encrypted_log_preimages_length = preimages_length; @@ -1247,12 +1259,14 @@ impl Empty for FixtureBuilder { note_encrypted_logs_hashes: BoundedVec::new(), encrypted_logs_hashes: BoundedVec::new(), unencrypted_logs_hashes: BoundedVec::new(), + contract_class_logs_hashes: BoundedVec::new(), note_encrypted_logs_hash: 0, encrypted_logs_hash: 0, unencrypted_logs_hash: 0, note_encrypted_log_preimages_length: 0, encrypted_log_preimages_length: 0, unencrypted_log_preimages_length: 0, + contract_class_log_preimages_length: 0, public_data_writes: BoundedVec::new(), public_data_update_requests: BoundedVec::new(), private_call_requests: BoundedVec::new(), diff --git a/noir/noir-repo/.release-please-manifest.json b/noir/noir-repo/.release-please-manifest.json index 69d91ea64a2e..138ef24bf732 100644 --- a/noir/noir-repo/.release-please-manifest.json +++ b/noir/noir-repo/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.37.0", - "acvm-repo": "0.53.0" + ".": "0.38.0", + "acvm-repo": "0.54.0" } diff --git a/noir/noir-repo/CHANGELOG.md b/noir/noir-repo/CHANGELOG.md index f2c9a76442b3..076a36fc96b8 100644 --- a/noir/noir-repo/CHANGELOG.md +++ b/noir/noir-repo/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.38.0](https://github.com/noir-lang/noir/compare/v0.37.0...v0.38.0) (2024-11-08) + + +### ⚠ BREAKING CHANGES + +* Always Check Arithmetic Generics at Monomorphization ([#6329](https://github.com/noir-lang/noir/issues/6329)) + +### Features + +* Always Check Arithmetic Generics at Monomorphization ([#6329](https://github.com/noir-lang/noir/issues/6329)) ([2972db2](https://github.com/noir-lang/noir/commit/2972db20fc00ed0e43b662092f0d0712421d122f)) +* Ensure that generated ACIR is solvable ([#6415](https://github.com/noir-lang/noir/issues/6415)) ([b473d99](https://github.com/noir-lang/noir/commit/b473d99b2b70b595596b8392617256dbaf5d5642)) +* Nargo command to generate shell completions ([#6413](https://github.com/noir-lang/noir/issues/6413)) ([13856a1](https://github.com/noir-lang/noir/commit/13856a121125b1ccca15919942081a5d157d280e)) + + +### Bug Fixes + +* Check infix expression is valid in program input ([#6450](https://github.com/noir-lang/noir/issues/6450)) ([35dedb5](https://github.com/noir-lang/noir/commit/35dedb54a0853ba0fa85038d832a520f9ba01a98)) +* Discard optimisation that would change execution ordering or that is related to call outputs ([#6461](https://github.com/noir-lang/noir/issues/6461)) ([b8654f7](https://github.com/noir-lang/noir/commit/b8654f700b218cc09c5381af65df11ead9ffcdaf)) +* Don't crash on AsTraitPath with empty path ([#6454](https://github.com/noir-lang/noir/issues/6454)) ([fc72dcd](https://github.com/noir-lang/noir/commit/fc72dcdf3e8eeff73f72756e7ab87dddf2920657)) +* Fix Alias and Error kinds ([#6426](https://github.com/noir-lang/noir/issues/6426)) ([3cb259f](https://github.com/noir-lang/noir/commit/3cb259f419cf352f768728b15f849e520fc233cb)) +* Let formatter respect newlines between comments ([#6458](https://github.com/noir-lang/noir/issues/6458)) ([fb1a8ca](https://github.com/noir-lang/noir/commit/fb1a8ca67c58d87991358078e6c532b49824fdb8)) +* Right shift is not a regular division ([#6400](https://github.com/noir-lang/noir/issues/6400)) ([2247814](https://github.com/noir-lang/noir/commit/2247814f951f5d33257cd123a3bdcba857c9b167)) +* **sea:** Mem2reg to treat block input references as alias ([#6452](https://github.com/noir-lang/noir/issues/6452)) ([5310064](https://github.com/noir-lang/noir/commit/53100647bf1dc7917b66c9a7041c06b1e716fbe7)) +* **ssa:** Change array_set to not mutate slices coming from function inputs ([#6463](https://github.com/noir-lang/noir/issues/6463)) ([371bd45](https://github.com/noir-lang/noir/commit/371bd45130c9095e5dfb20dc79fbf41c02ed087c)) +* **ssa:** Resolve value IDs in terminator before comparing to array ([#6448](https://github.com/noir-lang/noir/issues/6448)) ([66f15ca](https://github.com/noir-lang/noir/commit/66f15caba8466501256a98cee289c49376b27097)) +* **tests:** Prevent EOF error while running test programs ([#6455](https://github.com/noir-lang/noir/issues/6455)) ([358e381](https://github.com/noir-lang/noir/commit/358e38107edbc4f40c97b88196456d82f5557e3f)) +* Type-check turbofish in trait before function call ([#6416](https://github.com/noir-lang/noir/issues/6416)) ([f8fd813](https://github.com/noir-lang/noir/commit/f8fd813b09ce870364700659e3ea8499ab51105e)) + ## [0.37.0](https://github.com/noir-lang/noir/compare/v0.36.0...v0.37.0) (2024-10-31) diff --git a/noir/noir-repo/Cargo.lock b/noir/noir-repo/Cargo.lock index 3659a2647375..35ff97f55e34 100644 --- a/noir/noir-repo/Cargo.lock +++ b/noir/noir-repo/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir_field", "base64 0.21.7", @@ -26,7 +26,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.53.0" +version = "0.54.0" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -59,7 +59,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "blake2", @@ -89,14 +89,14 @@ dependencies = [ "proptest", "rand 0.8.5", "thiserror", - "toml 0.7.6", + "toml 0.7.8", "tracing-appender", "tracing-subscriber", ] [[package]] name = "acvm_js" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -130,6 +130,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -145,9 +151,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -175,9 +181,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -190,26 +196,26 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -224,9 +230,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "ark-bls12-381" @@ -359,26 +365,27 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "assert_cmd" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" dependencies = [ "anstyle", - "bstr 1.6.0", + "bstr", "doc-comment", - "predicates 3.0.3", + "libc", + "predicates 3.1.2", "predicates-core", "predicates-tree", "wait-timeout", @@ -386,14 +393,14 @@ dependencies = [ [[package]] name = "assert_fs" -version = "1.0.13" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f070617a68e5c2ed5d06ee8dd620ee18fb72b99f6c094bed34cf8ab07c875b48" +checksum = "7efdb1fdb47602827a342857666feb372712cbc64b414172bd6b167a02927674" dependencies = [ "anstyle", "doc-comment", "globwalk", - "predicates 3.0.3", + "predicates 3.1.2", "predicates-core", "predicates-tree", "tempfile", @@ -405,7 +412,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138985dd8aefbefeaa66b01b7f5b2b6b4c333fcef1cc5f32c63a2aabe37d6de3" dependencies = [ - "futures 0.3.30", + "futures 0.3.31", "lsp-types 0.94.1", "pin-project-lite", "rustix", @@ -421,21 +428,21 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -458,6 +465,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -496,9 +509,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitmaps" @@ -543,9 +556,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -578,7 +591,7 @@ dependencies = [ [[package]] name = "bn254_blackbox_solver" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -596,7 +609,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir_field", "serde", @@ -604,7 +617,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.53.0" +version = "0.54.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -615,31 +628,20 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata 0.1.10", -] - -[[package]] -name = "bstr" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.3.9", + "regex-automata 0.4.8", "serde", ] [[package]] name = "build-data" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac83c47416b2db78a5a8a45d7d229a730b62806fa41ac6b4dbde6d016798776" +checksum = "aed3884e2cab7c973c8fd2d150314b6a932df7fdc830edcaf1e8e7c4ae9db3c0" dependencies = [ "chrono", "safe-lock", @@ -648,42 +650,42 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "camino" -version = "1.1.6" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -710,11 +712,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" dependencies = [ - "libc", + "shlex", ] [[package]] @@ -746,9 +748,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -757,15 +759,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -798,14 +800,14 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] name = "clap_complete" -version = "4.5.36" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2" +checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595" dependencies = [ "clap", ] @@ -819,7 +821,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] @@ -857,7 +859,7 @@ checksum = "fc4159b76af02757139baf42c0c971c6dc155330999fbfd8eddb29b97fb2db68" dependencies = [ "codespan-reporting", "lsp-types 0.88.0", - "url 2.5.0", + "url 2.5.3", ] [[package]] @@ -873,9 +875,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -888,9 +890,9 @@ dependencies = [ [[package]] name = "color-spantrace" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" dependencies = [ "once_cell", "owo-colors", @@ -900,9 +902,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comma" @@ -934,30 +936,30 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const-str" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aca749d3d3f5b87a0d6100509879f9cf486ab510803a4a4e1001da1ff61c2bd6" +checksum = "3618cccc083bb987a415d85c02ca6c9994ea5b44731ec28b9ecf09658655fba9" [[package]] name = "const_format" -version = "0.2.31" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c990efc7a285731f9a4378d81aff2f0e85a2c8781a05ef0f8baa8dac54d0ff48" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.31" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e026b6ce194a874cb9cf32cd5772d1ef9767cc8fcb5765948d74f37a9d8b2bf6" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" dependencies = [ "proc-macro2", "quote", @@ -966,9 +968,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "convert_case" @@ -987,33 +989,33 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpp_demangle" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee34052ee3d93d6d8f3e6f81d85c47921f6653a19a7b70e939e3e602d893a674" +checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if 1.0.0", ] @@ -1056,43 +1058,43 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.9" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c3242926edf34aec4ac3a77108ad4854bffaa2e4ddc1824124ce59231302d5" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ - "cfg-if 1.0.0", "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if 1.0.0", "crossbeam-utils", - "memoffset 0.9.1", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" @@ -1118,9 +1120,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" dependencies = [ "csv-core", "itoa", @@ -1130,9 +1132,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" dependencies = [ "memchr", ] @@ -1150,9 +1152,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -1160,40 +1162,41 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", - "syn 2.0.64", + "strsim", + "syn 2.0.87", ] [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "dashmap" -version = "5.5.3" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if 1.0.0", + "crossbeam-utils", "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.10", ] [[package]] @@ -1217,10 +1220,11 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.7" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ + "powerfmt", "serde", ] @@ -1237,15 +1241,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] @@ -1306,6 +1310,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -1341,9 +1356,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -1383,12 +1398,22 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", +] + [[package]] name = "env_logger" -version = "0.10.2" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ + "env_filter", "log", ] @@ -1420,9 +1445,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ "indenter", "once_cell", @@ -1430,9 +1455,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fd-lock" @@ -1478,23 +1503,23 @@ dependencies = [ [[package]] name = "file-id" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" +checksum = "6bc904b9bbefcadbd8e3a9fb0d464a9b979de6324c03b3c663e8994f46a5be36" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "libredox 0.1.3", + "windows-sys 0.59.0", ] [[package]] @@ -1517,12 +1542,12 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -1536,7 +1561,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.37.0" +version = "0.38.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -1581,9 +1606,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1596,9 +1621,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1606,15 +1631,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1624,38 +1649,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures 0.1.31", "futures-channel", @@ -1715,9 +1740,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -1727,24 +1752,24 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.11" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", - "bstr 1.6.0", - "fnv", + "bstr", "log", - "regex", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] name = "globwalk" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "ignore", "walkdir", ] @@ -1787,9 +1812,13 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if 1.0.0", + "crunchy", +] [[package]] name = "halo2" @@ -1835,6 +1864,12 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + [[package]] name = "heck" version = "0.3.3" @@ -1858,9 +1893,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" @@ -1879,9 +1920,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1890,9 +1931,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1901,21 +1942,21 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -1942,9 +1983,9 @@ checksum = "71a816c97c42258aa5834d07590b718b4c9a598944cd39a52dc25b351185d678" [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1963,6 +2004,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1982,27 +2141,37 @@ dependencies = [ [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.8", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -2065,20 +2234,20 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.1", "serde", ] [[package]] name = "inferno" -version = "0.11.19" +version = "0.11.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" +checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash", "clap", @@ -2086,7 +2255,7 @@ dependencies = [ "crossbeam-utils", "dashmap", "env_logger", - "indexmap 2.2.6", + "indexmap 2.6.0", "is-terminal", "itoa", "log", @@ -2119,22 +2288,22 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "hermit-abi 0.4.0", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -2145,7 +2314,7 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "iter-extended" -version = "0.37.0" +version = "0.38.0" [[package]] name = "itertools" @@ -2158,9 +2327,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" @@ -2190,7 +2359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" dependencies = [ "derive_more", - "futures 0.3.30", + "futures 0.3.31", "jsonrpc-core", "jsonrpc-pubsub", "log", @@ -2205,7 +2374,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" dependencies = [ - "futures 0.3.30", + "futures 0.3.31", "futures-executor", "futures-util", "log", @@ -2220,7 +2389,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" dependencies = [ - "futures 0.3.30", + "futures 0.3.31", "jsonrpc-client-transports", ] @@ -2242,7 +2411,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" dependencies = [ - "futures 0.3.30", + "futures 0.3.31", "hyper", "jsonrpc-core", "jsonrpc-server-utils", @@ -2258,7 +2427,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" dependencies = [ - "futures 0.3.30", + "futures 0.3.31", "jsonrpc-core", "lazy_static", "log", @@ -2274,7 +2443,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" dependencies = [ "bytes", - "futures 0.3.30", + "futures 0.3.31", "globset", "jsonrpc-core", "lazy_static", @@ -2313,9 +2482,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -2342,9 +2511,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ "spin", ] @@ -2357,15 +2526,15 @@ checksum = "82903360c009b816f5ab72a9b68158c27c301ee2c3f20655b55c5e589e7d3bb7" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libredox" @@ -2373,11 +2542,22 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "redox_syscall 0.4.1", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall 0.5.7", +] + [[package]] name = "light-poseidon" version = "0.2.0" @@ -2396,11 +2576,17 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -2408,9 +2594,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "louds-rs" @@ -2431,7 +2617,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "url 2.5.0", + "url 2.5.3", ] [[package]] @@ -2444,7 +2630,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "url 2.5.0", + "url 2.5.3", ] [[package]] @@ -2464,15 +2650,15 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.5.10" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", ] @@ -2486,15 +2672,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" -dependencies = [ - "autocfg", -] - [[package]] name = "memuse" version = "0.2.1" @@ -2510,11 +2687,20 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "minreq" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" +checksum = "763d142cdff44aaadd9268bebddb156ef6c65a0e13486bb81673cf2d8739f9b0" dependencies = [ "log", "serde", @@ -2533,9 +2719,21 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", +] + [[package]] name = "nargo" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "fm", @@ -2562,7 +2760,7 @@ dependencies = [ [[package]] name = "nargo_cli" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "ark-bn254", @@ -2582,6 +2780,7 @@ dependencies = [ "fm", "iai", "iter-extended", + "lazy_static", "light-poseidon", "nargo", "nargo_fmt", @@ -2613,8 +2812,8 @@ dependencies = [ "test-case", "thiserror", "tokio", - "tokio-util 0.7.10", - "toml 0.7.6", + "tokio-util 0.7.12", + "toml 0.7.8", "tower", "tracing-appender", "tracing-subscriber", @@ -2622,18 +2821,18 @@ dependencies = [ [[package]] name = "nargo_fmt" -version = "0.37.0" +version = "0.38.0" dependencies = [ "noirc_frontend", "serde", "similar-asserts", "thiserror", - "toml 0.7.6", + "toml 0.7.8", ] [[package]] name = "nargo_toml" -version = "0.37.0" +version = "0.38.0" dependencies = [ "dirs", "fm", @@ -2643,8 +2842,8 @@ dependencies = [ "semver", "serde", "thiserror", - "toml 0.7.6", - "url 2.5.0", + "toml 0.7.8", + "url 2.5.3", ] [[package]] @@ -2677,7 +2876,7 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "memoffset 0.6.5", + "memoffset", ] [[package]] @@ -2690,7 +2889,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if 1.0.0", "libc", - "memoffset 0.6.5", + "memoffset", "pin-utils", ] @@ -2707,7 +2906,7 @@ dependencies = [ [[package]] name = "noir_debugger" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "assert_cmd", @@ -2731,7 +2930,7 @@ dependencies = [ [[package]] name = "noir_fuzzer" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "noirc_abi", @@ -2754,7 +2953,7 @@ dependencies = [ [[package]] name = "noir_lsp" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "async-lsp", @@ -2781,7 +2980,7 @@ dependencies = [ [[package]] name = "noir_profiler" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acir", "bn254_blackbox_solver", @@ -2807,7 +3006,7 @@ dependencies = [ [[package]] name = "noir_wasm" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "build-data", @@ -2831,7 +3030,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "iter-extended", @@ -2839,18 +3038,18 @@ dependencies = [ "num-bigint", "num-traits", "proptest", - "proptest-derive", + "proptest-derive 0.4.0", "serde", "serde_json", "strum", "strum_macros", "thiserror", - "toml 0.7.6", + "toml 0.7.8", ] [[package]] name = "noirc_abi_wasm" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "build-data", @@ -2867,11 +3066,11 @@ dependencies = [ [[package]] name = "noirc_arena" -version = "0.37.0" +version = "0.38.0" [[package]] name = "noirc_artifacts" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "codespan-reporting", @@ -2886,7 +3085,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "build-data", @@ -2905,7 +3104,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "base64 0.21.7", @@ -2922,7 +3121,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -2934,18 +3133,20 @@ dependencies = [ "noirc_errors", "noirc_frontend", "num-bigint", + "num-traits", "proptest", "rayon", "serde", "serde_json", "serde_with", + "similar-asserts", "thiserror", "tracing", ] [[package]] name = "noirc_frontend" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "base64 0.21.7", @@ -2960,6 +3161,8 @@ dependencies = [ "num-bigint", "num-traits", "petgraph", + "proptest", + "proptest-derive 0.5.0", "rangemap", "regex", "rustc-hash", @@ -2975,7 +3178,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.37.0" +version = "0.38.0" dependencies = [ "acvm", "iter-extended", @@ -2998,7 +3201,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -3006,22 +3209,22 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] [[package]] name = "notify-debouncer-full" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" +checksum = "fb7fd166739789c9ff169e654dc1501373db9d80a4c3f972817c8a4d7cf8f34e" dependencies = [ "crossbeam-channel", "file-id", "log", "notify", - "parking_lot 0.12.1", + "parking_lot 0.12.3", "walkdir", ] @@ -3045,6 +3248,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" @@ -3080,7 +3289,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -3092,24 +3301,24 @@ checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] name = "object" -version = "0.31.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "overload" @@ -3156,12 +3365,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.10", ] [[package]] @@ -3180,15 +3389,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.5.7", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -3223,9 +3432,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -3241,12 +3450,12 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.6.0", ] [[package]] @@ -3295,9 +3504,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -3317,15 +3526,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -3336,19 +3545,25 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "pprof" version = "0.12.1" @@ -3364,7 +3579,7 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.3", "smallvec", "symbolic-demangle", "tempfile", @@ -3386,7 +3601,7 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.3", "smallvec", "symbolic-demangle", "tempfile", @@ -3395,9 +3610,12 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "predicates" @@ -3415,27 +3633,26 @@ dependencies = [ [[package]] name = "predicates" -version = "3.0.3" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "difflib", - "itertools", "predicates-core", ] [[package]] name = "predicates-core" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -3472,28 +3689,28 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -3510,6 +3727,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "proptest-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -3527,9 +3755,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -3641,9 +3869,9 @@ dependencies = [ [[package]] name = "rangemap" -version = "1.4.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977b1e897f9d764566891689e642653e5ed90c6895106acd005eb4c1d0203991" +checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684" [[package]] name = "rayon" @@ -3676,20 +3904,20 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] @@ -3700,25 +3928,25 @@ checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb" [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom 0.2.15", - "redox_syscall 0.2.16", + "libredox 0.1.3", "thiserror", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.2", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -3732,19 +3960,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" - -[[package]] -name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", ] [[package]] @@ -3755,9 +3977,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rexpect" @@ -3785,9 +4007,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.36" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" dependencies = [ "bytemuck", ] @@ -3812,7 +4034,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.64", + "syn 2.0.87", "walkdir", ] @@ -3828,9 +4050,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -3840,20 +4062,20 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -3862,9 +4084,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -3914,23 +4136,23 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe-lock" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "077d73db7973cccf63eb4aff1e5a34dc2459baa867512088269ea5f2f4253c90" +checksum = "f29841ed0a577196bca5b753cd4e4022fa50b718e56fc0d35919ed32e20ec65c" [[package]] name = "safe-proc-macro2" -version = "1.0.36" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" +checksum = "7fd85be67db87168aa3c13fd0da99f48f2ab005dccad5af5626138dc1df20eb6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -3944,18 +4166,18 @@ dependencies = [ [[package]] name = "safe-regex" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" +checksum = "e6ab4bc484ef480a9ce79b381efd7b6767700f514d47bc599036e9d6f7f3c49d" dependencies = [ "safe-regex-macro", ] [[package]] name = "safe-regex-compiler" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" +checksum = "6d71f8c78bffb07962595e1bfa5ed11d24dd855eedc50b6a735f5ef648ce621b" dependencies = [ "safe-proc-macro2", "safe-quote", @@ -3963,9 +4185,9 @@ dependencies = [ [[package]] name = "safe-regex-macro" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" +checksum = "0909ab4b77511df24201cd66541d6a028887c77ecc065f277c68a12a663274ef" dependencies = [ "safe-proc-macro2", "safe-regex-compiler", @@ -4008,18 +4230,18 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.209" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] @@ -4060,58 +4282,60 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_repr" -version = "0.1.14" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] [[package]] name = "serde_with" -version = "3.2.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1402f54f9a3b9e2efe71c1cea24e648acce55887983553eeb858cf3115acfd49" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.6.0", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -4119,21 +4343,21 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.2.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9197f1ad0e3c173a0222d3c4404fb04c3afe87e962bcb327af73e8301fa203c7" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -4152,9 +4376,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -4165,6 +4389,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "1.6.4" @@ -4177,19 +4407,19 @@ dependencies = [ [[package]] name = "similar" -version = "2.3.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" dependencies = [ - "bstr 0.2.17", + "bstr", "unicode-segmentation", ] [[package]] name = "similar-asserts" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" +checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" dependencies = [ "console", "similar", @@ -4213,9 +4443,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -4252,19 +4482,19 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" @@ -4300,12 +4530,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -4333,15 +4557,15 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "symbolic-common" -version = "12.3.0" +version = "12.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167a4ffd7c35c143fd1030aa3c2caf76ba42220bd5a6b5f4781896434723b8c3" +checksum = "3d4d73159efebfb389d819fd479afb2dbd57dcb3e3f4b7fcfa0e675f5a46c1cb" dependencies = [ "debugid", "memmap2", @@ -4351,9 +4575,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.3.0" +version = "12.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e378c50e80686c1c5c205674e1f86a2858bec3d2a7dfdd690331a8a19330f293" +checksum = "a767859f6549c665011970874c3f541838b4835d5aaaa493d3ee383918be9f10" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -4373,15 +4597,26 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.64" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tap" version = "1.0.1" @@ -4390,15 +4625,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall 0.3.5", + "once_cell", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -4414,9 +4649,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -4428,7 +4663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "417813675a504dfbbf21bfde32c03e5bf9f2413999962b479023c02848c1c7a5" dependencies = [ "libc", - "libredox", + "libredox 0.0.2", "numtoa", "redox_termios", ] @@ -4470,7 +4705,7 @@ dependencies = [ "cfg-if 1.0.0", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] @@ -4481,7 +4716,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", "test-case-core", ] @@ -4508,29 +4743,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if 1.0.0", "once_cell", @@ -4538,12 +4773,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.25" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -4551,19 +4788,30 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -4576,9 +4824,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -4591,37 +4839,36 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.2", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -4644,9 +4891,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -4667,9 +4914,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -4679,20 +4926,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -4712,15 +4959,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -4754,7 +5001,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", ] [[package]] @@ -4830,15 +5077,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unarray" @@ -4848,24 +5095,21 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicase" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-linebreak" @@ -4875,30 +5119,30 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "url" @@ -4913,27 +5157,39 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.3", "percent-encoding 2.3.1", "serde", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.4.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" @@ -4943,9 +5199,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wait-timeout" @@ -4958,12 +5214,12 @@ dependencies = [ [[package]] name = "waitpid-any" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54f8c3c56044fc359f905b72879576a15d49c46d085ed6266a98826716f14033" +checksum = "0189157c93c54d86e5c61ddf0c1223baa25e5bfb2f6f9983c678985b028d7c12" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5020,7 +5276,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -5054,7 +5310,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5117,11 +5373,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -5132,11 +5388,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.50.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af6041b3f84485c21b57acdc0fee4f4f0c93f426053dc05fa5d6fc262537bbff" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -5289,13 +5545,25 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.0" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyz" version = "0.5.1" @@ -5305,31 +5573,77 @@ dependencies = [ "tap", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", ] [[package]] name = "zeroize" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -5342,7 +5656,29 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.87", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] diff --git a/noir/noir-repo/Cargo.toml b/noir/noir-repo/Cargo.toml index d819c37daeb0..214ed9a5bcbb 100644 --- a/noir/noir-repo/Cargo.toml +++ b/noir/noir-repo/Cargo.toml @@ -40,7 +40,7 @@ resolver = "2" [workspace.package] # x-release-please-start-version -version = "0.37.0" +version = "0.38.0" # x-release-please-end authors = ["The Noir Team "] edition = "2021" @@ -57,13 +57,13 @@ unused_qualifications = "warn" [workspace.dependencies] # ACVM workspace dependencies -acir_field = { version = "0.53.0", path = "acvm-repo/acir_field", default-features = false } -acir = { version = "0.53.0", path = "acvm-repo/acir", default-features = false } -acvm = { version = "0.53.0", path = "acvm-repo/acvm" } -brillig = { version = "0.53.0", path = "acvm-repo/brillig", default-features = false } -brillig_vm = { version = "0.53.0", path = "acvm-repo/brillig_vm", default-features = false } -acvm_blackbox_solver = { version = "0.53.0", path = "acvm-repo/blackbox_solver", default-features = false } -bn254_blackbox_solver = { version = "0.53.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } +acir_field = { version = "0.54.0", path = "acvm-repo/acir_field", default-features = false } +acir = { version = "0.54.0", path = "acvm-repo/acir", default-features = false } +acvm = { version = "0.54.0", path = "acvm-repo/acvm" } +brillig = { version = "0.54.0", path = "acvm-repo/brillig", default-features = false } +brillig_vm = { version = "0.54.0", path = "acvm-repo/brillig_vm", default-features = false } +acvm_blackbox_solver = { version = "0.54.0", path = "acvm-repo/blackbox_solver", default-features = false } +bn254_blackbox_solver = { version = "0.54.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } # Noir compiler workspace dependencies fm = { path = "compiler/fm" } @@ -142,6 +142,7 @@ build-data = "0.1.3" bincode = "1.3.3" hex = "0.4.2" const_format = "0.2.30" +lazy_static = "1.4" num-bigint = "0.4" num-traits = "0.2" similar-asserts = "1.5.0" diff --git a/noir/noir-repo/acvm-repo/CHANGELOG.md b/noir/noir-repo/acvm-repo/CHANGELOG.md index aa25221a477c..919653c0eba0 100644 --- a/noir/noir-repo/acvm-repo/CHANGELOG.md +++ b/noir/noir-repo/acvm-repo/CHANGELOG.md @@ -5,6 +5,131 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.54.0](https://github.com/noir-lang/noir/compare/v0.53.0...v0.54.0) (2024-11-08) + + +### ⚠ BREAKING CHANGES + +* **avm/brillig:** revert/rethrow oracle (https://github.com/AztecProtocol/aztec-packages/pull/9408) +* use Brillig opcode when possible for less-than operations on fields (https://github.com/AztecProtocol/aztec-packages/pull/9416) +* remove noir_js_backend_barretenberg (https://github.com/AztecProtocol/aztec-packages/pull/9338) +* replace usage of vector in keccakf1600 input with array (https://github.com/AztecProtocol/aztec-packages/pull/9350) +* **profiler:** New flamegraph command that profiles the opcodes executed ([#6327](https://github.com/noir-lang/noir/issues/6327)) +* remove pedersen commitment (https://github.com/AztecProtocol/aztec-packages/pull/9107) +* remove pedersen hash opcode (https://github.com/AztecProtocol/aztec-packages/pull/9245) +* Brillig and AVM default all uninitialized memory cells to Field 0 (https://github.com/AztecProtocol/aztec-packages/pull/9057) +* remove keccak256 opcode from ACIR/Brillig (https://github.com/AztecProtocol/aztec-packages/pull/9104) +* Brillig with a stack and conditional inlining (https://github.com/AztecProtocol/aztec-packages/pull/8989) +* **avm:** remove CMOV opcode (https://github.com/AztecProtocol/aztec-packages/pull/9030) +* remove sha256 opcode (https://github.com/AztecProtocol/aztec-packages/pull/4571) +* add support for u1 in the avm, ToRadix's radix arg is a memory addr (https://github.com/AztecProtocol/aztec-packages/pull/8570) +* Add Not instruction in brillig (https://github.com/AztecProtocol/aztec-packages/pull/8488) +* **avm:** variants for SET opcode (https://github.com/AztecProtocol/aztec-packages/pull/8441) +* **avm/brillig:** take addresses in calldatacopy (https://github.com/AztecProtocol/aztec-packages/pull/8388) + +### Features + +* (bb) 128-bit challenges (https://github.com/AztecProtocol/aztec-packages/pull/8406) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* **acir_gen:** Width aware ACIR gen addition ([#5493](https://github.com/noir-lang/noir/issues/5493)) ([85fa592](https://github.com/noir-lang/noir/commit/85fa592fdef3b8589ce03b232e1b51565837b540)) +* Add assertions for ACVM `FunctionInput` `bit_size` ([#5864](https://github.com/noir-lang/noir/issues/5864)) ([8712f4c](https://github.com/noir-lang/noir/commit/8712f4c20d23f3809bcfb03f2e3ba0e5ace20a1d)) +* Add Not instruction in brillig (https://github.com/AztecProtocol/aztec-packages/pull/8488) ([95e19ab](https://github.com/noir-lang/noir/commit/95e19ab9486ad054241b6e53e40e55bdba9dc7e5)) +* Add recursive aggregation object to proving/verification keys (https://github.com/AztecProtocol/aztec-packages/pull/6770) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Add reusable procedures to brillig generation (https://github.com/AztecProtocol/aztec-packages/pull/7981) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Add support for u1 in the avm, ToRadix's radix arg is a memory addr (https://github.com/AztecProtocol/aztec-packages/pull/8570) ([e8bbce7](https://github.com/noir-lang/noir/commit/e8bbce71fde3fc7af410c30920c2a547389d8248)) +* Added indirect const instruction (https://github.com/AztecProtocol/aztec-packages/pull/8065) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Adding aggregation to honk and rollup (https://github.com/AztecProtocol/aztec-packages/pull/7466) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Automate verify_honk_proof input generation (https://github.com/AztecProtocol/aztec-packages/pull/8092) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* **avm/brillig:** Revert/rethrow oracle (https://github.com/AztecProtocol/aztec-packages/pull/9408) ([321a493](https://github.com/noir-lang/noir/commit/321a493216e19a2f077007c3447a3030db0df0d0)) +* **avm/brillig:** Take addresses in calldatacopy (https://github.com/AztecProtocol/aztec-packages/pull/8388) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* **avm:** Variants for SET opcode (https://github.com/AztecProtocol/aztec-packages/pull/8441) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* Avoid heap allocs when going to/from field (https://github.com/AztecProtocol/aztec-packages/pull/7547) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Brillig and AVM default all uninitialized memory cells to Field 0 (https://github.com/AztecProtocol/aztec-packages/pull/9057) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Brillig with a stack and conditional inlining (https://github.com/AztecProtocol/aztec-packages/pull/8989) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Change the layout of arrays and vectors to be a single pointer (https://github.com/AztecProtocol/aztec-packages/pull/8448) ([d4832ec](https://github.com/noir-lang/noir/commit/d4832ece9d3ad16544afea49cc7caf40501a2cc3)) +* Ensure that generated ACIR is solvable ([#6415](https://github.com/noir-lang/noir/issues/6415)) ([b473d99](https://github.com/noir-lang/noir/commit/b473d99b2b70b595596b8392617256dbaf5d5642)) +* Hook up secondary calldata column in dsl (https://github.com/AztecProtocol/aztec-packages/pull/7759) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Integrate databus in the private kernels (https://github.com/AztecProtocol/aztec-packages/pull/9028) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Integrate new proving systems in e2e (https://github.com/AztecProtocol/aztec-packages/pull/6971) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Make Brillig do integer arithmetic operations using u128 instead of Bigint (https://github.com/AztecProtocol/aztec-packages/pull/7518) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Make token transfer be recursive (https://github.com/AztecProtocol/aztec-packages/pull/7730) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* New test programs for wasm benchmarking (https://github.com/AztecProtocol/aztec-packages/pull/8389) ([95e19ab](https://github.com/noir-lang/noir/commit/95e19ab9486ad054241b6e53e40e55bdba9dc7e5)) +* Note hashes as points (https://github.com/AztecProtocol/aztec-packages/pull/7618) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Optimize allocating immediate amounts of memory (https://github.com/AztecProtocol/aztec-packages/pull/8579) ([e8bbce7](https://github.com/noir-lang/noir/commit/e8bbce71fde3fc7af410c30920c2a547389d8248)) +* Optimize constant array handling in brillig_gen (https://github.com/AztecProtocol/aztec-packages/pull/7661) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Optimize to_radix (https://github.com/AztecProtocol/aztec-packages/pull/8073) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Pass calldata ids to the backend (https://github.com/AztecProtocol/aztec-packages/pull/7875) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Poseidon2 gates for Ultra arithmetisation (https://github.com/AztecProtocol/aztec-packages/pull/7494) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* **profiler:** Add support for brillig functions in opcodes-flamegraph (https://github.com/AztecProtocol/aztec-packages/pull/7698) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* **profiler:** New flamegraph command that profiles the opcodes executed ([#6327](https://github.com/noir-lang/noir/issues/6327)) ([4d87c9a](https://github.com/noir-lang/noir/commit/4d87c9ac78b48b4bd0ae81316df28aab390d004e)) +* Remove 'single use' intermediate variables ([#6268](https://github.com/noir-lang/noir/issues/6268)) ([ec75e8e](https://github.com/noir-lang/noir/commit/ec75e8ec59e0f2a2169aea67372411ede4074d09)) +* Remove sha256 opcode (https://github.com/AztecProtocol/aztec-packages/pull/4571) ([e8bbce7](https://github.com/noir-lang/noir/commit/e8bbce71fde3fc7af410c30920c2a547389d8248)) +* Removing superfluous call to MSM (https://github.com/AztecProtocol/aztec-packages/pull/7708) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Report gates and VKs of private protocol circuits with megahonk (https://github.com/AztecProtocol/aztec-packages/pull/7722) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Simplify constant calls to `poseidon2_permutation`, `schnorr_verify` and `embedded_curve_add` ([#5140](https://github.com/noir-lang/noir/issues/5140)) ([2823ba7](https://github.com/noir-lang/noir/commit/2823ba7242db788ca1d7f6e7a48be2f1de62f278)) +* Small optimization in toradix (https://github.com/AztecProtocol/aztec-packages/pull/8040) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7432) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7444) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7454) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7512) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7577) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7583) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7743) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7862) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7945) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7958) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8008) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8093) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8125) ([f0c2686](https://github.com/noir-lang/noir/commit/f0c268606a71381ab4504396695a0adb9b3258b6)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8237) ([f0c2686](https://github.com/noir-lang/noir/commit/f0c268606a71381ab4504396695a0adb9b3258b6)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8423) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8435) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8466) ([3c3ed1e](https://github.com/noir-lang/noir/commit/3c3ed1e3d28946a02071c524dd128afe131bc3da)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8482) ([d4832ec](https://github.com/noir-lang/noir/commit/d4832ece9d3ad16544afea49cc7caf40501a2cc3)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8512) ([95e19ab](https://github.com/noir-lang/noir/commit/95e19ab9486ad054241b6e53e40e55bdba9dc7e5)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8526) ([95e19ab](https://github.com/noir-lang/noir/commit/95e19ab9486ad054241b6e53e40e55bdba9dc7e5)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/8934) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/9034) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/9099) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/9275) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* **test:** Fuzz test poseidon2 hash equivalence ([#6265](https://github.com/noir-lang/noir/issues/6265)) ([f61ba03](https://github.com/noir-lang/noir/commit/f61ba037c6726e19be4f894d9447fe396df95417)) +* **test:** Fuzz test stdlib hash functions ([#6233](https://github.com/noir-lang/noir/issues/6233)) ([1a2ca46](https://github.com/noir-lang/noir/commit/1a2ca46af0d1c05813dbe28670a2bc39b79e4c9f)) +* TXE nr deployments, dependency cleanup for CLI (https://github.com/AztecProtocol/aztec-packages/pull/7548) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Typing return values of embedded_curve_ops (https://github.com/AztecProtocol/aztec-packages/pull/7413) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* Unify all acir recursion constraints based on RecursionConstraint and proof_type (https://github.com/AztecProtocol/aztec-packages/pull/7993) ([5c4f19f](https://github.com/noir-lang/noir/commit/5c4f19f097dd3704522996330c961bf0a2db8d99)) + + +### Bug Fixes + +* Add trailing extra arguments for backend in gates_flamegraph (https://github.com/AztecProtocol/aztec-packages/pull/7472) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* **debugger:** Update the debugger to handle the new Brillig debug metadata format ([#5706](https://github.com/noir-lang/noir/issues/5706)) ([a31f82e](https://github.com/noir-lang/noir/commit/a31f82e598def60d00c65b79b8c5411f8aa832aa)) +* Deflatten databus visibilities (https://github.com/AztecProtocol/aztec-packages/pull/7761) ([4ea25db](https://github.com/noir-lang/noir/commit/4ea25dbde87488e758139619a3ce4edf93c6ebd6)) +* Discard optimisation that would change execution ordering or that is related to call outputs ([#6461](https://github.com/noir-lang/noir/issues/6461)) ([b8654f7](https://github.com/noir-lang/noir/commit/b8654f700b218cc09c5381af65df11ead9ffcdaf)) +* Display every bit in integer tokens ([#6360](https://github.com/noir-lang/noir/issues/6360)) ([b985fdf](https://github.com/noir-lang/noir/commit/b985fdf6e635570b8db3af83d9ec14e7cd749062)) +* Do not duplicate redundant Brillig debug metadata ([#5696](https://github.com/noir-lang/noir/issues/5696)) ([e4f7dbe](https://github.com/noir-lang/noir/commit/e4f7dbe63b55807b3ff0b4d6f47a8b7f847299fb)) +* Export brillig names in contract functions (https://github.com/AztecProtocol/aztec-packages/pull/8212) ([f0c2686](https://github.com/noir-lang/noir/commit/f0c268606a71381ab4504396695a0adb9b3258b6)) +* Handle multiple entry points for Brillig call stack resolution after metadata deduplication ([#5788](https://github.com/noir-lang/noir/issues/5788)) ([38fe9dd](https://github.com/noir-lang/noir/commit/38fe9dda111952fdb894df90a319c087382edfc9)) +* Homogeneous input points for EC ADD ([#6241](https://github.com/noir-lang/noir/issues/6241)) ([f6a7306](https://github.com/noir-lang/noir/commit/f6a7306436ea1a37ec7f3b884721b50467e9a063)) +* Reject invalid expression with in CLI parser ([#6287](https://github.com/noir-lang/noir/issues/6287)) ([052aee8](https://github.com/noir-lang/noir/commit/052aee80ff3e1e4fd2ca45310d7bb8b980af126a)) +* Remove need for duplicate attributes on each function (https://github.com/AztecProtocol/aztec-packages/pull/9244) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Restrict keccak256_injective test input to 8 bits ([#5977](https://github.com/noir-lang/noir/issues/5977)) ([a1b1346](https://github.com/noir-lang/noir/commit/a1b1346bf7525c508fd390393c307475cc2345d7)) +* Revert "feat: Sync from noir (https://github.com/AztecProtocol/aztec-packages/pull/7512)" (https://github.com/AztecProtocol/aztec-packages/pull/7558) ([daad75c](https://github.com/noir-lang/noir/commit/daad75c26d19ae707b90a7424b77dab9937e8575)) +* **tests:** Prevent EOF error while running test programs ([#6455](https://github.com/noir-lang/noir/issues/6455)) ([358e381](https://github.com/noir-lang/noir/commit/358e38107edbc4f40c97b88196456d82f5557e3f)) + + +### Miscellaneous Chores + +* Remove keccak256 opcode from ACIR/Brillig (https://github.com/AztecProtocol/aztec-packages/pull/9104) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Remove noir_js_backend_barretenberg (https://github.com/AztecProtocol/aztec-packages/pull/9338) ([3925228](https://github.com/noir-lang/noir/commit/392522880e102e275ebcf42f16651a8ffa0bbbd2)) +* Remove pedersen commitment (https://github.com/AztecProtocol/aztec-packages/pull/9107) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Remove pedersen hash opcode (https://github.com/AztecProtocol/aztec-packages/pull/9245) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) +* Replace usage of vector in keccakf1600 input with array (https://github.com/AztecProtocol/aztec-packages/pull/9350) ([3925228](https://github.com/noir-lang/noir/commit/392522880e102e275ebcf42f16651a8ffa0bbbd2)) +* Use Brillig opcode when possible for less-than operations on fields (https://github.com/AztecProtocol/aztec-packages/pull/9416) ([321a493](https://github.com/noir-lang/noir/commit/321a493216e19a2f077007c3447a3030db0df0d0)) + + +### Code Refactoring + +* **avm:** Remove CMOV opcode (https://github.com/AztecProtocol/aztec-packages/pull/9030) ([70dcf4a](https://github.com/noir-lang/noir/commit/70dcf4a25dcad10daeb427f0887d3a0bf10c9916)) + ## [0.53.0](https://github.com/noir-lang/noir/compare/v0.52.0...v0.53.0) (2024-10-31) diff --git a/noir/noir-repo/acvm-repo/acir/Cargo.toml b/noir/noir-repo/acvm-repo/acir/Cargo.toml index 2d164e3a9835..ff6c9b1954e5 100644 --- a/noir/noir-repo/acvm-repo/acir/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acir/Cargo.toml @@ -2,7 +2,7 @@ name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acir_field/Cargo.toml b/noir/noir-repo/acvm-repo/acir_field/Cargo.toml index a8e7f34a374d..66a01848a545 100644 --- a/noir/noir-repo/acvm-repo/acir_field/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acir_field/Cargo.toml @@ -2,7 +2,7 @@ name = "acir_field" description = "The field implementation being used by ACIR." # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm/Cargo.toml b/noir/noir-repo/acvm-repo/acvm/Cargo.toml index 145c07a4a004..2b143ebe4752 100644 --- a/noir/noir-repo/acvm-repo/acvm/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acvm/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs b/noir/noir-repo/acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs index 7c0be0fc3fe6..a5258a494a26 100644 --- a/noir/noir-repo/acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs +++ b/noir/noir-repo/acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs @@ -1,7 +1,12 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use acir::{ - circuit::{brillig::BrilligInputs, directives::Directive, opcodes::BlockId, Circuit, Opcode}, + circuit::{ + brillig::{BrilligInputs, BrilligOutputs}, + directives::Directive, + opcodes::BlockId, + Circuit, Opcode, + }, native_types::{Expression, Witness}, AcirField, }; @@ -72,23 +77,31 @@ impl MergeExpressionsOptimizer { if let (Opcode::AssertZero(expr_define), Opcode::AssertZero(expr_use)) = (opcode.clone(), second_gate) { - if let Some(expr) = Self::merge(&expr_use, &expr_define, w) { - // sanity check - assert!(i < b); - modified_gates.insert(b, Opcode::AssertZero(expr)); - to_keep = false; - // Update the 'used_witness' map to account for the merge. - for w2 in CircuitSimulator::expr_wit(&expr_define) { - if !circuit_inputs.contains(&w2) { - let mut v = used_witness[&w2].clone(); - v.insert(b); - v.remove(&i); - used_witness.insert(w2, v); + // We cannot merge an expression into an earlier opcode, because this + // would break the 'execution ordering' of the opcodes + // This case can happen because a previous merge would change an opcode + // and eliminate a witness from it, giving new opportunities for this + // witness to be used in only two expressions + // TODO: the missed optimization for the i>b case can be handled by + // - doing this pass again until there is no change, or + // - merging 'b' into 'i' instead + if i < b { + if let Some(expr) = Self::merge(&expr_use, &expr_define, w) { + modified_gates.insert(b, Opcode::AssertZero(expr)); + to_keep = false; + // Update the 'used_witness' map to account for the merge. + for w2 in CircuitSimulator::expr_wit(&expr_define) { + if !circuit_inputs.contains(&w2) { + let mut v = used_witness[&w2].clone(); + v.insert(b); + v.remove(&i); + used_witness.insert(w2, v); + } } + // We need to stop here and continue with the next opcode + // because the merge invalidates the current opcode. + break; } - // We need to stop here and continue with the next opcode - // because the merge invalidate the current opcode - break; } } } @@ -125,6 +138,19 @@ impl MergeExpressionsOptimizer { result } + fn brillig_output_wit(&self, output: &BrilligOutputs) -> BTreeSet { + let mut result = BTreeSet::new(); + match output { + BrilligOutputs::Simple(witness) => { + result.insert(*witness); + } + BrilligOutputs::Array(witnesses) => { + result.extend(witnesses); + } + } + result + } + // Returns the input witnesses used by the opcode fn witness_inputs(&self, opcode: &Opcode) -> BTreeSet { let mut witnesses = BTreeSet::new(); @@ -146,16 +172,22 @@ impl MergeExpressionsOptimizer { Opcode::MemoryInit { block_id: _, init, block_type: _ } => { init.iter().cloned().collect() } - Opcode::BrilligCall { inputs, .. } => { + Opcode::BrilligCall { inputs, outputs, .. } => { for i in inputs { witnesses.extend(self.brillig_input_wit(i)); } + for i in outputs { + witnesses.extend(self.brillig_output_wit(i)); + } witnesses } - Opcode::Call { id: _, inputs, outputs: _, predicate } => { + Opcode::Call { id: _, inputs, outputs, predicate } => { for i in inputs { witnesses.insert(*i); } + for i in outputs { + witnesses.insert(*i); + } if let Some(p) = predicate { witnesses.extend(CircuitSimulator::expr_wit(p)); } @@ -195,3 +227,127 @@ impl MergeExpressionsOptimizer { None } } + +#[cfg(test)] +mod tests { + use crate::compiler::{optimizers::MergeExpressionsOptimizer, CircuitSimulator}; + use acir::{ + acir_field::AcirField, + circuit::{ + brillig::{BrilligFunctionId, BrilligOutputs}, + opcodes::FunctionInput, + Circuit, ExpressionWidth, Opcode, PublicInputs, + }, + native_types::{Expression, Witness}, + FieldElement, + }; + use std::collections::BTreeSet; + + fn check_circuit(circuit: Circuit) { + assert!(CircuitSimulator::default().check_circuit(&circuit)); + let mut merge_optimizer = MergeExpressionsOptimizer::new(); + let acir_opcode_positions = vec![0; 20]; + let (opcodes, _) = + merge_optimizer.eliminate_intermediate_variable(&circuit, acir_opcode_positions); + let mut optimized_circuit = circuit; + optimized_circuit.opcodes = opcodes; + // check that the circuit is still valid after optimization + assert!(CircuitSimulator::default().check_circuit(&optimized_circuit)); + } + + #[test] + fn does_not_eliminate_witnesses_returned_from_brillig() { + let opcodes = vec![ + Opcode::BrilligCall { + id: BrilligFunctionId::default(), + inputs: Vec::new(), + outputs: vec![BrilligOutputs::Simple(Witness(1))], + predicate: None, + }, + Opcode::AssertZero(Expression { + mul_terms: Vec::new(), + linear_combinations: vec![ + (FieldElement::from(2_u128), Witness(0)), + (FieldElement::from(3_u128), Witness(1)), + (FieldElement::from(1_u128), Witness(2)), + ], + q_c: FieldElement::one(), + }), + Opcode::AssertZero(Expression { + mul_terms: Vec::new(), + linear_combinations: vec![ + (FieldElement::from(2_u128), Witness(0)), + (FieldElement::from(2_u128), Witness(1)), + (FieldElement::from(1_u128), Witness(5)), + ], + q_c: FieldElement::one(), + }), + ]; + + let mut private_parameters = BTreeSet::new(); + private_parameters.insert(Witness(0)); + + let circuit = Circuit { + current_witness_index: 1, + expression_width: ExpressionWidth::Bounded { width: 4 }, + opcodes, + private_parameters, + public_parameters: PublicInputs::default(), + return_values: PublicInputs::default(), + assert_messages: Default::default(), + }; + check_circuit(circuit); + } + + #[test] + fn does_not_attempt_to_merge_into_previous_opcodes() { + let opcodes = vec![ + Opcode::AssertZero(Expression { + mul_terms: vec![(FieldElement::one(), Witness(0), Witness(0))], + linear_combinations: vec![(-FieldElement::one(), Witness(4))], + q_c: FieldElement::zero(), + }), + Opcode::AssertZero(Expression { + mul_terms: vec![(FieldElement::one(), Witness(0), Witness(1))], + linear_combinations: vec![(FieldElement::one(), Witness(5))], + q_c: FieldElement::zero(), + }), + Opcode::AssertZero(Expression { + mul_terms: Vec::new(), + linear_combinations: vec![ + (-FieldElement::one(), Witness(2)), + (FieldElement::one(), Witness(4)), + (FieldElement::one(), Witness(5)), + ], + q_c: FieldElement::zero(), + }), + Opcode::AssertZero(Expression { + mul_terms: Vec::new(), + linear_combinations: vec![ + (FieldElement::one(), Witness(2)), + (-FieldElement::one(), Witness(3)), + (FieldElement::one(), Witness(4)), + (FieldElement::one(), Witness(5)), + ], + q_c: FieldElement::zero(), + }), + Opcode::BlackBoxFuncCall(acir::circuit::opcodes::BlackBoxFuncCall::RANGE { + input: FunctionInput::witness(Witness(3), 32), + }), + ]; + + let mut private_parameters = BTreeSet::new(); + private_parameters.insert(Witness(0)); + private_parameters.insert(Witness(1)); + let circuit = Circuit { + current_witness_index: 5, + expression_width: ExpressionWidth::Bounded { width: 4 }, + opcodes, + private_parameters, + public_parameters: PublicInputs::default(), + return_values: PublicInputs::default(), + assert_messages: Default::default(), + }; + check_circuit(circuit); + } +} diff --git a/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml b/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml index 0e5fdf8b5c78..db34458ad880 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml +++ b/noir/noir-repo/acvm-repo/acvm_js/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_js" description = "Typescript wrapper around the ACVM allowing execution of ACIR code" # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/acvm_js/package.json b/noir/noir-repo/acvm-repo/acvm_js/package.json index 163ea5531696..b68aa0230869 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/package.json +++ b/noir/noir-repo/acvm-repo/acvm_js/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/acvm_js", - "version": "0.53.0", + "version": "0.54.0", "publishConfig": { "access": "public" }, diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml b/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml index 4c341a42a049..944b17c7dc67 100644 --- a/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml +++ b/noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml index 97f6b76a9a3e..7541fe239c9d 100644 --- a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml +++ b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "bn254_blackbox_solver" description = "Solvers for black box functions which are specific for the bn254 curve" # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true @@ -19,10 +19,10 @@ workspace = true acir.workspace = true acvm_blackbox_solver.workspace = true hex.workspace = true -lazy_static = "1.4" +lazy_static.workspace = true ark-bn254.workspace = true -grumpkin.workspace = true +grumpkin.workspace = true ark-ec.workspace = true ark-ff.workspace = true num-bigint.workspace = true diff --git a/noir/noir-repo/acvm-repo/brillig/Cargo.toml b/noir/noir-repo/acvm-repo/brillig/Cargo.toml index c0e50150b78c..7b48ff318d3e 100644 --- a/noir/noir-repo/acvm-repo/brillig/Cargo.toml +++ b/noir/noir-repo/acvm-repo/brillig/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml b/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml index 3cfedd1a1fb8..a9cb409a6f42 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml +++ b/noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" # x-release-please-start-version -version = "0.53.0" +version = "0.54.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/noir-repo/compiler/noirc_driver/src/abi_gen.rs b/noir/noir-repo/compiler/noirc_driver/src/abi_gen.rs index bf64c9c920c7..625a35c8d154 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/abi_gen.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/abi_gen.rs @@ -6,6 +6,7 @@ use iter_extended::vecmap; use noirc_abi::{ Abi, AbiErrorType, AbiParameter, AbiReturnType, AbiType, AbiValue, AbiVisibility, Sign, }; +use noirc_errors::Span; use noirc_evaluator::ErrorType; use noirc_frontend::ast::{Signedness, Visibility}; use noirc_frontend::TypeBinding; @@ -40,11 +41,21 @@ pub(super) fn gen_abi( Abi { parameters, return_type, error_types } } +// Get the Span of the root crate's main function, or else a dummy span if that fails +fn get_main_function_span(context: &Context) -> Span { + if let Some(func_id) = context.get_main_function(context.root_crate_id()) { + context.function_meta(&func_id).location.span + } else { + Span::default() + } +} + fn build_abi_error_type(context: &Context, typ: ErrorType) -> AbiErrorType { match typ { ErrorType::Dynamic(typ) => { if let Type::FmtString(len, item_types) = typ { - let length = len.evaluate_to_u32().expect("Cannot evaluate fmt length"); + let span = get_main_function_span(context); + let length = len.evaluate_to_u32(span).expect("Cannot evaluate fmt length"); let Type::Tuple(item_types) = item_types.as_ref() else { unreachable!("FmtString items must be a tuple") }; @@ -63,8 +74,9 @@ pub(super) fn abi_type_from_hir_type(context: &Context, typ: &Type) -> AbiType { match typ { Type::FieldElement => AbiType::Field, Type::Array(size, typ) => { + let span = get_main_function_span(context); let length = size - .evaluate_to_u32() + .evaluate_to_u32(span) .expect("Cannot have variable sized arrays as a parameter to main"); let typ = typ.as_ref(); AbiType::Array { length, typ: Box::new(abi_type_from_hir_type(context, typ)) } @@ -91,8 +103,9 @@ pub(super) fn abi_type_from_hir_type(context: &Context, typ: &Type) -> AbiType { } Type::Bool => AbiType::Boolean, Type::String(size) => { + let span = get_main_function_span(context); let size = size - .evaluate_to_u32() + .evaluate_to_u32(span) .expect("Cannot have variable sized strings as a parameter to main"); AbiType::String { length: size } } @@ -107,6 +120,7 @@ pub(super) fn abi_type_from_hir_type(context: &Context, typ: &Type) -> AbiType { AbiType::Struct { fields, path } } Type::Alias(def, args) => abi_type_from_hir_type(context, &def.borrow().get_type(args)), + Type::CheckedCast { to, .. } => abi_type_from_hir_type(context, to), Type::Tuple(fields) => { let fields = vecmap(fields, |typ| abi_type_from_hir_type(context, typ)); AbiType::Tuple { fields } diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index c4e2491a5fe6..d10029d81e62 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -456,9 +456,8 @@ fn compile_contract_inner( .secondary .iter() .filter_map(|attr| match attr { - SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute) => { - Some(attribute.contents.clone()) - } + SecondaryAttribute::Tag(attribute) => Some(attribute.contents.clone()), + SecondaryAttribute::Meta(attribute) => Some(attribute.to_string()), _ => None, }) .collect(); diff --git a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml index 1db6af2ae85a..aac07339dd6f 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml @@ -20,6 +20,7 @@ fxhash.workspace = true iter-extended.workspace = true thiserror.workspace = true num-bigint = "0.4" +num-traits.workspace = true im.workspace = true serde.workspace = true serde_json.workspace = true @@ -31,7 +32,8 @@ cfg-if.workspace = true [dev-dependencies] proptest.workspace = true +similar-asserts.workspace = true [features] bn254 = ["noirc_frontend/bn254"] -bls12_381= [] +bls12_381 = [] diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index 48914c6219de..40224e132ab8 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -2,6 +2,7 @@ use crate::brillig::brillig_ir::artifact::Label; use crate::brillig::brillig_ir::brillig_variable::{ type_to_heap_value_type, BrilligArray, BrilligVariable, SingleAddrVariable, }; + use crate::brillig::brillig_ir::registers::Stack; use crate::brillig::brillig_ir::{ BrilligBinaryOp, BrilligContext, ReservedRegisters, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, @@ -1202,7 +1203,7 @@ impl<'block> BrilligBlock<'block> { let brillig_binary_op = match binary.operator { BinaryOp::Div => { if is_signed { - self.convert_signed_division(left, right, result_variable); + self.brillig_context.convert_signed_division(left, right, result_variable); return; } else if is_field { BrilligBinaryOp::FieldDiv @@ -1234,7 +1235,14 @@ impl<'block> BrilligBlock<'block> { BinaryOp::Or => BrilligBinaryOp::Or, BinaryOp::Xor => BrilligBinaryOp::Xor, BinaryOp::Shl => BrilligBinaryOp::Shl, - BinaryOp::Shr => BrilligBinaryOp::Shr, + BinaryOp::Shr => { + if is_signed { + self.convert_signed_shr(left, right, result_variable); + return; + } else { + BrilligBinaryOp::Shr + } + } }; self.brillig_context.binary_instruction(left, right, result_variable, brillig_binary_op); @@ -1250,98 +1258,6 @@ impl<'block> BrilligBlock<'block> { ); } - /// Splits a two's complement signed integer in the sign bit and the absolute value. - /// For example, -6 i8 (11111010) is split to 00000110 (6, absolute value) and 1 (is_negative). - fn absolute_value( - &mut self, - num: SingleAddrVariable, - absolute_value: SingleAddrVariable, - result_is_negative: SingleAddrVariable, - ) { - let max_positive = self - .brillig_context - .make_constant_instruction(((1_u128 << (num.bit_size - 1)) - 1).into(), num.bit_size); - - // Compute if num is negative - self.brillig_context.binary_instruction( - max_positive, - num, - result_is_negative, - BrilligBinaryOp::LessThan, - ); - - // Two's complement of num - let zero = self.brillig_context.make_constant_instruction(0_usize.into(), num.bit_size); - let twos_complement = - SingleAddrVariable::new(self.brillig_context.allocate_register(), num.bit_size); - self.brillig_context.binary_instruction(zero, num, twos_complement, BrilligBinaryOp::Sub); - - // absolute_value = result_is_negative ? twos_complement : num - self.brillig_context.codegen_branch(result_is_negative.address, |ctx, is_negative| { - if is_negative { - ctx.mov_instruction(absolute_value.address, twos_complement.address); - } else { - ctx.mov_instruction(absolute_value.address, num.address); - } - }); - - self.brillig_context.deallocate_single_addr(zero); - self.brillig_context.deallocate_single_addr(max_positive); - self.brillig_context.deallocate_single_addr(twos_complement); - } - - fn convert_signed_division( - &mut self, - left: SingleAddrVariable, - right: SingleAddrVariable, - result: SingleAddrVariable, - ) { - let left_is_negative = SingleAddrVariable::new(self.brillig_context.allocate_register(), 1); - let left_abs_value = - SingleAddrVariable::new(self.brillig_context.allocate_register(), left.bit_size); - - let right_is_negative = - SingleAddrVariable::new(self.brillig_context.allocate_register(), 1); - let right_abs_value = - SingleAddrVariable::new(self.brillig_context.allocate_register(), right.bit_size); - - let result_is_negative = - SingleAddrVariable::new(self.brillig_context.allocate_register(), 1); - - // Compute both absolute values - self.absolute_value(left, left_abs_value, left_is_negative); - self.absolute_value(right, right_abs_value, right_is_negative); - - // Perform the division on the absolute values - self.brillig_context.binary_instruction( - left_abs_value, - right_abs_value, - result, - BrilligBinaryOp::UnsignedDiv, - ); - - // Compute result sign - self.brillig_context.binary_instruction( - left_is_negative, - right_is_negative, - result_is_negative, - BrilligBinaryOp::Xor, - ); - - // If result has to be negative, perform two's complement - self.brillig_context.codegen_if(result_is_negative.address, |ctx| { - let zero = ctx.make_constant_instruction(0_usize.into(), result.bit_size); - ctx.binary_instruction(zero, result, result, BrilligBinaryOp::Sub); - ctx.deallocate_single_addr(zero); - }); - - self.brillig_context.deallocate_single_addr(left_is_negative); - self.brillig_context.deallocate_single_addr(left_abs_value); - self.brillig_context.deallocate_single_addr(right_is_negative); - self.brillig_context.deallocate_single_addr(right_abs_value); - self.brillig_context.deallocate_single_addr(result_is_negative); - } - fn convert_signed_modulo( &mut self, left: SingleAddrVariable, @@ -1354,7 +1270,7 @@ impl<'block> BrilligBlock<'block> { SingleAddrVariable::new(self.brillig_context.allocate_register(), left.bit_size); // i = left / right - self.convert_signed_division(left, right, scratch_var_i); + self.brillig_context.convert_signed_division(left, right, scratch_var_i); // j = i * right self.brillig_context.binary_instruction( @@ -1401,6 +1317,56 @@ impl<'block> BrilligBlock<'block> { self.brillig_context.deallocate_single_addr(bias); } + fn convert_signed_shr( + &mut self, + left: SingleAddrVariable, + right: SingleAddrVariable, + result: SingleAddrVariable, + ) { + // Check if left is negative + let left_is_negative = SingleAddrVariable::new(self.brillig_context.allocate_register(), 1); + let max_positive = self + .brillig_context + .make_constant_instruction(((1_u128 << (left.bit_size - 1)) - 1).into(), left.bit_size); + self.brillig_context.binary_instruction( + max_positive, + left, + left_is_negative, + BrilligBinaryOp::LessThan, + ); + + self.brillig_context.codegen_branch(left_is_negative.address, |ctx, is_negative| { + if is_negative { + let one = ctx.make_constant_instruction(1_u128.into(), left.bit_size); + + // computes 2^right + let two = ctx.make_constant_instruction(2_u128.into(), left.bit_size); + let two_pow = ctx.make_constant_instruction(1_u128.into(), left.bit_size); + let right_u32 = SingleAddrVariable::new(ctx.allocate_register(), 32); + ctx.cast(right_u32, right); + let pow_body = |ctx: &mut BrilligContext<_, _>, _: SingleAddrVariable| { + ctx.binary_instruction(two_pow, two, two_pow, BrilligBinaryOp::Mul); + }; + ctx.codegen_for_loop(None, right_u32.address, None, pow_body); + + // Right shift using division on 1-complement + ctx.binary_instruction(left, one, result, BrilligBinaryOp::Add); + ctx.convert_signed_division(result, two_pow, result); + ctx.binary_instruction(result, one, result, BrilligBinaryOp::Sub); + + // Clean-up + ctx.deallocate_single_addr(one); + ctx.deallocate_single_addr(two); + ctx.deallocate_single_addr(two_pow); + ctx.deallocate_single_addr(right_u32); + } else { + ctx.binary_instruction(left, right, result, BrilligBinaryOp::Shr); + } + }); + + self.brillig_context.deallocate_single_addr(left_is_negative); + } + #[allow(clippy::too_many_arguments)] fn add_overflow_check( &mut self, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs index fc2746a7b532..d5529c00d6ca 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs @@ -73,8 +73,6 @@ pub(crate) fn directive_invert() -> GeneratedBrillig { return_data: HeapVector { pointer: zero_usize, size: one_usize }, }, ], - error_types: Default::default(), - locations: Default::default(), name: "directive_invert".to_string(), ..Default::default() } @@ -144,8 +142,6 @@ pub(crate) fn directive_quotient() -> GeneratedBrillig { }, }, ], - error_types: Default::default(), - locations: Default::default(), name: "directive_integer_quotient".to_string(), ..Default::default() } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs index c062ede3316f..b4e10035af6d 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs @@ -25,6 +25,7 @@ mod entry_point; mod instructions; use artifact::Label; +use brillig_variable::SingleAddrVariable; pub(crate) use instructions::BrilligBinaryOp; use registers::{RegisterAllocator, ScratchSpace}; @@ -109,6 +110,87 @@ impl BrilligContext { can_call_procedures: true, } } + + /// Splits a two's complement signed integer in the sign bit and the absolute value. + /// For example, -6 i8 (11111010) is split to 00000110 (6, absolute value) and 1 (is_negative). + pub(crate) fn absolute_value( + &mut self, + num: SingleAddrVariable, + absolute_value: SingleAddrVariable, + result_is_negative: SingleAddrVariable, + ) { + let max_positive = self + .make_constant_instruction(((1_u128 << (num.bit_size - 1)) - 1).into(), num.bit_size); + + // Compute if num is negative + self.binary_instruction(max_positive, num, result_is_negative, BrilligBinaryOp::LessThan); + + // Two's complement of num + let zero = self.make_constant_instruction(0_usize.into(), num.bit_size); + let twos_complement = SingleAddrVariable::new(self.allocate_register(), num.bit_size); + self.binary_instruction(zero, num, twos_complement, BrilligBinaryOp::Sub); + + // absolute_value = result_is_negative ? twos_complement : num + self.codegen_branch(result_is_negative.address, |ctx, is_negative| { + if is_negative { + ctx.mov_instruction(absolute_value.address, twos_complement.address); + } else { + ctx.mov_instruction(absolute_value.address, num.address); + } + }); + + self.deallocate_single_addr(zero); + self.deallocate_single_addr(max_positive); + self.deallocate_single_addr(twos_complement); + } + + pub(crate) fn convert_signed_division( + &mut self, + left: SingleAddrVariable, + right: SingleAddrVariable, + result: SingleAddrVariable, + ) { + let left_is_negative = SingleAddrVariable::new(self.allocate_register(), 1); + let left_abs_value = SingleAddrVariable::new(self.allocate_register(), left.bit_size); + + let right_is_negative = SingleAddrVariable::new(self.allocate_register(), 1); + let right_abs_value = SingleAddrVariable::new(self.allocate_register(), right.bit_size); + + let result_is_negative = SingleAddrVariable::new(self.allocate_register(), 1); + + // Compute both absolute values + self.absolute_value(left, left_abs_value, left_is_negative); + self.absolute_value(right, right_abs_value, right_is_negative); + + // Perform the division on the absolute values + self.binary_instruction( + left_abs_value, + right_abs_value, + result, + BrilligBinaryOp::UnsignedDiv, + ); + + // Compute result sign + self.binary_instruction( + left_is_negative, + right_is_negative, + result_is_negative, + BrilligBinaryOp::Xor, + ); + + // If result has to be negative, perform two's complement + self.codegen_if(result_is_negative.address, |ctx| { + let zero = ctx.make_constant_instruction(0_usize.into(), result.bit_size); + ctx.binary_instruction(zero, result, result, BrilligBinaryOp::Sub); + ctx.deallocate_single_addr(zero); + }); + + self.deallocate_single_addr(left_is_negative); + self.deallocate_single_addr(left_abs_value); + self.deallocate_single_addr(right_is_negative); + self.deallocate_single_addr(right_abs_value); + self.deallocate_single_addr(result_is_negative); + } } /// Special brillig context to codegen compiler intrinsic shared procedures diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_control_flow.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_control_flow.rs index 77661fba3a17..9512a60e6998 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_control_flow.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_control_flow.rs @@ -6,7 +6,7 @@ use acvm::{ AcirField, }; -use crate::ErrorType; +use crate::ssa::ir::instruction::ErrorType; use super::{ artifact::BrilligParameter, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/mod.rs index 1678268d3431..2fa51f3db59c 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/mod.rs @@ -18,6 +18,7 @@ use noirc_errors::debug_info::ProcedureDebugId; use prepare_vector_insert::compile_prepare_vector_insert_procedure; use prepare_vector_push::compile_prepare_vector_push_procedure; use revert_with_string::compile_revert_with_string_procedure; +use serde::{Deserialize, Serialize}; use vector_copy::compile_vector_copy_procedure; use vector_pop_back::compile_vector_pop_back_procedure; use vector_pop_front::compile_vector_pop_front_procedure; @@ -34,7 +35,7 @@ use super::{ /// Procedures are a set of complex operations that are common in the noir language. /// Extracting them to reusable procedures allows us to reduce the size of the generated Brillig. /// Procedures receive their arguments on scratch space to avoid stack dumping&restoring. -#[derive(Debug, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord, Deserialize, Serialize)] pub enum ProcedureId { ArrayCopy, ArrayReverse, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs index 3fddd9da0564..b2b4762723f0 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs @@ -14,3 +14,21 @@ pub mod brillig; pub use ssa::create_program; pub use ssa::ir::instruction::ErrorType; + +/// Trims leading whitespace from each line of the input string, according to +/// how much leading whitespace there is on the first non-empty line. +#[cfg(test)] +pub(crate) fn trim_leading_whitespace_from_lines(src: &str) -> String { + let mut lines = src.trim_end().lines(); + let mut first_line = lines.next().unwrap(); + while first_line.is_empty() { + first_line = lines.next().unwrap(); + } + let indent = first_line.len() - first_line.trim_start().len(); + let mut result = first_line.trim_start().to_string(); + for line in lines { + result.push('\n'); + result.push_str(&line[indent..]); + } + result +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs index 67d7ad70cbc3..5e2c0f0827d1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs @@ -43,6 +43,7 @@ mod checks; pub(super) mod function_builder; pub mod ir; mod opt; +mod parser; pub mod ssa_gen; pub struct SsaEvaluatorOptions { @@ -370,8 +371,8 @@ fn split_public_and_private_inputs( func_sig .0 .iter() - .map(|(_, typ, visibility)| { - let num_field_elements_needed = typ.field_count() as usize; + .map(|(pattern, typ, visibility)| { + let num_field_elements_needed = typ.field_count(&pattern.location()) as usize; let witnesses = input_witnesses[idx..idx + num_field_elements_needed].to_vec(); idx += num_field_elements_needed; (visibility, witnesses) diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index b32d6d11f035..ecf7561321ff 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -1009,13 +1009,13 @@ impl<'a> Context<'a> { }; entry_point.link_with(artifact); // Insert the range of opcode locations occupied by a procedure - if let Some(procedure_id) = artifact.procedure.clone() { + if let Some(procedure_id) = &artifact.procedure { let num_opcodes = entry_point.byte_code.len(); let previous_num_opcodes = entry_point.byte_code.len() - artifact.byte_code.len(); // We subtract one as to keep the range inclusive on both ends entry_point .procedure_locations - .insert(procedure_id, (previous_num_opcodes, num_opcodes - 1)); + .insert(procedure_id.clone(), (previous_num_opcodes, num_opcodes - 1)); } } // Generate the final bytecode diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs index de9ae8a24d7e..5a62e9c8e9ad 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs @@ -48,7 +48,7 @@ impl DataBusBuilder { ast::Visibility::CallData(id) => DatabusVisibility::CallData(id), ast::Visibility::ReturnData => DatabusVisibility::ReturnData, }; - let len = param.1.field_count() as usize; + let len = param.1.field_count(¶m.0.location()) as usize; params_is_databus.extend(vec![is_databus; len]); } params_is_databus diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 7b39f7041e45..63a9453a4306 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -328,6 +328,16 @@ impl FunctionBuilder { .first() } + pub(crate) fn insert_mutable_array_set( + &mut self, + array: ValueId, + index: ValueId, + value: ValueId, + ) -> ValueId { + self.insert_instruction(Instruction::ArraySet { array, index, value, mutable: true }, None) + .first() + } + /// Insert an instruction to increment an array's reference count. This only has an effect /// in unconstrained code where arrays are reference counted and copy on write. pub(crate) fn insert_inc_rc(&mut self, value: ValueId) { diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index d79916a9e118..2be9ffa9afa8 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -74,8 +74,9 @@ pub(crate) struct DataFlowGraph { blocks: DenseMap, /// Debugging information about which `ValueId`s have had their underlying `Value` substituted - /// for that of another. This information is purely used for printing the SSA, and has no - /// material effect on the SSA itself. + /// for that of another. In theory this information is purely used for printing the SSA, + /// and has no material effect on the SSA itself, however in practice the IDs can get out of + /// sync and may need this resolution before they can be compared. #[serde(skip)] replaced_value_ids: HashMap, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs index 03262be0a061..487370488b9a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs @@ -281,15 +281,7 @@ impl Binary { let zero = dfg.make_constant(FieldElement::zero(), operand_type); return SimplifyResult::SimplifiedTo(zero); } - - // `two_pow_rhs` is limited to be at most `2 ^ {operand_bitsize - 1}` so it fits in `operand_type`. - let two_pow_rhs = FieldElement::from(2u128).pow(&rhs_const); - let two_pow_rhs = dfg.make_constant(two_pow_rhs, operand_type); - return SimplifyResult::SimplifiedToInstruction(Instruction::binary( - BinaryOp::Div, - self.lhs, - two_pow_rhs, - )); + return SimplifyResult::None; } } }; diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/printer.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/printer.rs index 93d69f255c37..3bbe14f866a1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/printer.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/printer.rs @@ -69,9 +69,16 @@ fn value(function: &Function, id: ValueId) -> String { } Value::Function(id) => id.to_string(), Value::Intrinsic(intrinsic) => intrinsic.to_string(), - Value::Array { array, .. } => { + Value::Array { array, typ } => { let elements = vecmap(array, |element| value(function, *element)); - format!("[{}]", elements.join(", ")) + let element_types = &typ.clone().element_types(); + let element_types_str = + element_types.iter().map(|typ| typ.to_string()).collect::>().join(", "); + if element_types.len() == 1 { + format!("[{}] of {}", elements.join(", "), element_types_str) + } else { + format!("[{}] of ({})", elements.join(", "), element_types_str) + } } Value::Param { .. } | Value::Instruction { .. } | Value::ForeignFunction(_) => { id.to_string() @@ -119,7 +126,11 @@ pub(crate) fn display_terminator( ) } Some(TerminatorInstruction::Return { return_values, .. }) => { - writeln!(f, " return {}", value_list(function, return_values)) + if return_values.is_empty() { + writeln!(f, " return") + } else { + writeln!(f, " return {}", value_list(function, return_values)) + } } None => writeln!(f, " (no terminator instruction)"), } @@ -139,12 +150,13 @@ pub(crate) fn display_instruction( write!(f, "{} = ", value_list(function, results))?; } - display_instruction_inner(function, &function.dfg[instruction], f) + display_instruction_inner(function, &function.dfg[instruction], results, f) } fn display_instruction_inner( function: &Function, instruction: &Instruction, + results: &[ValueId], f: &mut Formatter, ) -> Result { let show = |id| value(function, id); @@ -168,10 +180,15 @@ fn display_instruction_inner( } } Instruction::Call { func, arguments } => { - writeln!(f, "call {}({})", show(*func), value_list(function, arguments)) + let arguments = value_list(function, arguments); + writeln!(f, "call {}({}){}", show(*func), arguments, result_types(function, results)) + } + Instruction::Allocate => { + writeln!(f, "allocate{}", result_types(function, results)) + } + Instruction::Load { address } => { + writeln!(f, "load {}{}", show(*address), result_types(function, results)) } - Instruction::Allocate => writeln!(f, "allocate"), - Instruction::Load { address } => writeln!(f, "load {}", show(*address)), Instruction::Store { address, value } => { writeln!(f, "store {} at {}", show(*value), show(*address)) } @@ -179,7 +196,13 @@ fn display_instruction_inner( writeln!(f, "enable_side_effects {}", show(*condition)) } Instruction::ArrayGet { array, index } => { - writeln!(f, "array_get {}, index {}", show(*array), show(*index)) + writeln!( + f, + "array_get {}, index {}{}", + show(*array), + show(*index), + result_types(function, results) + ) } Instruction::ArraySet { array, index, value, mutable } => { let array = show(*array); @@ -210,6 +233,17 @@ fn display_instruction_inner( } } +fn result_types(function: &Function, results: &[ValueId]) -> String { + let types = vecmap(results, |result| function.dfg.type_of_value(*result).to_string()); + if types.is_empty() { + String::new() + } else if types.len() == 1 { + format!(" -> {}", types[0]) + } else { + format!(" -> ({})", types.join(", ")) + } +} + /// Tries to extract a constant string from an error payload. pub(crate) fn try_to_extract_string_from_error_payload( is_string_type: bool, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/types.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/types.rs index b7ee37ba17af..130f1d59e46f 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/types.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/types.rs @@ -204,6 +204,17 @@ impl Type { Type::Slice(element_types) | Type::Array(element_types, _) => element_types[0].first(), } } + + /// True if this is a reference type or if it is a composite type which contains a reference. + pub(crate) fn contains_reference(&self) -> bool { + match self { + Type::Reference(_) => true, + Type::Numeric(_) | Type::Function => false, + Type::Array(elements, _) | Type::Slice(elements) => { + elements.iter().any(|elem| elem.contains_reference()) + } + } + } } /// Composite Types are essentially flattened struct or tuple types. @@ -218,7 +229,11 @@ impl std::fmt::Display for Type { Type::Reference(element) => write!(f, "&mut {element}"), Type::Array(element, length) => { let elements = vecmap(element.iter(), |element| element.to_string()); - write!(f, "[{}; {length}]", elements.join(", ")) + if elements.len() == 1 { + write!(f, "[{}; {length}]", elements.join(", ")) + } else { + write!(f, "[({}); {length}]", elements.join(", ")) + } } Type::Slice(element) => { let elements = vecmap(element.iter(), |element| element.to_string()); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/array_set.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/array_set.rs index 7035345436e1..ed3accae15a5 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/array_set.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/array_set.rs @@ -186,135 +186,47 @@ fn make_mutable( #[cfg(test)] mod tests { - use std::sync::Arc; - - use im::vector; - use noirc_frontend::monomorphization::ast::InlineType; - - use crate::ssa::{ - function_builder::FunctionBuilder, - ir::{ - function::RuntimeType, - instruction::{BinaryOp, Instruction}, - map::Id, - types::Type, - }, - }; + use crate::ssa::{opt::assert_normalized_ssa_equals, Ssa}; #[test] fn array_set_in_loop_with_conditional_clone() { // We want to make sure that we do not mark a single array set mutable which is loaded // from and cloned in a loop. If the array is inadvertently marked mutable, and is cloned in a previous iteration // of the loop, its clone will also be altered. - // - // brillig fn main f0 { - // b0(): - // v3 = allocate - // store [[Field 0, Field 0, Field 0, Field 0, Field 0], [Field 0, Field 0, Field 0, Field 0, Field 0]] at v3 - // v4 = allocate - // store [[Field 0, Field 0, Field 0, Field 0, Field 0], [Field 0, Field 0, Field 0, Field 0, Field 0]] at v4 - // jmp b1(u32 0) - // b1(v6: u32): - // v8 = lt v6, u32 5 - // jmpif v8 then: b3, else: b2 - // b3(): - // v9 = eq v6, u32 5 - // jmpif v9 then: b4, else: b5 - // b4(): - // v10 = load v3 - // store v10 at v4 - // jmp b5() - // b5(): - // v11 = load v3 - // v13 = array_get v11, index Field 0 - // v14 = array_set v13, index v6, value Field 20 - // v15 = array_set v11, index v6, value v14 - // store v15 at v3 - // v17 = add v6, u32 1 - // jmp b1(v17) - // b2(): - // return - // } - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - builder.set_runtime(RuntimeType::Brillig(InlineType::default())); - - let array_type = Type::Array(Arc::new(vec![Type::field()]), 5); - let zero = builder.field_constant(0u128); - let array_constant = - builder.array_constant(vector![zero, zero, zero, zero, zero], array_type.clone()); - let nested_array_type = Type::Array(Arc::new(vec![array_type.clone()]), 2); - let nested_array_constant = builder - .array_constant(vector![array_constant, array_constant], nested_array_type.clone()); - - let v3 = builder.insert_allocate(array_type.clone()); - - builder.insert_store(v3, nested_array_constant); - - let v4 = builder.insert_allocate(array_type.clone()); - builder.insert_store(v4, nested_array_constant); - - let b1 = builder.insert_block(); - let zero_u32 = builder.numeric_constant(0u128, Type::unsigned(32)); - builder.terminate_with_jmp(b1, vec![zero_u32]); - - // Loop header - builder.switch_to_block(b1); - let v5 = builder.add_block_parameter(b1, Type::unsigned(32)); - let five = builder.numeric_constant(5u128, Type::unsigned(32)); - let v8 = builder.insert_binary(v5, BinaryOp::Lt, five); - - let b2 = builder.insert_block(); - let b3 = builder.insert_block(); - let b4 = builder.insert_block(); - let b5 = builder.insert_block(); - builder.terminate_with_jmpif(v8, b3, b2); - - // Loop body - // b3 is the if statement conditional - builder.switch_to_block(b3); - let two = builder.numeric_constant(5u128, Type::unsigned(32)); - let v9 = builder.insert_binary(v5, BinaryOp::Eq, two); - builder.terminate_with_jmpif(v9, b4, b5); - - // b4 is the rest of the loop after the if statement - builder.switch_to_block(b4); - let v10 = builder.insert_load(v3, nested_array_type.clone()); - builder.insert_store(v4, v10); - builder.terminate_with_jmp(b5, vec![]); - - builder.switch_to_block(b5); - let v11 = builder.insert_load(v3, nested_array_type.clone()); - let twenty = builder.field_constant(20u128); - let v13 = builder.insert_array_get(v11, zero, array_type.clone()); - let v14 = builder.insert_array_set(v13, v5, twenty); - let v15 = builder.insert_array_set(v11, v5, v14); - - builder.insert_store(v3, v15); - let one = builder.numeric_constant(1u128, Type::unsigned(32)); - let v17 = builder.insert_binary(v5, BinaryOp::Add, one); - builder.terminate_with_jmp(b1, vec![v17]); - - builder.switch_to_block(b2); - builder.terminate_with_return(vec![]); + let src = " + brillig(inline) fn main f0 { + b0(): + v1 = allocate -> &mut [Field; 5] + store [[Field 0, Field 0, Field 0, Field 0, Field 0] of Field, [Field 0, Field 0, Field 0, Field 0, Field 0] of Field] of [Field; 5] at v1 + v6 = allocate -> &mut [Field; 5] + store [[Field 0, Field 0, Field 0, Field 0, Field 0] of Field, [Field 0, Field 0, Field 0, Field 0, Field 0] of Field] of [Field; 5] at v6 + jmp b1(u32 0) + b1(v0: u32): + v12 = lt v0, u32 5 + jmpif v12 then: b3, else: b2 + b3(): + v13 = eq v0, u32 5 + jmpif v13 then: b4, else: b5 + b4(): + v14 = load v1 -> [[Field; 5]; 2] + store v14 at v6 + jmp b5() + b5(): + v15 = load v1 -> [[Field; 5]; 2] + v16 = array_get v15, index Field 0 -> [Field; 5] + v18 = array_set v16, index v0, value Field 20 + v19 = array_set v15, index v0, value v18 + store v19 at v1 + v21 = add v0, u32 1 + jmp b1(v21) + b2(): + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); - let ssa = builder.finish(); // We expect the same result as above let ssa = ssa.array_set_optimization(); - - let main = ssa.main(); - assert_eq!(main.reachable_blocks().len(), 6); - - let array_set_instructions = main.dfg[b5] - .instructions() - .iter() - .filter(|instruction| matches!(&main.dfg[**instruction], Instruction::ArraySet { .. })) - .collect::>(); - - assert_eq!(array_set_instructions.len(), 2); - if let Instruction::ArraySet { mutable, .. } = &main.dfg[*array_set_instructions[0]] { - // The single array set should not be marked mutable - assert!(!mutable); - } + assert_normalized_ssa_equals(ssa, src); } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/as_slice_length.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/as_slice_length.rs index 59917e8589b7..76705dcc9db6 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/as_slice_length.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/as_slice_length.rs @@ -75,3 +75,34 @@ fn replace_known_slice_lengths( func.dfg.set_value_from_id(original_slice_length, known_length); }); } + +#[cfg(test)] +mod test { + use crate::ssa::opt::assert_normalized_ssa_equals; + + use super::Ssa; + + #[test] + fn as_slice_length_optimization() { + // In this code we expect `return v2` to be replaced with `return u32 3` because + // that's the length of the v0 array. + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v2, v3 = call as_slice(v0) -> (u32, [Field]) + return v2 + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v2, v3 = call as_slice(v0) -> (u32, [Field]) + return u32 3 + } + "; + let ssa = ssa.as_slice_optimization(); + assert_normalized_ssa_equals(ssa, expected); + } +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index 3b86ded4a874..b5ab688cb2cb 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -317,531 +317,305 @@ mod test { use crate::ssa::{ function_builder::FunctionBuilder, - ir::{ - instruction::{Binary, BinaryOp, Instruction, TerminatorInstruction}, - map::Id, - types::Type, - value::{Value, ValueId}, - }, + ir::{map::Id, types::Type}, + opt::assert_normalized_ssa_equals, + Ssa, }; - use acvm::{acir::AcirField, FieldElement}; #[test] fn simple_constant_fold() { - // fn main f0 { - // b0(v0: Field): - // v1 = add v0, Field 1 - // v2 = mul v1, Field 3 - // return v2 - // } - // // After constructing this IR, we set the value of v0 to 2. // The expected return afterwards should be 9. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); - - let one = builder.field_constant(1u128); - let two = builder.field_constant(2u128); - let three = builder.field_constant(3u128); - - let v1 = builder.insert_binary(v0, BinaryOp::Add, one); - let v2 = builder.insert_binary(v1, BinaryOp::Mul, three); - builder.terminate_with_return(vec![v2]); - - let mut ssa = builder.finish(); + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v1 = add v0, Field 1 + v2 = mul v1, Field 3 + return v2 + } + "; + let mut ssa = Ssa::from_str(src).unwrap(); let main = ssa.main_mut(); + let instructions = main.dfg[main.entry_block()].instructions(); assert_eq!(instructions.len(), 2); // The final return is not counted - // Expected output: - // - // fn main f0 { - // b0(Field 2: Field): - // return Field 9 - // } + let v0 = main.parameters()[0]; + let two = main.dfg.make_constant(2_u128.into(), Type::field()); + main.dfg.set_value_from_id(v0, two); - let ssa = ssa.fold_constants(); - let main = ssa.main(); - let block = &main.dfg[main.entry_block()]; - assert_eq!(block.instructions().len(), 0); - - match block.terminator() { - Some(TerminatorInstruction::Return { return_values, .. }) => { - let value = main - .dfg - .get_numeric_constant(return_values[0]) - .expect("Expected constant 9") - .to_u128(); - assert_eq!(value, 9); + let expected = " + acir(inline) fn main f0 { + b0(v0: Field): + return Field 9 } - _ => unreachable!("b0 should have a return terminator"), - } + "; + let ssa = ssa.fold_constants(); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn redundant_truncation() { - // fn main f0 { - // b0(v0: u16, v1: u16): - // v2 = div v0, v1 - // v3 = truncate v2 to 8 bits, max_bit_size: 16 - // return v3 - // } - // // After constructing this IR, we set the value of v1 to 2^8. // The expected return afterwards should be v2. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(16)); - let v1 = builder.add_parameter(Type::unsigned(16)); - - // Note that this constant guarantees that `v0/constant < 2^8`. We then do not need to truncate the result. - let constant = 2_u128.pow(8); - let constant = builder.numeric_constant(constant, Type::field()); - - let v2 = builder.insert_binary(v0, BinaryOp::Div, v1); - let v3 = builder.insert_truncate(v2, 8, 16); - builder.terminate_with_return(vec![v3]); - - let mut ssa = builder.finish(); + let src = " + acir(inline) fn main f0 { + b0(v0: u16, v1: u16): + v2 = div v0, v1 + v3 = truncate v2 to 8 bits, max_bit_size: 16 + return v3 + } + "; + let mut ssa = Ssa::from_str(src).unwrap(); let main = ssa.main_mut(); + let instructions = main.dfg[main.entry_block()].instructions(); assert_eq!(instructions.len(), 2); // The final return is not counted - // Expected output: - // - // fn main f0 { - // b0(Field 2: Field): - // return Field 9 - // } - main.dfg.set_value_from_id(v1, constant); + let v1 = main.parameters()[1]; - let ssa = ssa.fold_constants(); - let main = ssa.main(); + // Note that this constant guarantees that `v0/constant < 2^8`. We then do not need to truncate the result. + let constant = 2_u128.pow(8); + let constant = main.dfg.make_constant(constant.into(), Type::unsigned(16)); - println!("{ssa}"); + main.dfg.set_value_from_id(v1, constant); - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 1); - let instruction = &main.dfg[instructions[0]]; + let expected = " + acir(inline) fn main f0 { + b0(v0: u16, v1: u16): + v3 = div v0, u16 256 + return v3 + } + "; - assert_eq!( - instruction, - &Instruction::Binary(Binary { lhs: v0, operator: BinaryOp::Div, rhs: constant }) - ); + let ssa = ssa.fold_constants(); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn non_redundant_truncation() { - // fn main f0 { - // b0(v0: u16, v1: u16): - // v2 = div v0, v1 - // v3 = truncate v2 to 8 bits, max_bit_size: 16 - // return v3 - // } - // // After constructing this IR, we set the value of v1 to 2^8 - 1. // This should not result in the truncation being removed. - let main_id = Id::test_new(0); + let src = " + acir(inline) fn main f0 { + b0(v0: u16, v1: u16): + v2 = div v0, v1 + v3 = truncate v2 to 8 bits, max_bit_size: 16 + return v3 + } + "; + let mut ssa = Ssa::from_str(src).unwrap(); + let main = ssa.main_mut(); - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(16)); - let v1 = builder.add_parameter(Type::unsigned(16)); + let instructions = main.dfg[main.entry_block()].instructions(); + assert_eq!(instructions.len(), 2); // The final return is not counted + + let v1 = main.parameters()[1]; // Note that this constant does not guarantee that `v0/constant < 2^8`. We must then truncate the result. let constant = 2_u128.pow(8) - 1; - let constant = builder.numeric_constant(constant, Type::field()); - - let v2 = builder.insert_binary(v0, BinaryOp::Div, v1); - let v3 = builder.insert_truncate(v2, 8, 16); - builder.terminate_with_return(vec![v3]); - - let mut ssa = builder.finish(); - let main = ssa.main_mut(); - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 2); // The final return is not counted + let constant = main.dfg.make_constant(constant.into(), Type::unsigned(16)); - // Expected output: - // - // fn main f0 { - // b0(v0: u16, Field 255: Field): - // v6 = div v0, Field 255 - // v7 = truncate v6 to 8 bits, max_bit_size: 16 - // return v7 - // } main.dfg.set_value_from_id(v1, constant); - let ssa = ssa.fold_constants(); - let main = ssa.main(); - - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 2); + let expected = " + acir(inline) fn main f0 { + b0(v0: u16, v1: u16): + v3 = div v0, u16 255 + v4 = truncate v3 to 8 bits, max_bit_size: 16 + return v4 + } + "; - assert_eq!( - &main.dfg[instructions[0]], - &Instruction::Binary(Binary { lhs: v0, operator: BinaryOp::Div, rhs: constant }) - ); - assert_eq!( - &main.dfg[instructions[1]], - &Instruction::Truncate { value: ValueId::test_new(6), bit_size: 8, max_bit_size: 16 } - ); + let ssa = ssa.fold_constants(); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn arrays_elements_are_updated() { - // fn main f0 { - // b0(v0: Field): - // v1 = add v0, Field 1 - // return [v1] - // } - // // After constructing this IR, we run constant folding with no expected benefit, but to // ensure that all new values ids are correctly propagated. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); - let one = builder.field_constant(1u128); - let v1 = builder.insert_binary(v0, BinaryOp::Add, one); - - let array_type = Type::Array(Arc::new(vec![Type::field()]), 1); - let arr = builder.current_function.dfg.make_array(vec![v1].into(), array_type); - builder.terminate_with_return(vec![arr]); - - let ssa = builder.finish().fold_constants(); - let main = ssa.main(); - let entry_block_id = main.entry_block(); - let entry_block = &main.dfg[entry_block_id]; - assert_eq!(entry_block.instructions().len(), 1); - let new_add_instr = entry_block.instructions().first().unwrap(); - let new_add_instr_result = main.dfg.instruction_results(*new_add_instr)[0]; - assert_ne!(new_add_instr_result, v1); - - let return_value_id = match entry_block.unwrap_terminator() { - TerminatorInstruction::Return { return_values, .. } => return_values[0], - _ => unreachable!("Should have terminator instruction"), - }; - let return_element = match &main.dfg[return_value_id] { - Value::Array { array, .. } => array[0], - _ => unreachable!("Return type should be array"), - }; - // The return element is expected to refer to the new add instruction result. - assert_eq!(main.dfg.resolve(new_add_instr_result), main.dfg.resolve(return_element)); + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v2 = add v0, Field 1 + return [v2] of Field + } + "; + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.fold_constants(); + assert_normalized_ssa_equals(ssa, src); } #[test] fn instruction_deduplication() { - // fn main f0 { - // b0(v0: u16): - // v1 = cast v0 as u32 - // v2 = cast v0 as u32 - // constrain v1 v2 - // } - // // After constructing this IR, we run constant folding which should replace the second cast // with a reference to the results to the first. This then allows us to optimize away // the constrain instruction as both inputs are known to be equal. // // The first cast instruction is retained and will be removed in the dead instruction elimination pass. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(16)); - - let v1 = builder.insert_cast(v0, Type::unsigned(32)); - let v2 = builder.insert_cast(v0, Type::unsigned(32)); - builder.insert_constrain(v1, v2, None); - - let mut ssa = builder.finish(); - let main = ssa.main_mut(); - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 3); - - // Expected output: - // - // fn main f0 { - // b0(v0: u16): - // v1 = cast v0 as u32 - // } + let src = " + acir(inline) fn main f0 { + b0(v0: u16): + v1 = cast v0 as u32 + v2 = cast v0 as u32 + constrain v1 == v2 + return + } + "; + let expected = " + acir(inline) fn main f0 { + b0(v0: u16): + v1 = cast v0 as u32 + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); let ssa = ssa.fold_constants(); - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - - assert_eq!(instructions.len(), 1); - let instruction = &main.dfg[instructions[0]]; - - assert_eq!(instruction, &Instruction::Cast(v0, Type::unsigned(32))); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn constant_index_array_access_deduplication() { - // fn main f0 { - // b0(v0: [Field; 4], v1: u32, v2: bool, v3: bool): - // enable_side_effects v2 - // v4 = array_get v0 u32 0 - // v5 = array_get v0 v1 - // enable_side_effects v3 - // v6 = array_get v0 u32 0 - // v7 = array_get v0 v1 - // constrain v4 v6 - // } - // // After constructing this IR, we run constant folding which should replace the second constant-index array get // with a reference to the results to the first. This then allows us to optimize away // the constrain instruction as both inputs are known to be equal. - // - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(Type::Array(Arc::new(vec![Type::field()]), 4)); - let v1 = builder.add_parameter(Type::unsigned(32)); - let v2 = builder.add_parameter(Type::unsigned(1)); - let v3 = builder.add_parameter(Type::unsigned(1)); - - let zero = builder.numeric_constant(FieldElement::zero(), Type::length_type()); - - builder.insert_enable_side_effects_if(v2); - let v4 = builder.insert_array_get(v0, zero, Type::field()); - let _v5 = builder.insert_array_get(v0, v1, Type::field()); - - builder.insert_enable_side_effects_if(v3); - let v6 = builder.insert_array_get(v0, zero, Type::field()); - let _v7 = builder.insert_array_get(v0, v1, Type::field()); - - builder.insert_constrain(v4, v6, None); - - let ssa = builder.finish(); - - println!("{ssa}"); - - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 7); + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 4], v1: u32, v2: bool, v3: bool): + enable_side_effects v2 + v4 = array_get v0, index u32 0 -> Field + v5 = array_get v0, index v1 -> Field + enable_side_effects v3 + v6 = array_get v0, index u32 0 -> Field + v7 = array_get v0, index v1 -> Field + constrain v4 == v6 + return + } + "; + let expected = " + acir(inline) fn main f0 { + b0(v0: [Field; 4], v1: u32, v2: u1, v3: u1): + enable_side_effects v2 + v5 = array_get v0, index u32 0 -> Field + v6 = array_get v0, index v1 -> Field + enable_side_effects v3 + v7 = array_get v0, index v1 -> Field + return + } + "; - // Expected output: - // - // fn main f0 { - // b0(v0: [Field; 4], v1: u32, v2: bool, v3: bool): - // enable_side_effects v2 - // v10 = array_get v0 u32 0 - // v11 = array_get v0 v1 - // enable_side_effects v3 - // v12 = array_get v0 v1 - // } + let ssa = Ssa::from_str(src).unwrap(); let ssa = ssa.fold_constants(); - - println!("{ssa}"); - - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - - assert_eq!(instructions.len(), 5); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn constraint_decomposition() { - // fn main f0 { - // b0(v0: u1, v1: u1, v2: u1): - // v3 = mul v0 v1 - // v4 = not v2 - // v5 = mul v3 v4 - // constrain v4 u1 1 - // } - // // When constructing this IR, we should automatically decompose the constraint to be in terms of `v0`, `v1` and `v2`. // // The mul instructions are retained and will be removed in the dead instruction elimination pass. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::bool()); - let v2 = builder.add_parameter(Type::bool()); - - let v3 = builder.insert_binary(v0, BinaryOp::Mul, v1); - let v4 = builder.insert_not(v2); - let v5 = builder.insert_binary(v3, BinaryOp::Mul, v4); - - // This constraint is automatically decomposed when it is inserted. - let v_true = builder.numeric_constant(true, Type::bool()); - builder.insert_constrain(v5, v_true, None); - - let v_false = builder.numeric_constant(false, Type::bool()); - - // Expected output: - // - // fn main f0 { - // b0(v0: u1, v1: u1, v2: u1): - // v3 = mul v0 v1 - // v4 = not v2 - // v5 = mul v3 v4 - // constrain v0 u1 1 - // constrain v1 u1 1 - // constrain v2 u1 0 - // } - - let ssa = builder.finish(); - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - - assert_eq!(instructions.len(), 6); - - assert_eq!( - main.dfg[instructions[0]], - Instruction::Binary(Binary { lhs: v0, operator: BinaryOp::Mul, rhs: v1 }) - ); - assert_eq!(main.dfg[instructions[1]], Instruction::Not(v2)); - assert_eq!( - main.dfg[instructions[2]], - Instruction::Binary(Binary { lhs: v3, operator: BinaryOp::Mul, rhs: v4 }) - ); - assert_eq!(main.dfg[instructions[3]], Instruction::Constrain(v0, v_true, None)); - assert_eq!(main.dfg[instructions[4]], Instruction::Constrain(v1, v_true, None)); - assert_eq!(main.dfg[instructions[5]], Instruction::Constrain(v2, v_false, None)); + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1, v2: u1): + v3 = mul v0, v1 + v4 = not v2 + v5 = mul v3, v4 + constrain v5 == u1 1 + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1, v2: u1): + v3 = mul v0, v1 + v4 = not v2 + v5 = mul v3, v4 + constrain v0 == u1 1 + constrain v1 == u1 1 + constrain v2 == u1 0 + return + } + "; + assert_normalized_ssa_equals(ssa, expected); } // Regression for #4600 #[test] fn array_get_regression() { - // fn main f0 { - // b0(v0: u1, v1: u64): - // enable_side_effects_if v0 - // v2 = array_get [Field 0, Field 1], index v1 - // v3 = not v0 - // enable_side_effects_if v3 - // v4 = array_get [Field 0, Field 1], index v1 - // } - // // We want to make sure after constant folding both array_gets remain since they are // under different enable_side_effects_if contexts and thus one may be disabled while // the other is not. If one is removed, it is possible e.g. v4 is replaced with v2 which // is disabled (only gets from index 0) and thus returns the wrong result. - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::unsigned(64)); - - builder.insert_enable_side_effects_if(v0); - - let zero = builder.field_constant(0u128); - let one = builder.field_constant(1u128); - - let typ = Type::Array(Arc::new(vec![Type::field()]), 2); - let array = builder.array_constant(vec![zero, one].into(), typ); - - let _v2 = builder.insert_array_get(array, v1, Type::field()); - let v3 = builder.insert_not(v0); - - builder.insert_enable_side_effects_if(v3); - let _v4 = builder.insert_array_get(array, v1, Type::field()); + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u64): + enable_side_effects v0 + v5 = array_get [Field 0, Field 1] of Field, index v1 -> Field + v6 = not v0 + enable_side_effects v6 + v8 = array_get [Field 0, Field 1] of Field, index v1 -> Field + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); // Expected output is unchanged - let ssa = builder.finish(); - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - let starting_instruction_count = instructions.len(); - assert_eq!(starting_instruction_count, 5); - let ssa = ssa.fold_constants(); - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - let ending_instruction_count = instructions.len(); - assert_eq!(starting_instruction_count, ending_instruction_count); + assert_normalized_ssa_equals(ssa, src); } #[test] fn deduplicate_instructions_with_predicates() { - // fn main f0 { - // b0(v0: bool, v1: bool, v2: [u32; 2]): - // enable_side_effects v0 - // v3 = array_get v2, index u32 0 - // v4 = array_set v2, index u32 1, value: u32 2 - // v5 = array_get v4, index u32 0 - // constrain_eq v3, v5 - // enable_side_effects v1 - // v6 = array_get v2, index u32 0 - // v7 = array_set v2, index u32 1, value: u32 2 - // v8 = array_get v7, index u32 0 - // constrain_eq v6, v8 - // enable_side_effects v0 - // v9 = array_get v2, index u32 0 - // v10 = array_set v2, index u32 1, value: u32 2 - // v11 = array_get v10, index u32 0 - // constrain_eq v9, v11 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::bool()); - let v2 = builder.add_parameter(Type::Array(Arc::new(vec![Type::field()]), 2)); - - let zero = builder.numeric_constant(0u128, Type::length_type()); - let one = builder.numeric_constant(1u128, Type::length_type()); - let two = builder.numeric_constant(2u128, Type::length_type()); - - builder.insert_enable_side_effects_if(v0); - let v3 = builder.insert_array_get(v2, zero, Type::length_type()); - let v4 = builder.insert_array_set(v2, one, two); - let v5 = builder.insert_array_get(v4, zero, Type::length_type()); - builder.insert_constrain(v3, v5, None); - - builder.insert_enable_side_effects_if(v1); - let v6 = builder.insert_array_get(v2, zero, Type::length_type()); - let v7 = builder.insert_array_set(v2, one, two); - let v8 = builder.insert_array_get(v7, zero, Type::length_type()); - builder.insert_constrain(v6, v8, None); - - // We expect all these instructions after the 'enable side effects' instruction to be removed. - builder.insert_enable_side_effects_if(v0); - let v9 = builder.insert_array_get(v2, zero, Type::length_type()); - let v10 = builder.insert_array_set(v2, one, two); - let v11 = builder.insert_array_get(v10, zero, Type::length_type()); - builder.insert_constrain(v9, v11, None); - - let ssa = builder.finish(); - println!("{ssa}"); + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1, v2: [Field; 2]): + enable_side_effects v0 + v6 = array_get v2, index u32 0 -> u32 + v7 = array_set v2, index u32 1, value u32 2 + v8 = array_get v7, index u32 0 -> u32 + constrain v6 == v8 + enable_side_effects v1 + v9 = array_get v2, index u32 0 -> u32 + v10 = array_set v2, index u32 1, value u32 2 + v11 = array_get v10, index u32 0 -> u32 + constrain v9 == v11 + enable_side_effects v0 + v12 = array_get v2, index u32 0 -> u32 + v13 = array_set v2, index u32 1, value u32 2 + v14 = array_get v13, index u32 0 -> u32 + constrain v12 == v14 + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); let main = ssa.main(); let instructions = main.dfg[main.entry_block()].instructions(); assert_eq!(instructions.len(), 15); - // Expected output: - // - // fn main f0 { - // b0(v0: bool, v1: bool, v2: [Field; 2]): - // enable_side_effects v0 - // v3 = array_get v2, index Field 0 - // v4 = array_set v2, index Field 1, value: Field 2 - // v5 = array_get v4, index Field 0 - // constrain_eq v3, v5 - // enable_side_effects v1 - // v7 = array_set v2, index Field 1, value: Field 2 - // v8 = array_get v7, index Field 0 - // constrain_eq v3, v8 - // enable_side_effects v0 - // } - let ssa = ssa.fold_constants_using_constraints(); - println!("{ssa}"); + let expected = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1, v2: [Field; 2]): + enable_side_effects v0 + v4 = array_get v2, index u32 0 -> u32 + v7 = array_set v2, index u32 1, value u32 2 + v8 = array_get v7, index u32 0 -> u32 + constrain v4 == v8 + enable_side_effects v1 + v9 = array_set v2, index u32 1, value u32 2 + v10 = array_get v9, index u32 0 -> u32 + constrain v4 == v10 + enable_side_effects v0 + return + } + "; - let main = ssa.main(); - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 10); + let ssa = ssa.fold_constants_using_constraints(); + assert_normalized_ssa_equals(ssa, expected); } // This test currently fails. It being fixed will address the issue https://github.com/noir-lang/noir/issues/5756 @@ -878,7 +652,8 @@ mod test { let _v10 = builder.insert_call(keccakf1600, vec![array1], vec![typ.clone()]); let _v11 = builder.insert_call(keccakf1600, vec![array2], vec![typ.clone()]); - let ssa = builder.finish(); + let mut ssa = builder.finish(); + ssa.normalize_ids(); println!("{ssa}"); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs index beca7c41e5c9..f28b076a5f9f 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs @@ -3,6 +3,7 @@ use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use im::Vector; use noirc_errors::Location; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use crate::ssa::{ ir::{ @@ -24,9 +25,8 @@ impl Ssa { /// unused results. #[tracing::instrument(level = "trace", skip(self))] pub(crate) fn dead_instruction_elimination(mut self) -> Ssa { - for function in self.functions.values_mut() { - function.dead_instruction_elimination(true); - } + self.functions.par_iter_mut().for_each(|(_, func)| func.dead_instruction_elimination(true)); + self } } @@ -622,210 +622,118 @@ mod test { use crate::ssa::{ function_builder::FunctionBuilder, - ir::{ - instruction::{BinaryOp, Instruction, Intrinsic}, - map::Id, - types::Type, - }, + ir::{instruction::Instruction, map::Id, types::Type}, + opt::assert_normalized_ssa_equals, + Ssa, }; #[test] fn dead_instruction_elimination() { - // fn main f0 { - // b0(v0: Field): - // v1 = add v0, Field 1 - // v2 = add v0, Field 2 - // jmp b1(v2) - // b1(v3: Field): - // v4 = allocate 1 field - // v5 = load v4 - // v6 = allocate 1 field - // store Field 1 in v6 - // v7 = load v6 - // v8 = add v7, Field 1 - // v9 = add v7, Field 2 - // v10 = add v7, Field 3 - // v11 = add v10, v10 - // call assert_constant(v8) - // return v9 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); - let b1 = builder.insert_block(); - - let one = builder.field_constant(1u128); - let two = builder.field_constant(2u128); - let three = builder.field_constant(3u128); - - let _v1 = builder.insert_binary(v0, BinaryOp::Add, one); - let v2 = builder.insert_binary(v0, BinaryOp::Add, two); - builder.terminate_with_jmp(b1, vec![v2]); - - builder.switch_to_block(b1); - let _v3 = builder.add_block_parameter(b1, Type::field()); - - let v4 = builder.insert_allocate(Type::field()); - let _v5 = builder.insert_load(v4, Type::field()); - - let v6 = builder.insert_allocate(Type::field()); - builder.insert_store(v6, one); - let v7 = builder.insert_load(v6, Type::field()); - let v8 = builder.insert_binary(v7, BinaryOp::Add, one); - let v9 = builder.insert_binary(v7, BinaryOp::Add, two); - let v10 = builder.insert_binary(v7, BinaryOp::Add, three); - let _v11 = builder.insert_binary(v10, BinaryOp::Add, v10); - - let assert_constant_id = builder.import_intrinsic_id(Intrinsic::AssertConstant); - builder.insert_call(assert_constant_id, vec![v8], vec![]); - builder.terminate_with_return(vec![v9]); - - let ssa = builder.finish(); - let main = ssa.main(); - - // The instruction count never includes the terminator instruction - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 2); - assert_eq!(main.dfg[b1].instructions().len(), 10); - - // Expected output: - // - // fn main f0 { - // b0(v0: Field): - // v2 = add v0, Field 2 - // jmp b1(v2) - // b1(v3: Field): - // v6 = allocate 1 field - // store Field 1 in v6 - // v7 = load v6 - // v8 = add v7, Field 1 - // v9 = add v7, Field 2 - // call assert_constant(v8) - // return v9 - // } + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v3 = add v0, Field 1 + v5 = add v0, Field 2 + jmp b1(v5) + b1(v1: Field): + v6 = allocate -> &mut Field + v7 = load v6 -> Field + v8 = allocate -> &mut Field + store Field 1 at v8 + v9 = load v8 -> Field + v10 = add v9, Field 1 + v11 = add v9, Field 2 + v13 = add v9, Field 3 + v14 = add v13, v13 + call assert_constant(v10) + return v11 + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: Field): + v3 = add v0, Field 2 + jmp b1(v3) + b1(v1: Field): + v4 = allocate -> &mut Field + store Field 1 at v4 + v6 = load v4 -> Field + v7 = add v6, Field 1 + v8 = add v6, Field 2 + call assert_constant(v7) + return v8 + } + "; let ssa = ssa.dead_instruction_elimination(); - let main = ssa.main(); - - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 1); - assert_eq!(main.dfg[b1].instructions().len(), 6); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn as_witness_die() { - // fn main f0 { - // b0(v0: Field): - // v1 = add v0, Field 1 - // v2 = add v0, Field 2 - // call as_witness(v2) - // return v1 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); - - let one = builder.field_constant(1u128); - let two = builder.field_constant(2u128); - - let v1 = builder.insert_binary(v0, BinaryOp::Add, one); - let v2 = builder.insert_binary(v0, BinaryOp::Add, two); - let as_witness = builder.import_intrinsic("as_witness").unwrap(); - builder.insert_call(as_witness, vec![v2], Vec::new()); - builder.terminate_with_return(vec![v1]); - - let ssa = builder.finish(); - let main = ssa.main(); - - // The instruction count never includes the terminator instruction - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 3); - - // Expected output: - // - // acir(inline) fn main f0 { - // b0(v0: Field): - // v3 = add v0, Field 1 - // return v3 - // } + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v2 = add v0, Field 1 + v4 = add v0, Field 2 + call as_witness(v4) + return v2 + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: Field): + v2 = add v0, Field 1 + return v2 + } + "; let ssa = ssa.dead_instruction_elimination(); - let main = ssa.main(); - - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 1); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn remove_useless_paired_rcs_even_when_used() { - // acir(inline) fn main f0 { - // b0(v0: [Field; 2]): - // inc_rc v0 - // v2 = array_get v0, index u32 0 - // dec_rc v0 - // return v2 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::Array(Arc::new(vec![Type::field()]), 2)); - builder.increment_array_reference_count(v0); - let zero = builder.numeric_constant(0u128, Type::unsigned(32)); - let v1 = builder.insert_array_get(v0, zero, Type::field()); - builder.decrement_array_reference_count(v0); - builder.terminate_with_return(vec![v1]); - - let ssa = builder.finish(); - let main = ssa.main(); - - // The instruction count never includes the terminator instruction - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 3); - - // Expected output: - // - // acir(inline) fn main f0 { - // b0(v0: [Field; 2]): - // v2 = array_get v0, index u32 0 - // return v2 - // } + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 2]): + inc_rc v0 + v2 = array_get v0, index u32 0 -> Field + dec_rc v0 + return v2 + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: [Field; 2]): + v2 = array_get v0, index u32 0 -> Field + return v2 + } + "; let ssa = ssa.dead_instruction_elimination(); - let main = ssa.main(); - - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 1); - assert!(matches!(&main.dfg[instructions[0]], Instruction::ArrayGet { .. })); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn keep_paired_rcs_with_array_set() { - // acir(inline) fn main f0 { - // b0(v0: [Field; 2]): - // inc_rc v0 - // v2 = array_set v0, index u32 0, value u32 0 - // dec_rc v0 - // return v2 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::Array(Arc::new(vec![Type::field()]), 2)); - builder.increment_array_reference_count(v0); - let zero = builder.numeric_constant(0u128, Type::unsigned(32)); - let v1 = builder.insert_array_set(v0, zero, zero); - builder.decrement_array_reference_count(v0); - builder.terminate_with_return(vec![v1]); - - let ssa = builder.finish(); - let main = ssa.main(); - - // The instruction count never includes the terminator instruction - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 3); + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 2]): + inc_rc v0 + v2 = array_set v0, index u32 0, value u32 0 + dec_rc v0 + return v2 + } + "; + let ssa = Ssa::from_str(src).unwrap(); // We expect the output to be unchanged let ssa = ssa.dead_instruction_elimination(); - let main = ssa.main(); - - assert_eq!(main.dfg[main.entry_block()].instructions().len(), 3); + assert_normalized_ssa_equals(ssa, src); } #[test] @@ -940,47 +848,31 @@ mod test { #[test] fn remove_inc_rcs_that_are_never_mutably_borrowed() { - // acir(inline) fn main f0 { - // b0(v0: [Field; 2]): - // inc_rc v0 - // inc_rc v0 - // inc_rc v0 - // v2 = array_get v0, index u32 0 - // inc_rc v0 - // return v2 - // } - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::Array(Arc::new(vec![Type::field()]), 2)); - builder.increment_array_reference_count(v0); - builder.increment_array_reference_count(v0); - builder.increment_array_reference_count(v0); - - let zero = builder.numeric_constant(0u128, Type::unsigned(32)); - let v2 = builder.insert_array_get(v0, zero, Type::field()); - builder.increment_array_reference_count(v0); - builder.terminate_with_return(vec![v2]); - - let ssa = builder.finish(); + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 2]): + inc_rc v0 + inc_rc v0 + inc_rc v0 + v2 = array_get v0, index u32 0 -> Field + inc_rc v0 + return v2 + } + "; + let ssa = Ssa::from_str(src).unwrap(); let main = ssa.main(); // The instruction count never includes the terminator instruction assert_eq!(main.dfg[main.entry_block()].instructions().len(), 5); - // Expected output: - // - // acir(inline) fn main f0 { - // b0(v0: [Field; 2]): - // v2 = array_get v0, index u32 0 - // return v2 - // } + let expected = " + acir(inline) fn main f0 { + b0(v0: [Field; 2]): + v2 = array_get v0, index u32 0 -> Field + return v2 + } + "; let ssa = ssa.dead_instruction_elimination(); - let main = ssa.main(); - - let instructions = main.dfg[main.entry_block()].instructions(); - assert_eq!(instructions.len(), 1); - assert!(matches!(&main.dfg[instructions[0]], Instruction::ArrayGet { .. })); + assert_normalized_ssa_equals(ssa, expected); } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index 984f639df00a..db2d96aac818 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -930,237 +930,156 @@ mod test { types::Type, value::{Value, ValueId}, }, + opt::assert_normalized_ssa_equals, + Ssa, }; #[test] fn basic_jmpif() { - // fn main f0 { - // b0(v0: b1): - // jmpif v0, then: b1, else: b2 - // b1(): - // jmp b3(Field 3) - // b2(): - // jmp b3(Field 4) - // b3(v1: Field): - // return v1 - // } - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let b1 = builder.insert_block(); - let b2 = builder.insert_block(); - let b3 = builder.insert_block(); - - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_block_parameter(b3, Type::field()); - - let three = builder.field_constant(3u128); - let four = builder.field_constant(4u128); - - builder.terminate_with_jmpif(v0, b1, b2); - - builder.switch_to_block(b1); - builder.terminate_with_jmp(b3, vec![three]); - - builder.switch_to_block(b2); - builder.terminate_with_jmp(b3, vec![four]); - - builder.switch_to_block(b3); - builder.terminate_with_return(vec![v1]); - - let ssa = builder.finish(); + let src = " + acir(inline) fn main f0 { + b0(v0: u1): + jmpif v0 then: b1, else: b2 + b1(): + jmp b3(Field 3) + b3(v1: Field): + return v1 + b2(): + jmp b3(Field 4) + } + "; + let ssa = Ssa::from_str(src).unwrap(); assert_eq!(ssa.main().reachable_blocks().len(), 4); - // Expected output: - // fn main f0 { - // b0(v0: u1): - // enable_side_effects v0 - // v5 = not v0 - // enable_side_effects v5 - // enable_side_effects u1 1 - // v7 = mul v0, Field 3 - // v8 = mul v5, Field 4 - // v9 = add v7, v8 - // return v9 - // } + let expected = " + acir(inline) fn main f0 { + b0(v0: u1): + enable_side_effects v0 + v1 = not v0 + enable_side_effects u1 1 + v3 = cast v0 as Field + v4 = cast v1 as Field + v6 = mul v3, Field 3 + v8 = mul v4, Field 4 + v9 = add v6, v8 + return v9 + } + "; + let ssa = ssa.flatten_cfg(); - assert_eq!(ssa.main().reachable_blocks().len(), 1); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn modify_constrain() { - // fn main f0 { - // b0(v0: u1, v1: u1): - // jmpif v0, then: b1, else: b2 - // b1(): - // constrain v1 - // jmp b2() - // b2(): - // return - // } - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let b1 = builder.insert_block(); - let b2 = builder.insert_block(); - - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::bool()); - let v_true = builder.numeric_constant(true, Type::bool()); - - builder.terminate_with_jmpif(v0, b1, b2); - - builder.switch_to_block(b1); - builder.insert_constrain(v1, v_true, None); - builder.terminate_with_jmp(b2, vec![]); - - builder.switch_to_block(b2); - builder.terminate_with_return(vec![]); - - let ssa = builder.finish(); + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1): + jmpif v0 then: b1, else: b2 + b1(): + constrain v1 == u1 1 + jmp b2() + b2(): + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); assert_eq!(ssa.main().reachable_blocks().len(), 3); - // Expected output: - // fn main f0 { - // b0(v0: u1, v1: u1): - // enable_side_effects v0 - // v3 = mul v1, v0 - // v4 = eq v3, v0 - // constrain v4 - // v5 = not v0 - // enable_side_effects v5 - // enable_side_effects u1 1 - // return - // } + let expected = " + acir(inline) fn main f0 { + b0(v0: u1, v1: u1): + enable_side_effects v0 + v2 = mul v1, v0 + constrain v2 == v0 + v3 = not v0 + enable_side_effects u1 1 + return + } + "; let ssa = ssa.flatten_cfg(); assert_eq!(ssa.main().reachable_blocks().len(), 1); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn merge_stores() { - // fn main f0 { - // b0(v0: u1, v1: &mut Field): - // jmpif v0, then: b1, else: b2 - // b1(): - // store v1, Field 5 - // jmp b2() - // b2(): - // return - // } - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let b1 = builder.insert_block(); - let b2 = builder.insert_block(); - - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::Reference(Arc::new(Type::field()))); - - builder.terminate_with_jmpif(v0, b1, b2); - - builder.switch_to_block(b1); - let five = builder.field_constant(5u128); - builder.insert_store(v1, five); - builder.terminate_with_jmp(b2, vec![]); - - builder.switch_to_block(b2); - builder.terminate_with_return(vec![]); - - let ssa = builder.finish(); - - // Expected output: - // fn main f0 { - // b0(v0: u1, v1: reference): - // enable_side_effects v0 - // v4 = load v1 - // store Field 5 at v1 - // v5 = not v0 - // store v4 at v1 - // enable_side_effects u1 1 - // v6 = cast v0 as Field - // v7 = cast v5 as Field - // v8 = mul v6, Field 5 - // v9 = mul v7, v4 - // v10 = add v8, v9 - // store v10 at v1 - // return - // } + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: &mut Field): + jmpif v0 then: b1, else: b2 + b1(): + store Field 5 at v1 + jmp b2() + b2(): + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: u1, v1: &mut Field): + enable_side_effects v0 + v2 = load v1 -> Field + store Field 5 at v1 + v4 = not v0 + store v2 at v1 + enable_side_effects u1 1 + v6 = cast v0 as Field + v7 = cast v4 as Field + v8 = mul v6, Field 5 + v9 = mul v7, v2 + v10 = add v8, v9 + store v10 at v1 + return + } + "; let ssa = ssa.flatten_cfg(); - let main = ssa.main(); - - assert_eq!(main.reachable_blocks().len(), 1); - - let store_count = count_instruction(main, |ins| matches!(ins, Instruction::Store { .. })); - assert_eq!(store_count, 3); + assert_normalized_ssa_equals(ssa, expected); } #[test] fn merge_stores_with_else_block() { - // fn main f0 { - // b0(v0: u1, v1: ref): - // jmpif v0, then: b1, else: b2 - // b1(): - // store Field 5 in v1 - // jmp b3() - // b2(): - // store Field 6 in v1 - // jmp b3() - // b3(): - // return - // } - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let b1 = builder.insert_block(); - let b2 = builder.insert_block(); - let b3 = builder.insert_block(); - - let v0 = builder.add_parameter(Type::bool()); - let v1 = builder.add_parameter(Type::Reference(Arc::new(Type::field()))); - - builder.terminate_with_jmpif(v0, b1, b2); - - builder.switch_to_block(b1); - let five = builder.field_constant(5u128); - builder.insert_store(v1, five); - builder.terminate_with_jmp(b3, vec![]); - - builder.switch_to_block(b2); - let six = builder.field_constant(6u128); - builder.insert_store(v1, six); - builder.terminate_with_jmp(b3, vec![]); - - builder.switch_to_block(b3); - builder.terminate_with_return(vec![]); - - let ssa = builder.finish(); - - // Expected output: - // fn main f0 { - // b0(v0: u1, v1: reference): - // enable_side_effects v0 - // v5 = load v1 - // store Field 5 at v1 - // v6 = not v0 - // store v5 at v1 - // enable_side_effects v6 - // v8 = load v1 - // store Field 6 at v1 - // enable_side_effects u1 1 - // v9 = cast v0 as Field - // v10 = cast v6 as Field - // v11 = mul v9, Field 5 - // v12 = mul v10, Field 6 - // v13 = add v11, v12 - // store v13 at v1 - // return - // } + let src = " + acir(inline) fn main f0 { + b0(v0: u1, v1: &mut Field): + jmpif v0 then: b1, else: b2 + b1(): + store Field 5 at v1 + jmp b3() + b2(): + store Field 6 at v1 + jmp b3() + b3(): + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(v0: u1, v1: &mut Field): + enable_side_effects v0 + v2 = load v1 -> Field + store Field 5 at v1 + v4 = not v0 + store v2 at v1 + enable_side_effects v4 + v5 = load v1 -> Field + store Field 6 at v1 + enable_side_effects u1 1 + v8 = cast v0 as Field + v9 = cast v4 as Field + v10 = mul v8, Field 5 + v11 = mul v9, Field 6 + v12 = add v10, v11 + store v12 at v1 + return + } + "; let ssa = ssa.flatten_cfg(); - let main = ssa.main(); - assert_eq!(main.reachable_blocks().len(), 1); - - let store_count = count_instruction(main, |ins| matches!(ins, Instruction::Store { .. })); - assert_eq!(store_count, 4); + assert_normalized_ssa_equals(ssa, expected); } fn count_instruction(function: &Function, f: impl Fn(&Instruction) -> bool) -> usize { @@ -1445,40 +1364,29 @@ mod test { // Very simplified derived regression test for #1792 // Tests that it does not simplify to a true constraint an always-false constraint // The original function is replaced by the following: - // fn main f1 { - // b0(): - // jmpif u1 0 then: b1, else: b2 - // b1(): - // jmp b2() - // b2(): - // constrain u1 0 // was incorrectly removed - // return - // } - let main_id = Id::test_new(1); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - builder.insert_block(); // entry - - let b1 = builder.insert_block(); - let b2 = builder.insert_block(); - let v_true = builder.numeric_constant(true, Type::bool()); - let v_false = builder.numeric_constant(false, Type::bool()); - builder.terminate_with_jmpif(v_false, b1, b2); - - builder.switch_to_block(b1); - builder.terminate_with_jmp(b2, vec![]); - - builder.switch_to_block(b2); - builder.insert_constrain(v_false, v_true, None); // should not be removed - builder.terminate_with_return(vec![]); - - let ssa = builder.finish().flatten_cfg(); - let main = ssa.main(); - - // Assert we have not incorrectly removed a constraint: - use Instruction::Constrain; - let constrain_count = count_instruction(main, |ins| matches!(ins, Constrain(..))); - assert_eq!(constrain_count, 1); + let src = " + acir(inline) fn main f1 { + b0(): + jmpif u1 0 then: b1, else: b2 + b1(): + jmp b2() + b2(): + constrain u1 0 == u1 1 // was incorrectly removed + return + } + "; + let ssa = Ssa::from_str(src).unwrap(); + + let expected = " + acir(inline) fn main f0 { + b0(): + enable_side_effects u1 1 + constrain u1 0 == u1 1 + return + } + "; + let ssa = ssa.flatten_cfg(); + assert_normalized_ssa_equals(ssa, expected); } #[test] diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs index 9e3dd3e5a30a..a052abc5e163 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs @@ -212,37 +212,32 @@ impl<'f> PerFunctionContext<'f> { all_terminator_values: &HashSet, per_func_block_params: &HashSet, ) -> bool { - let func_params = self.inserter.function.parameters(); - let reference_parameters = func_params - .iter() - .filter(|param| self.inserter.function.dfg.value_is_reference(**param)) - .collect::>(); + let reference_parameters = self.reference_parameters(); - let mut store_alias_used = false; if let Some(expression) = block.expressions.get(store_address) { if let Some(aliases) = block.aliases.get(expression) { let allocation_aliases_parameter = aliases.any(|alias| reference_parameters.contains(&alias)); if allocation_aliases_parameter == Some(true) { - store_alias_used = true; + return true; } let allocation_aliases_parameter = aliases.any(|alias| per_func_block_params.contains(&alias)); if allocation_aliases_parameter == Some(true) { - store_alias_used = true; + return true; } let allocation_aliases_parameter = aliases.any(|alias| self.calls_reference_input.contains(&alias)); if allocation_aliases_parameter == Some(true) { - store_alias_used = true; + return true; } let allocation_aliases_parameter = aliases.any(|alias| all_terminator_values.contains(&alias)); if allocation_aliases_parameter == Some(true) { - store_alias_used = true; + return true; } let allocation_aliases_parameter = aliases.any(|alias| { @@ -252,14 +247,25 @@ impl<'f> PerFunctionContext<'f> { false } }); - if allocation_aliases_parameter == Some(true) { - store_alias_used = true; + return true; } } } - store_alias_used + false + } + + /// Collect the input parameters of the function which are of reference type. + /// All references are mutable, so these inputs are shared with the function caller + /// and thus stores should not be eliminated, even if the blocks in this function + /// don't use them anywhere. + fn reference_parameters(&self) -> BTreeSet { + let parameters = self.inserter.function.parameters().iter(); + parameters + .filter(|param| self.inserter.function.dfg.value_is_reference(**param)) + .copied() + .collect() } fn recursively_add_values(&self, value: ValueId, set: &mut HashSet) { @@ -300,6 +306,12 @@ impl<'f> PerFunctionContext<'f> { fn analyze_block(&mut self, block: BasicBlockId, mut references: Block) { let instructions = self.inserter.function.dfg[block].take_instructions(); + // If this is the entry block, take all the block parameters and assume they may + // be aliased to each other + if block == self.inserter.function.entry_block() { + self.add_aliases_for_reference_parameters(block, &mut references); + } + for instruction in instructions { self.analyze_instruction(block, &mut references, instruction); } @@ -316,13 +328,51 @@ impl<'f> PerFunctionContext<'f> { self.blocks.insert(block, references); } + /// Go through each parameter and register that all reference parameters of the same type are + /// possibly aliased to each other. If there are parameters with nested references (arrays of + /// references or references containing other references) we give up and assume all parameter + /// references are `AliasSet::unknown()`. + fn add_aliases_for_reference_parameters(&self, block: BasicBlockId, references: &mut Block) { + let dfg = &self.inserter.function.dfg; + let params = dfg.block_parameters(block); + + let mut aliases: HashMap = HashMap::default(); + + for param in params { + match dfg.type_of_value(*param) { + // If the type indirectly contains a reference we have to assume all references + // are unknown since we don't have any ValueIds to use. + Type::Reference(element) if element.contains_reference() => return, + Type::Reference(element) => { + let empty_aliases = AliasSet::known_empty(); + let alias_set = + aliases.entry(element.as_ref().clone()).or_insert(empty_aliases); + alias_set.insert(*param); + } + typ if typ.contains_reference() => return, + _ => continue, + } + } + + for aliases in aliases.into_values() { + let first = aliases.first(); + let first = first.expect("All parameters alias at least themselves or we early return"); + + let expression = Expression::Other(first); + let previous = references.aliases.insert(expression.clone(), aliases.clone()); + assert!(previous.is_none()); + + aliases.for_each(|alias| { + let previous = references.expressions.insert(alias, expression.clone()); + assert!(previous.is_none()); + }); + } + } + /// Add all instructions in `last_stores` to `self.instructions_to_remove` which do not /// possibly alias any parameters of the given function. fn remove_stores_that_do_not_alias_parameters(&mut self, references: &Block) { - let parameters = self.inserter.function.parameters().iter(); - let reference_parameters = parameters - .filter(|param| self.inserter.function.dfg.value_is_reference(**param)) - .collect::>(); + let reference_parameters = self.reference_parameters(); for (allocation, instruction) in &references.last_stores { if let Some(expression) = references.expressions.get(allocation) { @@ -466,6 +516,8 @@ impl<'f> PerFunctionContext<'f> { } } + /// If `array` is an array constant that contains reference types, then insert each element + /// as a potential alias to the array itself. fn check_array_aliasing(&self, references: &mut Block, array: ValueId) { if let Some((elements, typ)) = self.inserter.function.dfg.get_array_constant(array) { if Self::contains_references(&typ) { @@ -904,7 +956,7 @@ mod tests { let mut builder = FunctionBuilder::new("main".into(), main_id); let v0 = builder.insert_allocate(Type::field()); - let zero = builder.numeric_constant(0u128, Type::field()); + let zero = builder.field_constant(0u128); builder.insert_store(v0, zero); let v2 = builder.insert_allocate(Type::field()); @@ -928,9 +980,9 @@ mod tests { // Loop body builder.switch_to_block(b2); let v5 = builder.insert_load(v2, v2_type.clone()); - let two = builder.numeric_constant(2u128, Type::field()); + let two = builder.field_constant(2u128); builder.insert_store(v5, two); - let one = builder.numeric_constant(1u128, Type::field()); + let one = builder.field_constant(1u128); let v3_plus_one = builder.insert_binary(v3, BinaryOp::Add, one); builder.terminate_with_jmp(b1, vec![v3_plus_one]); @@ -961,4 +1013,44 @@ mod tests { assert_eq!(count_loads(b2, &main.dfg), 1); assert_eq!(count_loads(b3, &main.dfg), 3); } + + #[test] + fn parameter_alias() { + // Do not assume parameters are not aliased to each other. + // The load below shouldn't be removed since `v0` could + // be aliased to `v1`. + // + // fn main f0 { + // b0(v0: &mut Field, v1: &mut Field): + // store Field 0 at v0 + // store Field 1 at v1 + // v4 = load v0 + // constrain v4 == Field 1 + // return + // } + let main_id = Id::test_new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let field_ref = Type::Reference(Arc::new(Type::field())); + let v0 = builder.add_parameter(field_ref.clone()); + let v1 = builder.add_parameter(field_ref.clone()); + + let zero = builder.field_constant(0u128); + let one = builder.field_constant(0u128); + builder.insert_store(v0, zero); + builder.insert_store(v1, one); + + let v4 = builder.insert_load(v0, Type::field()); + builder.insert_constrain(v4, one, None); + builder.terminate_with_return(Vec::new()); + + let ssa = builder.finish(); + let main = ssa.main(); + assert_eq!(count_loads(main.entry_block(), &main.dfg), 1); + + // No change expected + let ssa = ssa.mem2reg(); + let main = ssa.main(); + assert_eq!(count_loads(main.entry_block(), &main.dfg), 1); + } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg/alias_set.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg/alias_set.rs index 5477025e429f..4d768caa36b4 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg/alias_set.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mem2reg/alias_set.rs @@ -73,4 +73,11 @@ impl AliasSet { } } } + + /// Return the first ValueId in the alias set as long as there is at least one. + /// The ordering is arbitrary (by lowest ValueId) so this method should only be + /// used when you need an arbitrary ValueId from the alias set. + pub(super) fn first(&self) -> Option { + self.aliases.as_ref().and_then(|aliases| aliases.first().copied()) + } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mod.rs index f3dbd58fa693..5576b4945700 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/mod.rs @@ -3,6 +3,7 @@ //! Each pass is generally expected to mutate the SSA IR into a gradually //! simpler form until the IR only has a single function remaining with 1 block within it. //! Generally, these passes are also expected to minimize the final amount of instructions. + mod array_set; mod as_slice_length; mod assert_constant; @@ -21,3 +22,29 @@ mod resolve_is_unconstrained; mod runtime_separation; mod simplify_cfg; mod unrolling; + +/// Asserts that the given SSA, after normalizing its IDs and printing it, +/// is equal to the expected strings. Normalization is done so the IDs don't +/// shift depending on whether temporary intermediate values were created. +#[cfg(test)] +pub(crate) fn assert_normalized_ssa_equals(mut ssa: super::Ssa, expected: &str) { + // First check if `expected` is valid SSA by parsing it, otherwise + // the comparison will always fail but it won't be clear that it's because + // expected is not valid. + if let Err(err) = Ssa::from_str(expected) { + panic!("`expected` argument of `assert_ssa_equals` is not valid SSA:\n{:?}", err); + } + + use crate::{ssa::Ssa, trim_leading_whitespace_from_lines}; + + ssa.normalize_ids(); + + let ssa = ssa.to_string(); + let ssa = trim_leading_whitespace_from_lines(&ssa); + let expected = trim_leading_whitespace_from_lines(expected); + + if ssa != expected { + println!("Got:\n~~~\n{}\n~~~\nExpected:\n~~~\n{}\n~~~", ssa, expected); + similar_asserts::assert_eq!(ssa, expected); + } +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs index 6f3f2fa14b7b..cdbb10432324 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs @@ -145,6 +145,8 @@ impl Context<'_> { } /// Insert ssa instructions which computes lhs >> rhs by doing lhs/2^rhs + /// For negative signed integers, we do the division on the 1-complement representation of lhs, + /// before converting back the result to the 2-complement representation. pub(crate) fn insert_shift_right( &mut self, lhs: ValueId, @@ -153,16 +155,27 @@ impl Context<'_> { ) -> ValueId { let lhs_typ = self.function.dfg.type_of_value(lhs); let base = self.field_constant(FieldElement::from(2_u128)); - // we can safely cast to unsigned because overflow_checks prevent bit-shift with a negative value - let rhs_unsigned = self.insert_cast(rhs, Type::unsigned(bit_size)); - let pow = self.pow(base, rhs_unsigned); - // We need at least one more bit for the case where rhs == bit_size - let div_type = Type::unsigned(bit_size + 1); - let casted_lhs = self.insert_cast(lhs, div_type.clone()); - let casted_pow = self.insert_cast(pow, div_type); - let div_result = self.insert_binary(casted_lhs, BinaryOp::Div, casted_pow); - // We have to cast back to the original type - self.insert_cast(div_result, lhs_typ) + let pow = self.pow(base, rhs); + if lhs_typ.is_unsigned() { + // unsigned right bit shift is just a normal division + self.insert_binary(lhs, BinaryOp::Div, pow) + } else { + // Get the sign of the operand; positive signed operand will just do a division as well + let zero = self.numeric_constant(FieldElement::zero(), Type::signed(bit_size)); + let lhs_sign = self.insert_binary(lhs, BinaryOp::Lt, zero); + let lhs_sign_as_field = self.insert_cast(lhs_sign, Type::field()); + let lhs_as_field = self.insert_cast(lhs, Type::field()); + // For negative numbers, convert to 1-complement using wrapping addition of a + 1 + let one_complement = self.insert_binary(lhs_sign_as_field, BinaryOp::Add, lhs_as_field); + let one_complement = self.insert_truncate(one_complement, bit_size, bit_size + 1); + let one_complement = self.insert_cast(one_complement, Type::signed(bit_size)); + // Performs the division on the 1-complement (or the operand if positive) + let shifted_complement = self.insert_binary(one_complement, BinaryOp::Div, pow); + // Convert back to 2-complement representation if operand is negative + let lhs_sign_as_int = self.insert_cast(lhs_sign, lhs_typ); + let shifted = self.insert_binary(shifted_complement, BinaryOp::Sub, lhs_sign_as_int); + self.insert_truncate(shifted, bit_size, bit_size + 1) + } } /// Computes lhs^rhs via square&multiply, using the bits decomposition of rhs diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser.rs new file mode 100644 index 000000000000..717d2691b2f7 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser.rs @@ -0,0 +1,902 @@ +use std::{ + fmt::{self, Debug, Formatter}, + sync::Arc, +}; + +use super::{ + ir::{instruction::BinaryOp, types::Type}, + Ssa, +}; + +use acvm::{AcirField, FieldElement}; +use ast::{ + Identifier, ParsedBlock, ParsedFunction, ParsedInstruction, ParsedParameter, ParsedSsa, + ParsedValue, +}; +use lexer::{Lexer, LexerError}; +use noirc_errors::Span; +use noirc_frontend::{monomorphization::ast::InlineType, token::IntType}; +use thiserror::Error; +use token::{Keyword, SpannedToken, Token}; + +use crate::ssa::{ir::function::RuntimeType, parser::ast::ParsedTerminator}; + +mod ast; +mod into_ssa; +mod lexer; +mod tests; +mod token; + +impl Ssa { + pub(crate) fn from_str(src: &str) -> Result { + let mut parser = + Parser::new(src).map_err(|err| SsaErrorWithSource::parse_error(err, src))?; + let parsed_ssa = + parser.parse_ssa().map_err(|err| SsaErrorWithSource::parse_error(err, src))?; + parsed_ssa.into_ssa().map_err(|error| SsaErrorWithSource { src: src.to_string(), error }) + } +} + +pub(crate) struct SsaErrorWithSource { + src: String, + error: SsaError, +} + +impl SsaErrorWithSource { + fn parse_error(error: ParserError, src: &str) -> Self { + Self { src: src.to_string(), error: SsaError::ParserError(error) } + } +} + +impl Debug for SsaErrorWithSource { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + let span = self.error.span(); + + let mut byte: usize = 0; + for line in self.src.lines() { + let has_error = + byte <= span.start() as usize && span.end() as usize <= byte + line.len(); + if has_error { + writeln!(f)?; + } + + writeln!(f, "{}", line)?; + + if has_error { + let offset = span.start() as usize - byte; + write!(f, "{}", " ".repeat(offset))?; + writeln!(f, "{}", "^".repeat((span.end() - span.start()) as usize))?; + write!(f, "{}", " ".repeat(offset))?; + writeln!(f, "{}", self.error)?; + writeln!(f)?; + } + + byte += line.len() + 1; // "+ 1" for the newline + } + Ok(()) + } +} + +#[derive(Debug, Error)] +pub(crate) enum SsaError { + #[error("{0}")] + ParserError(ParserError), + #[error("Unknown variable '{0}'")] + UnknownVariable(Identifier), + #[error("Unknown block '{0}'")] + UnknownBlock(Identifier), + #[error("Unknown function '{0}'")] + UnknownFunction(Identifier), + #[error("Mismatched return values")] + MismatchedReturnValues { returns: Vec, expected: usize }, + #[error("Variable '{0}' already defined")] + VariableAlreadyDefined(Identifier), +} + +impl SsaError { + fn span(&self) -> Span { + match self { + SsaError::ParserError(parser_error) => parser_error.span(), + SsaError::UnknownVariable(identifier) + | SsaError::UnknownBlock(identifier) + | SsaError::VariableAlreadyDefined(identifier) + | SsaError::UnknownFunction(identifier) => identifier.span, + SsaError::MismatchedReturnValues { returns, expected: _ } => returns[0].span, + } + } +} + +type ParseResult = Result; + +pub(crate) struct Parser<'a> { + lexer: Lexer<'a>, + token: SpannedToken, +} + +impl<'a> Parser<'a> { + pub(crate) fn new(source: &'a str) -> ParseResult { + let lexer = Lexer::new(source); + let mut parser = Self { lexer, token: eof_spanned_token() }; + parser.token = parser.read_token_internal()?; + Ok(parser) + } + + pub(crate) fn parse_ssa(&mut self) -> ParseResult { + let mut functions = Vec::new(); + while !self.at(Token::Eof) { + let function = self.parse_function()?; + functions.push(function); + } + Ok(ParsedSsa { functions }) + } + + fn parse_function(&mut self) -> ParseResult { + let runtime_type = self.parse_runtime_type()?; + self.eat_or_error(Token::Keyword(Keyword::Fn))?; + + let external_name = self.eat_ident_or_error()?; + let internal_name = self.eat_ident_or_error()?; + + self.eat_or_error(Token::LeftBrace)?; + + let blocks = self.parse_blocks()?; + + self.eat_or_error(Token::RightBrace)?; + + Ok(ParsedFunction { runtime_type, external_name, internal_name, blocks }) + } + + fn parse_runtime_type(&mut self) -> ParseResult { + let acir = if self.eat_keyword(Keyword::Acir)? { + true + } else if self.eat_keyword(Keyword::Brillig)? { + false + } else { + return self.expected_one_of_tokens(&[ + Token::Keyword(Keyword::Acir), + Token::Keyword(Keyword::Brillig), + ]); + }; + + self.eat_or_error(Token::LeftParen)?; + let inline_type = self.parse_inline_type()?; + self.eat_or_error(Token::RightParen)?; + + if acir { + Ok(RuntimeType::Acir(inline_type)) + } else { + Ok(RuntimeType::Brillig(inline_type)) + } + } + + fn parse_inline_type(&mut self) -> ParseResult { + if self.eat_keyword(Keyword::Inline)? { + Ok(InlineType::Inline) + } else if self.eat_keyword(Keyword::InlineAlways)? { + Ok(InlineType::InlineAlways) + } else if self.eat_keyword(Keyword::Fold)? { + Ok(InlineType::Fold) + } else if self.eat_keyword(Keyword::NoPredicates)? { + Ok(InlineType::NoPredicates) + } else { + self.expected_one_of_tokens(&[ + Token::Keyword(Keyword::Inline), + Token::Keyword(Keyword::InlineAlways), + Token::Keyword(Keyword::Fold), + Token::Keyword(Keyword::NoPredicates), + ]) + } + } + + fn parse_blocks(&mut self) -> ParseResult> { + let mut blocks = Vec::new(); + while !self.at(Token::RightBrace) { + let block = self.parse_block()?; + blocks.push(block); + } + Ok(blocks) + } + + fn parse_block(&mut self) -> ParseResult { + let name = self.eat_ident_or_error()?; + self.eat_or_error(Token::LeftParen)?; + + let mut parameters = Vec::new(); + while !self.at(Token::RightParen) { + parameters.push(self.parse_parameter()?); + if !self.eat(Token::Comma)? { + break; + } + } + + self.eat_or_error(Token::RightParen)?; + self.eat_or_error(Token::Colon)?; + + let instructions = self.parse_instructions()?; + let terminator = self.parse_terminator()?; + Ok(ParsedBlock { name, parameters, instructions, terminator }) + } + + fn parse_parameter(&mut self) -> ParseResult { + let identifier = self.eat_identifier_or_error()?; + self.eat_or_error(Token::Colon)?; + let typ = self.parse_type()?; + Ok(ParsedParameter { identifier, typ }) + } + + fn parse_instructions(&mut self) -> ParseResult> { + let mut instructions = Vec::new(); + while let Some(instruction) = self.parse_instruction()? { + instructions.push(instruction); + } + Ok(instructions) + } + + fn parse_instruction(&mut self) -> ParseResult> { + if let Some(instruction) = self.parse_call()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_constrain()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_decrement_rc()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_enable_side_effects()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_increment_rc()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_range_check()? { + return Ok(Some(instruction)); + } + + if let Some(instruction) = self.parse_store()? { + return Ok(Some(instruction)); + } + + if let Some(target) = self.eat_identifier()? { + return Ok(Some(self.parse_assignment(target)?)); + } + + Ok(None) + } + + fn eat_binary_op(&mut self) -> ParseResult> { + let op = match self.token.token() { + Token::Keyword(Keyword::Add) => BinaryOp::Add, + Token::Keyword(Keyword::Sub) => BinaryOp::Sub, + Token::Keyword(Keyword::Mul) => BinaryOp::Mul, + Token::Keyword(Keyword::Div) => BinaryOp::Div, + Token::Keyword(Keyword::Eq) => BinaryOp::Eq, + Token::Keyword(Keyword::Mod) => BinaryOp::Mod, + Token::Keyword(Keyword::Lt) => BinaryOp::Lt, + Token::Keyword(Keyword::And) => BinaryOp::And, + Token::Keyword(Keyword::Or) => BinaryOp::Or, + Token::Keyword(Keyword::Xor) => BinaryOp::Xor, + Token::Keyword(Keyword::Shl) => BinaryOp::Shl, + Token::Keyword(Keyword::Shr) => BinaryOp::Shr, + _ => return Ok(None), + }; + + self.bump()?; + + Ok(Some(op)) + } + + fn parse_call(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::Call)? { + return Ok(None); + } + + let function = self.eat_identifier_or_error()?; + let arguments = self.parse_arguments()?; + Ok(Some(ParsedInstruction::Call { targets: vec![], function, arguments, types: vec![] })) + } + + fn parse_constrain(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::Constrain)? { + return Ok(None); + } + + let lhs = self.parse_value_or_error()?; + self.eat_or_error(Token::Equal)?; + let rhs = self.parse_value_or_error()?; + Ok(Some(ParsedInstruction::Constrain { lhs, rhs })) + } + + fn parse_decrement_rc(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::DecRc)? { + return Ok(None); + } + + let value = self.parse_value_or_error()?; + Ok(Some(ParsedInstruction::DecrementRc { value })) + } + + fn parse_enable_side_effects(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::EnableSideEffects)? { + return Ok(None); + } + + let condition = self.parse_value_or_error()?; + Ok(Some(ParsedInstruction::EnableSideEffectsIf { condition })) + } + + fn parse_increment_rc(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::IncRc)? { + return Ok(None); + } + + let value = self.parse_value_or_error()?; + Ok(Some(ParsedInstruction::IncrementRc { value })) + } + + fn parse_range_check(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::RangeCheck)? { + return Ok(None); + } + + let value = self.parse_value_or_error()?; + self.eat_or_error(Token::Keyword(Keyword::To))?; + let max_bit_size = self.eat_int_or_error()?.to_u128() as u32; + self.eat_or_error(Token::Keyword(Keyword::Bits))?; + Ok(Some(ParsedInstruction::RangeCheck { value, max_bit_size })) + } + + fn parse_store(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::Store)? { + return Ok(None); + } + + let value = self.parse_value_or_error()?; + self.eat_or_error(Token::Keyword(Keyword::At))?; + let address = self.parse_value_or_error()?; + Ok(Some(ParsedInstruction::Store { address, value })) + } + + fn parse_assignment(&mut self, target: Identifier) -> ParseResult { + let mut targets = vec![target]; + + while self.eat(Token::Comma)? { + let target = self.eat_identifier_or_error()?; + targets.push(target); + } + + self.eat_or_error(Token::Assign)?; + + if self.eat_keyword(Keyword::Call)? { + let function = self.eat_identifier_or_error()?; + let arguments = self.parse_arguments()?; + self.eat_or_error(Token::Arrow)?; + let types = self.parse_types()?; + return Ok(ParsedInstruction::Call { targets, function, arguments, types }); + } + + if targets.len() > 1 { + return Err(ParserError::MultipleReturnValuesOnlyAllowedForCall { + second_target: targets[1].clone(), + }); + } + + let target = targets.remove(0); + + if self.eat_keyword(Keyword::Allocate)? { + self.eat_or_error(Token::Arrow)?; + let typ = self.parse_mutable_reference_type_or_error()?; + return Ok(ParsedInstruction::Allocate { target, typ }); + } + + if self.eat_keyword(Keyword::ArrayGet)? { + let array = self.parse_value_or_error()?; + self.eat_or_error(Token::Comma)?; + self.eat_or_error(Token::Keyword(Keyword::Index))?; + let index = self.parse_value_or_error()?; + self.eat_or_error(Token::Arrow)?; + let element_type = self.parse_type()?; + return Ok(ParsedInstruction::ArrayGet { target, element_type, array, index }); + } + + if self.eat_keyword(Keyword::ArraySet)? { + let mutable = self.eat_keyword(Keyword::Mut)?; + let array = self.parse_value_or_error()?; + self.eat_or_error(Token::Comma)?; + self.eat_or_error(Token::Keyword(Keyword::Index))?; + let index = self.parse_value_or_error()?; + self.eat_or_error(Token::Comma)?; + self.eat_or_error(Token::Keyword(Keyword::Value))?; + let value = self.parse_value_or_error()?; + return Ok(ParsedInstruction::ArraySet { target, array, index, value, mutable }); + } + + if self.eat_keyword(Keyword::Cast)? { + let lhs = self.parse_value_or_error()?; + self.eat_or_error(Token::Keyword(Keyword::As))?; + let typ = self.parse_type()?; + return Ok(ParsedInstruction::Cast { target, lhs, typ }); + } + + if self.eat_keyword(Keyword::Load)? { + let value = self.parse_value_or_error()?; + self.eat_or_error(Token::Arrow)?; + let typ = self.parse_type()?; + return Ok(ParsedInstruction::Load { target, value, typ }); + } + + if self.eat_keyword(Keyword::Not)? { + let value = self.parse_value_or_error()?; + return Ok(ParsedInstruction::Not { target, value }); + } + + if self.eat_keyword(Keyword::Truncate)? { + let value = self.parse_value_or_error()?; + self.eat_or_error(Token::Keyword(Keyword::To))?; + let bit_size = self.eat_int_or_error()?.to_u128() as u32; + self.eat_or_error(Token::Keyword(Keyword::Bits))?; + self.eat_or_error(Token::Comma)?; + self.eat_or_error(Token::Keyword(Keyword::MaxBitSize))?; + self.eat_or_error(Token::Colon)?; + let max_bit_size = self.eat_int_or_error()?.to_u128() as u32; + return Ok(ParsedInstruction::Truncate { target, value, bit_size, max_bit_size }); + } + + if let Some(op) = self.eat_binary_op()? { + let lhs = self.parse_value_or_error()?; + self.eat_or_error(Token::Comma)?; + let rhs = self.parse_value_or_error()?; + return Ok(ParsedInstruction::BinaryOp { target, lhs, op, rhs }); + } + + self.expected_instruction_or_terminator() + } + + fn parse_terminator(&mut self) -> ParseResult { + if let Some(terminator) = self.parse_return()? { + return Ok(terminator); + } + + if let Some(terminator) = self.parse_jmp()? { + return Ok(terminator); + } + + if let Some(terminator) = self.parse_jmpif()? { + return Ok(terminator); + } + + self.expected_instruction_or_terminator() + } + + fn parse_return(&mut self) -> ParseResult> { + // Before advancing to the next token (after a potential return keyword), + // we check if a newline follows. This is because if we have this: + // + // return + // b1(): + // ... + // + // then unless we check for a newline we can't know if the return + // returns `b1` or not (we could check if a parentheses comes next, but + // that would require a look-ahead and, for the purpose of the SSA parser, + // it's just simpler to check if a newline follows) + let newline_follows = self.newline_follows(); + + if !self.eat_keyword(Keyword::Return)? { + return Ok(None); + } + + let values = + if newline_follows { Vec::new() } else { self.parse_comma_separated_values()? }; + Ok(Some(ParsedTerminator::Return(values))) + } + + fn parse_jmp(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::Jmp)? { + return Ok(None); + } + + let destination = self.eat_identifier_or_error()?; + let arguments = self.parse_arguments()?; + Ok(Some(ParsedTerminator::Jmp { destination, arguments })) + } + + fn parse_jmpif(&mut self) -> ParseResult> { + if !self.eat_keyword(Keyword::Jmpif)? { + return Ok(None); + } + + let condition = self.parse_value_or_error()?; + self.eat_or_error(Token::Keyword(Keyword::Then))?; + self.eat_or_error(Token::Colon)?; + let then_block = self.eat_identifier_or_error()?; + self.eat_or_error(Token::Comma)?; + self.eat_or_error(Token::Keyword(Keyword::Else))?; + self.eat_or_error(Token::Colon)?; + let else_block = self.eat_identifier_or_error()?; + + Ok(Some(ParsedTerminator::Jmpif { condition, then_block, else_block })) + } + + fn parse_arguments(&mut self) -> ParseResult> { + self.eat_or_error(Token::LeftParen)?; + let arguments = self.parse_comma_separated_values()?; + self.eat_or_error(Token::RightParen)?; + Ok(arguments) + } + + fn parse_comma_separated_values(&mut self) -> ParseResult> { + let mut values = Vec::new(); + while let Some(value) = self.parse_value()? { + values.push(value); + if !self.eat(Token::Comma)? { + break; + } + } + Ok(values) + } + + fn parse_value_or_error(&mut self) -> ParseResult { + if let Some(value) = self.parse_value()? { + Ok(value) + } else { + self.expected_value() + } + } + + fn parse_value(&mut self) -> ParseResult> { + if let Some(value) = self.parse_field_value()? { + return Ok(Some(value)); + } + + if let Some(value) = self.parse_int_value()? { + return Ok(Some(value)); + } + + if let Some(value) = self.parse_array_value()? { + return Ok(Some(value)); + } + + if let Some(identifier) = self.eat_identifier()? { + return Ok(Some(ParsedValue::Variable(identifier))); + } + + Ok(None) + } + + fn parse_field_value(&mut self) -> ParseResult> { + if self.eat_keyword(Keyword::Field)? { + let constant = self.eat_int_or_error()?; + Ok(Some(ParsedValue::NumericConstant { constant, typ: Type::field() })) + } else { + Ok(None) + } + } + + fn parse_int_value(&mut self) -> ParseResult> { + if let Some(int_type) = self.eat_int_type()? { + let constant = self.eat_int_or_error()?; + let typ = match int_type { + IntType::Unsigned(bit_size) => Type::unsigned(bit_size), + IntType::Signed(bit_size) => Type::signed(bit_size), + }; + Ok(Some(ParsedValue::NumericConstant { constant, typ })) + } else { + Ok(None) + } + } + + fn parse_array_value(&mut self) -> ParseResult> { + if self.eat(Token::LeftBracket)? { + let values = self.parse_comma_separated_values()?; + self.eat_or_error(Token::RightBracket)?; + self.eat_or_error(Token::Keyword(Keyword::Of))?; + let types = self.parse_types()?; + let types_len = types.len(); + let values_len = values.len(); + Ok(Some(ParsedValue::Array { + typ: Type::Array(Arc::new(types), values_len / types_len), + values, + })) + } else { + Ok(None) + } + } + + fn parse_types(&mut self) -> ParseResult> { + if self.eat(Token::LeftParen)? { + let types = self.parse_comma_separated_types()?; + self.eat_or_error(Token::RightParen)?; + Ok(types) + } else { + Ok(vec![self.parse_type()?]) + } + } + + fn parse_comma_separated_types(&mut self) -> ParseResult> { + let mut types = Vec::new(); + loop { + let typ = self.parse_type()?; + types.push(typ); + if !self.eat(Token::Comma)? { + break; + } + } + Ok(types) + } + + fn parse_type(&mut self) -> ParseResult { + if self.eat_keyword(Keyword::Bool)? { + return Ok(Type::bool()); + } + + if self.eat_keyword(Keyword::Field)? { + return Ok(Type::field()); + } + + if let Some(int_type) = self.eat_int_type()? { + return Ok(match int_type { + IntType::Unsigned(bit_size) => Type::unsigned(bit_size), + IntType::Signed(bit_size) => Type::signed(bit_size), + }); + } + + if self.eat(Token::LeftBracket)? { + let element_types = self.parse_types()?; + if self.eat(Token::Semicolon)? { + let length = self.eat_int_or_error()?; + self.eat_or_error(Token::RightBracket)?; + return Ok(Type::Array(Arc::new(element_types), length.to_u128() as usize)); + } else { + self.eat_or_error(Token::RightBracket)?; + return Ok(Type::Slice(Arc::new(element_types))); + } + } + + if let Some(typ) = self.parse_mutable_reference_type()? { + return Ok(Type::Reference(Arc::new(typ))); + } + + self.expected_type() + } + + /// Parses `&mut Type`, returns `Type` if `&mut` was found, errors otherwise. + fn parse_mutable_reference_type_or_error(&mut self) -> ParseResult { + if let Some(typ) = self.parse_mutable_reference_type()? { + Ok(typ) + } else { + self.expected_token(Token::Ampersand) + } + } + + /// Parses `&mut Type`, returns `Some(Type)` if `&mut` was found, `None` otherwise. + fn parse_mutable_reference_type(&mut self) -> ParseResult> { + if !self.eat(Token::Ampersand)? { + return Ok(None); + } + + self.eat_or_error(Token::Keyword(Keyword::Mut))?; + let typ = self.parse_type()?; + Ok(Some(typ)) + } + + fn eat_identifier_or_error(&mut self) -> ParseResult { + if let Some(identifier) = self.eat_identifier()? { + Ok(identifier) + } else { + self.expected_identifier() + } + } + + fn eat_identifier(&mut self) -> ParseResult> { + let span = self.token.to_span(); + if let Some(name) = self.eat_ident()? { + Ok(Some(Identifier::new(name, span))) + } else { + Ok(None) + } + } + + fn eat_keyword(&mut self, keyword: Keyword) -> ParseResult { + if let Token::Keyword(kw) = self.token.token() { + if *kw == keyword { + self.bump()?; + Ok(true) + } else { + Ok(false) + } + } else { + Ok(false) + } + } + + fn eat_ident(&mut self) -> ParseResult> { + if !matches!(self.token.token(), Token::Ident(..)) { + return Ok(None); + } + + let token = self.bump()?; + match token.into_token() { + Token::Ident(ident) => Ok(Some(ident)), + _ => unreachable!(), + } + } + + fn eat_ident_or_error(&mut self) -> ParseResult { + if let Some(ident) = self.eat_ident()? { + Ok(ident) + } else { + self.expected_identifier() + } + } + + fn eat_int(&mut self) -> ParseResult> { + if matches!(self.token.token(), Token::Int(..)) { + let token = self.bump()?; + match token.into_token() { + Token::Int(int) => Ok(Some(int)), + _ => unreachable!(), + } + } else { + Ok(None) + } + } + + fn eat_int_or_error(&mut self) -> ParseResult { + if let Some(int) = self.eat_int()? { + Ok(int) + } else { + self.expected_int() + } + } + + fn eat_int_type(&mut self) -> ParseResult> { + let is_int_type = matches!(self.token.token(), Token::IntType(..)); + if is_int_type { + let token = self.bump()?; + match token.into_token() { + Token::IntType(int_type) => Ok(Some(int_type)), + _ => unreachable!(), + } + } else { + Ok(None) + } + } + + fn eat(&mut self, token: Token) -> ParseResult { + if self.token.token() == &token { + self.bump()?; + Ok(true) + } else { + Ok(false) + } + } + + fn eat_or_error(&mut self, token: Token) -> ParseResult<()> { + if self.eat(token.clone())? { + Ok(()) + } else { + self.expected_token(token) + } + } + + fn at(&self, token: Token) -> bool { + self.token.token() == &token + } + + fn at_keyword(&self, keyword: Keyword) -> bool { + self.at(Token::Keyword(keyword)) + } + + fn newline_follows(&self) -> bool { + self.lexer.newline_follows() + } + + fn bump(&mut self) -> ParseResult { + let token = self.read_token_internal()?; + Ok(std::mem::replace(&mut self.token, token)) + } + + fn read_token_internal(&mut self) -> ParseResult { + self.lexer.next_token().map_err(ParserError::LexerError) + } + + fn expected_instruction_or_terminator(&mut self) -> ParseResult { + Err(ParserError::ExpectedInstructionOrTerminator { + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_identifier(&mut self) -> ParseResult { + Err(ParserError::ExpectedIdentifier { + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_int(&mut self) -> ParseResult { + Err(ParserError::ExpectedInt { + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_type(&mut self) -> ParseResult { + Err(ParserError::ExpectedType { + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_value(&mut self) -> ParseResult { + Err(ParserError::ExpectedValue { + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_token(&mut self, token: Token) -> ParseResult { + Err(ParserError::ExpectedToken { + token, + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } + + fn expected_one_of_tokens(&mut self, tokens: &[Token]) -> ParseResult { + Err(ParserError::ExpectedOneOfTokens { + tokens: tokens.to_vec(), + found: self.token.token().clone(), + span: self.token.to_span(), + }) + } +} + +#[derive(Debug, Error)] +pub(crate) enum ParserError { + #[error("{0}")] + LexerError(LexerError), + #[error("Expected '{token}', found '{found}'")] + ExpectedToken { token: Token, found: Token, span: Span }, + #[error("Expected one of {tokens:?}, found {found}")] + ExpectedOneOfTokens { tokens: Vec, found: Token, span: Span }, + #[error("Expected an identifier, found '{found}'")] + ExpectedIdentifier { found: Token, span: Span }, + #[error("Expected an int, found '{found}'")] + ExpectedInt { found: Token, span: Span }, + #[error("Expected a type, found '{found}'")] + ExpectedType { found: Token, span: Span }, + #[error("Expected an instruction or terminator, found '{found}'")] + ExpectedInstructionOrTerminator { found: Token, span: Span }, + #[error("Expected a value, found '{found}'")] + ExpectedValue { found: Token, span: Span }, + #[error("Multiple return values only allowed for call")] + MultipleReturnValuesOnlyAllowedForCall { second_target: Identifier }, +} + +impl ParserError { + fn span(&self) -> Span { + match self { + ParserError::LexerError(err) => err.span(), + ParserError::ExpectedToken { span, .. } + | ParserError::ExpectedOneOfTokens { span, .. } + | ParserError::ExpectedIdentifier { span, .. } + | ParserError::ExpectedInt { span, .. } + | ParserError::ExpectedType { span, .. } + | ParserError::ExpectedInstructionOrTerminator { span, .. } + | ParserError::ExpectedValue { span, .. } => *span, + ParserError::MultipleReturnValuesOnlyAllowedForCall { second_target, .. } => { + second_target.span + } + } + } +} + +fn eof_spanned_token() -> SpannedToken { + SpannedToken::new(Token::Eof, Default::default()) +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/ast.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/ast.rs new file mode 100644 index 000000000000..f8fe8c68a98d --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/ast.rs @@ -0,0 +1,139 @@ +use std::fmt::{self, Display, Formatter}; + +use acvm::FieldElement; +use noirc_errors::Span; + +use crate::ssa::ir::{function::RuntimeType, instruction::BinaryOp, types::Type}; + +#[derive(Debug)] +pub(crate) struct ParsedSsa { + pub(crate) functions: Vec, +} + +#[derive(Debug)] +pub(crate) struct ParsedFunction { + pub(crate) runtime_type: RuntimeType, + pub(crate) external_name: String, + pub(crate) internal_name: String, + pub(crate) blocks: Vec, +} + +#[derive(Debug)] +pub(crate) struct ParsedBlock { + pub(crate) name: String, + pub(crate) parameters: Vec, + pub(crate) instructions: Vec, + pub(crate) terminator: ParsedTerminator, +} + +#[derive(Debug)] +pub(crate) struct ParsedParameter { + pub(crate) identifier: Identifier, + pub(crate) typ: Type, +} + +#[derive(Debug, Clone)] +pub(crate) struct Identifier { + pub(crate) name: String, + pub(crate) span: Span, +} + +impl Identifier { + pub(crate) fn new(name: String, span: Span) -> Self { + Self { name, span } + } +} + +impl Display for Identifier { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.name) + } +} + +#[derive(Debug)] +pub(crate) enum ParsedInstruction { + Allocate { + target: Identifier, + typ: Type, + }, + ArrayGet { + target: Identifier, + element_type: Type, + array: ParsedValue, + index: ParsedValue, + }, + ArraySet { + target: Identifier, + array: ParsedValue, + index: ParsedValue, + value: ParsedValue, + mutable: bool, + }, + BinaryOp { + target: Identifier, + lhs: ParsedValue, + op: BinaryOp, + rhs: ParsedValue, + }, + Call { + targets: Vec, + function: Identifier, + arguments: Vec, + types: Vec, + }, + Cast { + target: Identifier, + lhs: ParsedValue, + typ: Type, + }, + Constrain { + lhs: ParsedValue, + rhs: ParsedValue, + }, + DecrementRc { + value: ParsedValue, + }, + EnableSideEffectsIf { + condition: ParsedValue, + }, + IncrementRc { + value: ParsedValue, + }, + Load { + target: Identifier, + value: ParsedValue, + typ: Type, + }, + Not { + target: Identifier, + value: ParsedValue, + }, + RangeCheck { + value: ParsedValue, + max_bit_size: u32, + }, + Store { + value: ParsedValue, + address: ParsedValue, + }, + Truncate { + target: Identifier, + value: ParsedValue, + bit_size: u32, + max_bit_size: u32, + }, +} + +#[derive(Debug)] +pub(crate) enum ParsedTerminator { + Jmp { destination: Identifier, arguments: Vec }, + Jmpif { condition: ParsedValue, then_block: Identifier, else_block: Identifier }, + Return(Vec), +} + +#[derive(Debug)] +pub(crate) enum ParsedValue { + NumericConstant { constant: FieldElement, typ: Type }, + Array { values: Vec, typ: Type }, + Variable(Identifier), +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/into_ssa.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/into_ssa.rs new file mode 100644 index 000000000000..2a94a4fd1eb9 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/into_ssa.rs @@ -0,0 +1,317 @@ +use std::collections::HashMap; + +use im::Vector; + +use crate::ssa::{ + function_builder::FunctionBuilder, + ir::{basic_block::BasicBlockId, function::FunctionId, value::ValueId}, +}; + +use super::{ + Identifier, ParsedBlock, ParsedFunction, ParsedInstruction, ParsedSsa, ParsedTerminator, + ParsedValue, RuntimeType, Ssa, SsaError, +}; + +impl ParsedSsa { + pub(crate) fn into_ssa(self) -> Result { + Translator::translate(self) + } +} + +struct Translator { + builder: FunctionBuilder, + + /// Maps function names to their IDs + functions: HashMap, + + /// Maps block names to their IDs + blocks: HashMap>, + + /// Maps variable names to their IDs + variables: HashMap>, +} + +impl Translator { + fn translate(mut parsed_ssa: ParsedSsa) -> Result { + let mut translator = Self::new(&mut parsed_ssa)?; + + // Note that the `new` call above removed the main function, + // so all we are left with are non-main functions. + for function in parsed_ssa.functions { + translator.translate_non_main_function(function)?; + } + + Ok(translator.finish()) + } + + fn new(parsed_ssa: &mut ParsedSsa) -> Result { + // A FunctionBuilder must be created with a main Function, so here wer remove it + // from the parsed SSA to avoid adding it twice later on. + let main_function = parsed_ssa.functions.remove(0); + let main_id = FunctionId::new(0); + let mut builder = FunctionBuilder::new(main_function.external_name.clone(), main_id); + builder.set_runtime(main_function.runtime_type); + + // Map function names to their IDs so calls can be resolved + let mut function_id_counter = 1; + let mut functions = HashMap::new(); + for function in &parsed_ssa.functions { + let function_id = FunctionId::new(function_id_counter); + function_id_counter += 1; + + functions.insert(function.internal_name.clone(), function_id); + } + + let mut translator = + Self { builder, functions, variables: HashMap::new(), blocks: HashMap::new() }; + translator.translate_function_body(main_function)?; + + Ok(translator) + } + + fn translate_non_main_function(&mut self, function: ParsedFunction) -> Result<(), SsaError> { + let function_id = self.functions[&function.internal_name]; + let external_name = function.external_name.clone(); + + match function.runtime_type { + RuntimeType::Acir(inline_type) => { + self.builder.new_function(external_name, function_id, inline_type); + } + RuntimeType::Brillig(inline_type) => { + self.builder.new_brillig_function(external_name, function_id, inline_type); + } + } + + self.translate_function_body(function) + } + + fn translate_function_body(&mut self, function: ParsedFunction) -> Result<(), SsaError> { + // First define all blocks so that they are known (a block might jump to a block that comes next) + for (index, block) in function.blocks.iter().enumerate() { + // The first block is the entry block and it was automatically created by the builder + let block_id = if index == 0 { + self.builder.current_function.entry_block() + } else { + self.builder.insert_block() + }; + let entry = self.blocks.entry(self.current_function_id()).or_default(); + entry.insert(block.name.clone(), block_id); + } + + for block in function.blocks { + self.translate_block(block)?; + } + + Ok(()) + } + + fn translate_block(&mut self, block: ParsedBlock) -> Result<(), SsaError> { + let block_id = self.blocks[&self.current_function_id()][&block.name]; + self.builder.switch_to_block(block_id); + + for parameter in block.parameters { + let parameter_value_id = self.builder.add_block_parameter(block_id, parameter.typ); + self.define_variable(parameter.identifier, parameter_value_id)?; + } + + for instruction in block.instructions { + self.translate_instruction(instruction)?; + } + + match block.terminator { + ParsedTerminator::Jmp { destination, arguments } => { + let block_id = self.lookup_block(destination)?; + let arguments = self.translate_values(arguments)?; + self.builder.terminate_with_jmp(block_id, arguments); + } + ParsedTerminator::Jmpif { condition, then_block, else_block } => { + let condition = self.translate_value(condition)?; + let then_destination = self.lookup_block(then_block)?; + let else_destination = self.lookup_block(else_block)?; + self.builder.terminate_with_jmpif(condition, then_destination, else_destination); + } + ParsedTerminator::Return(values) => { + let return_values = self.translate_values(values)?; + self.builder.terminate_with_return(return_values); + } + } + + Ok(()) + } + + fn translate_instruction(&mut self, instruction: ParsedInstruction) -> Result<(), SsaError> { + match instruction { + ParsedInstruction::Allocate { target, typ } => { + let value_id = self.builder.insert_allocate(typ); + self.define_variable(target, value_id)?; + } + ParsedInstruction::ArrayGet { target, element_type, array, index } => { + let array = self.translate_value(array)?; + let index = self.translate_value(index)?; + let value_id = self.builder.insert_array_get(array, index, element_type); + self.define_variable(target, value_id)?; + } + ParsedInstruction::ArraySet { target, array, index, value, mutable } => { + let array = self.translate_value(array)?; + let index = self.translate_value(index)?; + let value = self.translate_value(value)?; + let value_id = if mutable { + self.builder.insert_mutable_array_set(array, index, value) + } else { + self.builder.insert_array_set(array, index, value) + }; + self.define_variable(target, value_id)?; + } + ParsedInstruction::BinaryOp { target, lhs, op, rhs } => { + let lhs = self.translate_value(lhs)?; + let rhs = self.translate_value(rhs)?; + let value_id = self.builder.insert_binary(lhs, op, rhs); + self.define_variable(target, value_id)?; + } + ParsedInstruction::Call { targets, function, arguments, types } => { + let function_id = if let Some(id) = self.builder.import_intrinsic(&function.name) { + id + } else { + let function_id = self.lookup_function(function)?; + self.builder.import_function(function_id) + }; + + let arguments = self.translate_values(arguments)?; + + let value_ids = self.builder.insert_call(function_id, arguments, types).to_vec(); + + if value_ids.len() != targets.len() { + return Err(SsaError::MismatchedReturnValues { + returns: targets, + expected: value_ids.len(), + }); + } + + for (target, value_id) in targets.into_iter().zip(value_ids.into_iter()) { + self.define_variable(target, value_id)?; + } + } + ParsedInstruction::Cast { target, lhs, typ } => { + let lhs = self.translate_value(lhs)?; + let value_id = self.builder.insert_cast(lhs, typ); + self.define_variable(target, value_id)?; + } + ParsedInstruction::Constrain { lhs, rhs } => { + let lhs = self.translate_value(lhs)?; + let rhs = self.translate_value(rhs)?; + self.builder.insert_constrain(lhs, rhs, None); + } + ParsedInstruction::DecrementRc { value } => { + let value = self.translate_value(value)?; + self.builder.decrement_array_reference_count(value); + } + ParsedInstruction::EnableSideEffectsIf { condition } => { + let condition = self.translate_value(condition)?; + self.builder.insert_enable_side_effects_if(condition); + } + ParsedInstruction::IncrementRc { value } => { + let value = self.translate_value(value)?; + self.builder.increment_array_reference_count(value); + } + ParsedInstruction::Load { target, value, typ } => { + let value = self.translate_value(value)?; + let value_id = self.builder.insert_load(value, typ); + self.define_variable(target, value_id)?; + } + ParsedInstruction::Not { target, value } => { + let value = self.translate_value(value)?; + let value_id = self.builder.insert_not(value); + self.define_variable(target, value_id)?; + } + ParsedInstruction::RangeCheck { value, max_bit_size } => { + let value = self.translate_value(value)?; + self.builder.insert_range_check(value, max_bit_size, None); + } + ParsedInstruction::Store { value, address } => { + let value = self.translate_value(value)?; + let address = self.translate_value(address)?; + self.builder.insert_store(address, value); + } + ParsedInstruction::Truncate { target, value, bit_size, max_bit_size } => { + let value = self.translate_value(value)?; + let value_id = self.builder.insert_truncate(value, bit_size, max_bit_size); + self.define_variable(target, value_id)?; + } + } + + Ok(()) + } + + fn translate_values(&mut self, values: Vec) -> Result, SsaError> { + let mut translated_values = Vec::with_capacity(values.len()); + for value in values { + translated_values.push(self.translate_value(value)?); + } + Ok(translated_values) + } + + fn translate_value(&mut self, value: ParsedValue) -> Result { + match value { + ParsedValue::NumericConstant { constant, typ } => { + Ok(self.builder.numeric_constant(constant, typ)) + } + ParsedValue::Array { values, typ } => { + let mut translated_values = Vector::new(); + for value in values { + translated_values.push_back(self.translate_value(value)?); + } + Ok(self.builder.array_constant(translated_values, typ)) + } + ParsedValue::Variable(identifier) => self.lookup_variable(identifier), + } + } + + fn define_variable( + &mut self, + identifier: Identifier, + value_id: ValueId, + ) -> Result<(), SsaError> { + if let Some(vars) = self.variables.get(&self.current_function_id()) { + if vars.contains_key(&identifier.name) { + return Err(SsaError::VariableAlreadyDefined(identifier)); + } + } + + let entry = self.variables.entry(self.current_function_id()).or_default(); + entry.insert(identifier.name, value_id); + + Ok(()) + } + + fn lookup_variable(&mut self, identifier: Identifier) -> Result { + if let Some(value_id) = self.variables[&self.current_function_id()].get(&identifier.name) { + Ok(*value_id) + } else { + Err(SsaError::UnknownVariable(identifier)) + } + } + + fn lookup_block(&mut self, identifier: Identifier) -> Result { + if let Some(block_id) = self.blocks[&self.current_function_id()].get(&identifier.name) { + Ok(*block_id) + } else { + Err(SsaError::UnknownBlock(identifier)) + } + } + + fn lookup_function(&mut self, identifier: Identifier) -> Result { + if let Some(function_id) = self.functions.get(&identifier.name) { + Ok(*function_id) + } else { + Err(SsaError::UnknownFunction(identifier)) + } + } + + fn finish(self) -> Ssa { + self.builder.finish() + } + + fn current_function_id(&self) -> FunctionId { + self.builder.current_function.id() + } +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/lexer.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/lexer.rs new file mode 100644 index 000000000000..ac4c3b772050 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/lexer.rs @@ -0,0 +1,259 @@ +use std::str::{CharIndices, FromStr}; + +use acvm::{AcirField, FieldElement}; +use noirc_errors::{Position, Span}; +use noirc_frontend::token::IntType; +use num_bigint::BigInt; +use num_traits::{Num, One}; +use thiserror::Error; + +use super::token::{Keyword, SpannedToken, Token}; + +pub(crate) struct Lexer<'a> { + chars: CharIndices<'a>, + position: Position, + done: bool, + max_integer: BigInt, +} + +impl<'a> Lexer<'a> { + pub(crate) fn new(source: &'a str) -> Self { + Lexer { + chars: source.char_indices(), + position: 0, + done: false, + max_integer: BigInt::from_biguint(num_bigint::Sign::Plus, FieldElement::modulus()) + - BigInt::one(), + } + } + + pub(crate) fn next_token(&mut self) -> SpannedTokenResult { + match self.next_char() { + Some(char) if char.is_ascii_whitespace() => { + while let Some(char) = self.peek_char() { + if char.is_ascii_whitespace() { + self.next_char(); + } else { + break; + } + } + self.next_token() + } + Some('/') if self.peek_char() == Some('/') => { + while let Some(char) = self.next_char() { + if char == '\n' { + break; + } + } + self.next_token() + } + Some('=') if self.peek_char() == Some('=') => self.double_char_token(Token::Equal), + Some('=') => self.single_char_token(Token::Assign), + Some(',') => self.single_char_token(Token::Comma), + Some(':') => self.single_char_token(Token::Colon), + Some(';') => self.single_char_token(Token::Semicolon), + Some('(') => self.single_char_token(Token::LeftParen), + Some(')') => self.single_char_token(Token::RightParen), + Some('{') => self.single_char_token(Token::LeftBrace), + Some('}') => self.single_char_token(Token::RightBrace), + Some('[') => self.single_char_token(Token::LeftBracket), + Some(']') => self.single_char_token(Token::RightBracket), + Some('&') => self.single_char_token(Token::Ampersand), + Some('-') if self.peek_char() == Some('>') => self.double_char_token(Token::Arrow), + Some(ch) if ch.is_ascii_alphanumeric() || ch == '_' => self.eat_alpha_numeric(ch), + Some(char) => Err(LexerError::UnexpectedCharacter { + char, + span: Span::single_char(self.position), + }), + None => { + self.done = true; + Ok(Token::Eof.into_single_span(self.position)) + } + } + } + + fn eat_alpha_numeric(&mut self, initial_char: char) -> SpannedTokenResult { + match initial_char { + 'A'..='Z' | 'a'..='z' | '_' => Ok(self.eat_word(initial_char)?), + '0'..='9' => self.eat_digit(initial_char), + _ => Err(LexerError::UnexpectedCharacter { + char: initial_char, + span: Span::single_char(self.position), + }), + } + } + + fn eat_word(&mut self, initial_char: char) -> SpannedTokenResult { + let (start, word, end) = self.lex_word(initial_char); + self.lookup_word_token(word, start, end) + } + + fn lex_word(&mut self, initial_char: char) -> (Position, String, Position) { + let start = self.position; + let word = self.eat_while(Some(initial_char), |ch| { + ch.is_ascii_alphabetic() || ch.is_numeric() || ch == '_' + }); + (start, word, self.position) + } + + fn lookup_word_token( + &self, + word: String, + start: Position, + end: Position, + ) -> SpannedTokenResult { + // Check if word either an identifier or a keyword + if let Some(keyword_token) = Keyword::lookup_keyword(&word) { + return Ok(keyword_token.into_span(start, end)); + } + + // Check if word an int type + // if no error occurred, then it is either a valid integer type or it is not an int type + let parsed_token = IntType::lookup_int_type(&word); + + // Check if it is an int type + if let Some(int_type) = parsed_token { + return Ok(Token::IntType(int_type).into_span(start, end)); + } + + // Else it is just an identifier + let ident_token = Token::Ident(word); + Ok(ident_token.into_span(start, end)) + } + + fn eat_digit(&mut self, initial_char: char) -> SpannedTokenResult { + let start = self.position; + + let integer_str = self.eat_while(Some(initial_char), |ch| { + ch.is_ascii_digit() | ch.is_ascii_hexdigit() | (ch == 'x') | (ch == '_') + }); + + let end = self.position; + + // We want to enforce some simple rules about usage of underscores: + // 1. Underscores cannot appear at the end of a integer literal. e.g. 0x123_. + // 2. There cannot be more than one underscore consecutively, e.g. 0x5__5, 5__5. + // + // We're not concerned with an underscore at the beginning of a decimal literal + // such as `_5` as this would be lexed into an ident rather than an integer literal. + let invalid_underscore_location = integer_str.ends_with('_'); + let consecutive_underscores = integer_str.contains("__"); + if invalid_underscore_location || consecutive_underscores { + return Err(LexerError::InvalidIntegerLiteral { + span: Span::inclusive(start, end), + found: integer_str, + }); + } + + // Underscores needs to be stripped out before the literal can be converted to a `FieldElement. + let integer_str = integer_str.replace('_', ""); + + let bigint_result = match integer_str.strip_prefix("0x") { + Some(integer_str) => BigInt::from_str_radix(integer_str, 16), + None => BigInt::from_str(&integer_str), + }; + + let integer = match bigint_result { + Ok(bigint) => { + if bigint > self.max_integer { + return Err(LexerError::IntegerLiteralTooLarge { + span: Span::inclusive(start, end), + limit: self.max_integer.to_string(), + }); + } + let big_uint = bigint.magnitude(); + FieldElement::from_be_bytes_reduce(&big_uint.to_bytes_be()) + } + Err(_) => { + return Err(LexerError::InvalidIntegerLiteral { + span: Span::inclusive(start, end), + found: integer_str, + }) + } + }; + + let integer_token = Token::Int(integer); + Ok(integer_token.into_span(start, end)) + } + + fn eat_while bool>( + &mut self, + initial_char: Option, + predicate: F, + ) -> String { + // This function is only called when we want to continue consuming a character of the same type. + // For example, we see a digit and we want to consume the whole integer + // Therefore, the current character which triggered this function will need to be appended + let mut word = String::new(); + if let Some(init_char) = initial_char { + word.push(init_char); + } + + // Keep checking that we are not at the EOF + while let Some(peek_char) = self.peek_char() { + // Then check for the predicate, if predicate matches append char and increment the cursor + // If not, return word. The next character will be analyzed on the next iteration of next_token, + // Which will increment the cursor + if !predicate(peek_char) { + return word; + } + word.push(peek_char); + + // If we arrive at this point, then the char has been added to the word and we should increment the cursor + self.next_char(); + } + + word + } + + fn single_char_token(&self, token: Token) -> SpannedTokenResult { + Ok(token.into_single_span(self.position)) + } + + fn double_char_token(&mut self, token: Token) -> SpannedTokenResult { + let start_position = self.position; + self.next_char(); + Ok(token.into_span(start_position, self.position)) + } + + fn next_char(&mut self) -> Option { + let (position, ch) = self.chars.next()?; + self.position = position as u32; + Some(ch) + } + + fn peek_char(&self) -> Option { + self.chars.clone().next().map(|(_, ch)| ch) + } + + fn is_code_whitespace(c: char) -> bool { + c.is_ascii_whitespace() + } + + pub(crate) fn newline_follows(&self) -> bool { + let chars = self.chars.clone(); + chars.take_while(|(_, char)| char.is_ascii_whitespace()).any(|(_, char)| char == '\n') + } +} + +type SpannedTokenResult = Result; + +#[derive(Debug, Error)] +pub(crate) enum LexerError { + #[error("Unexpected character: {char:?}")] + UnexpectedCharacter { char: char, span: Span }, + #[error("Invalid integer literal")] + InvalidIntegerLiteral { span: Span, found: String }, + #[error("Integer literal too large")] + IntegerLiteralTooLarge { span: Span, limit: String }, +} + +impl LexerError { + pub(crate) fn span(&self) -> Span { + match self { + LexerError::UnexpectedCharacter { span, .. } + | LexerError::InvalidIntegerLiteral { span, .. } + | LexerError::IntegerLiteralTooLarge { span, .. } => *span, + } + } +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/tests.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/tests.rs new file mode 100644 index 000000000000..3ed6be57b5e9 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/tests.rs @@ -0,0 +1,427 @@ +#![cfg(test)] + +use crate::{ + ssa::{opt::assert_normalized_ssa_equals, Ssa}, + trim_leading_whitespace_from_lines, +}; + +fn assert_ssa_roundtrip(src: &str) { + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.to_string(); + let ssa = trim_leading_whitespace_from_lines(&ssa); + let src = trim_leading_whitespace_from_lines(src); + if ssa != src { + println!("Expected:\n~~~\n{}\n~~~\nGot:\n~~~\n{}\n~~~", src, ssa); + similar_asserts::assert_eq!(ssa, src); + } +} + +#[test] +fn test_empty_acir_function() { + let src = " + acir(inline) fn main f0 { + b0(): + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_empty_brillig_function() { + let src = " + brillig(inline) fn main f0 { + b0(): + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_return_integer() { + for typ in ["u1", "u8", "u16", "u32", "u64", "i1", "i8", "i16", "i32", "i64", "Field"] { + let src = format!( + " + acir(inline) fn main f0 {{ + b0(): + return {typ} 1 + }} + " + ); + assert_ssa_roundtrip(&src); + } +} + +#[test] +fn test_return_array() { + let src = " + acir(inline) fn main f0 { + b0(): + return [Field 1] of Field + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_return_empty_array() { + let src = " + acir(inline) fn main f0 { + b0(): + return [] of Field + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_return_composite_array() { + let src = " + acir(inline) fn main f0 { + b0(): + return [Field 1, Field 2] of (Field, Field) + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_block_parameters() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field, v1: Field): + return v0, v1 + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_multiple_blocks_and_jmp() { + let src = " + acir(inline) fn main f0 { + b0(): + jmp b1(Field 1) + b1(v1: Field): + return v1 + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_jmpif() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + jmpif v0 then: b1, else: b2 + b1(): + return + b2(): + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_call() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v2 = call f1(v0) -> Field + return v2 + } + acir(inline) fn foo f1 { + b0(v0: Field): + return v0 + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_call_multiple_return_values() { + let src = " + acir(inline) fn main f0 { + b0(): + v1, v2 = call f1() -> ([Field; 3], [Field; 1]) + return v1 + } + acir(inline) fn foo f1 { + b0(): + return [Field 1, Field 2, Field 3] of Field, [Field 4] of Field + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_call_no_return_value() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + call f1(v0) + return + } + acir(inline) fn foo f1 { + b0(v0: Field): + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_call_intrinsic() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + call assert_constant(v0) + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_cast() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v1 = cast v0 as i32 + return v1 + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_constrain() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + constrain v0 == Field 1 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_enable_side_effects() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + enable_side_effects v0 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_array_get() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v2 = array_get v0, index Field 0 -> Field + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_array_set() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v3 = array_set v0, index Field 0, value Field 1 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_mutable_array_set() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v3 = array_set mut v0, index Field 0, value Field 1 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_array_get_set_bug() { + let src = " + acir(inline) fn main f0 { + b0(v0: [u32; 3]): + v3 = array_set v0, index u32 1, value u32 2 + v5 = array_get v3, index u32 0 -> u32 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_binary() { + for op in ["add", "sub", "mul", "div", "eq", "mod", "lt", "and", "or", "xor", "shl", "shr"] { + let src = format!( + " + acir(inline) fn main f0 {{ + b0(v0: Field, v1: Field): + v2 = {op} v0, v1 + return + }} + " + ); + assert_ssa_roundtrip(&src); + } +} + +#[test] +fn test_truncate() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v1 = truncate v0 to 8 bits, max_bit_size: 16 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_not() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v1 = not v0 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_range_check() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + range_check v0 to 8 bits + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_allocate() { + let src = " + acir(inline) fn main f0 { + b0(): + v0 = allocate -> &mut [Field; 3] + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_load() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + v1 = load v0 -> Field + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_store() { + let src = " + acir(inline) fn main f0 { + b0(v0: Field): + store Field 1 at v0 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_inc_rc() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + inc_rc v0 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_dec_rc() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + dec_rc v0 + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_mutable_reference_type() { + let src = " + acir(inline) fn main f0 { + b0(v0: &mut Field): + return + } + "; + assert_ssa_roundtrip(src); +} + +#[test] +fn test_parses_with_comments() { + let src = " + // This is a comment + acir(inline) fn main f0 { + b0(v0: &mut Field): // This is a block + return // Returns nothing + } + "; + + let expected = " + acir(inline) fn main f0 { + b0(v0: &mut Field): + return + } + "; + + let ssa = Ssa::from_str(src).unwrap(); + assert_normalized_ssa_equals(ssa, expected); +} + +#[test] +fn test_slice() { + let src = " + acir(inline) fn main f0 { + b0(v0: [Field; 3]): + v2, v3 = call as_slice(v0) -> (u32, [Field]) + return + } + "; + assert_ssa_roundtrip(src); +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/token.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/token.rs new file mode 100644 index 000000000000..41c4f9ca1645 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/parser/token.rs @@ -0,0 +1,269 @@ +use std::fmt::Display; + +use acvm::FieldElement; +use noirc_errors::{Position, Span, Spanned}; +use noirc_frontend::token::IntType; + +#[derive(Debug)] +pub(crate) struct SpannedToken(Spanned); + +impl SpannedToken { + pub(crate) fn new(token: Token, span: Span) -> SpannedToken { + SpannedToken(Spanned::from(span, token)) + } + + pub(crate) fn to_span(&self) -> Span { + self.0.span() + } + + pub(crate) fn token(&self) -> &Token { + &self.0.contents + } + + pub(crate) fn into_token(self) -> Token { + self.0.contents + } +} + +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub(crate) enum Token { + Ident(String), + Int(FieldElement), + Keyword(Keyword), + IntType(IntType), + /// = + Assign, + /// ( + LeftParen, + /// ) + RightParen, + /// { + LeftBrace, + /// } + RightBrace, + /// [ + LeftBracket, + /// ] + RightBracket, + /// , + Comma, + /// : + Colon, + /// ; + Semicolon, + /// -> + Arrow, + /// == + Equal, + /// & + Ampersand, + Eof, +} + +impl Token { + pub(super) fn into_single_span(self, position: Position) -> SpannedToken { + self.into_span(position, position) + } + + pub(super) fn into_span(self, start: Position, end: Position) -> SpannedToken { + SpannedToken(Spanned::from_position(start, end, self)) + } +} + +impl Display for Token { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Token::Ident(ident) => write!(f, "{}", ident), + Token::Int(int) => write!(f, "{}", int), + Token::Keyword(keyword) => write!(f, "{}", keyword), + Token::IntType(int_type) => write!(f, "{}", int_type), + Token::Assign => write!(f, "="), + Token::LeftParen => write!(f, "("), + Token::RightParen => write!(f, ")"), + Token::LeftBrace => write!(f, "{{"), + Token::RightBrace => write!(f, "}}"), + Token::LeftBracket => write!(f, "["), + Token::RightBracket => write!(f, "]"), + Token::Comma => write!(f, ","), + Token::Colon => write!(f, ":"), + Token::Semicolon => write!(f, ";"), + Token::Arrow => write!(f, "->"), + Token::Equal => write!(f, "=="), + Token::Ampersand => write!(f, "&"), + Token::Eof => write!(f, "(end of stream)"), + } + } +} + +impl std::fmt::Debug for Token { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self) + } +} + +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub(crate) enum Keyword { + Acir, + Add, + Allocate, + And, + ArrayGet, + ArraySet, + As, + At, + Bits, + Bool, + Brillig, + Call, + Cast, + Constrain, + DecRc, + Div, + Inline, + InlineAlways, + Else, + EnableSideEffects, + Eq, + Field, + Fold, + Fn, + IncRc, + Index, + Jmp, + Jmpif, + Load, + Lt, + MaxBitSize, + Mod, + Mul, + Mut, + NoPredicates, + Not, + Of, + Or, + RangeCheck, + Return, + Shl, + Shr, + Store, + Sub, + Then, + To, + Truncate, + Value, + Xor, +} + +impl Keyword { + pub(crate) fn lookup_keyword(word: &str) -> Option { + let keyword = match word { + "acir" => Keyword::Acir, + "add" => Keyword::Add, + "allocate" => Keyword::Allocate, + "and" => Keyword::And, + "array_get" => Keyword::ArrayGet, + "array_set" => Keyword::ArraySet, + "as" => Keyword::As, + "at" => Keyword::At, + "bits" => Keyword::Bits, + "bool" => Keyword::Bool, + "brillig" => Keyword::Brillig, + "call" => Keyword::Call, + "cast" => Keyword::Cast, + "constrain" => Keyword::Constrain, + "dec_rc" => Keyword::DecRc, + "div" => Keyword::Div, + "else" => Keyword::Else, + "enable_side_effects" => Keyword::EnableSideEffects, + "eq" => Keyword::Eq, + "inline" => Keyword::Inline, + "inline_always" => Keyword::InlineAlways, + "Field" => Keyword::Field, + "fold" => Keyword::Fold, + "fn" => Keyword::Fn, + "inc_rc" => Keyword::IncRc, + "index" => Keyword::Index, + "jmp" => Keyword::Jmp, + "jmpif" => Keyword::Jmpif, + "load" => Keyword::Load, + "lt" => Keyword::Lt, + "max_bit_size" => Keyword::MaxBitSize, + "mod" => Keyword::Mod, + "mul" => Keyword::Mul, + "mut" => Keyword::Mut, + "no_predicates" => Keyword::NoPredicates, + "not" => Keyword::Not, + "of" => Keyword::Of, + "or" => Keyword::Or, + "range_check" => Keyword::RangeCheck, + "return" => Keyword::Return, + "shl" => Keyword::Shl, + "shr" => Keyword::Shr, + "store" => Keyword::Store, + "sub" => Keyword::Sub, + "then" => Keyword::Then, + "to" => Keyword::To, + "truncate" => Keyword::Truncate, + "value" => Keyword::Value, + "xor" => Keyword::Xor, + _ => return None, + }; + Some(Token::Keyword(keyword)) + } +} + +impl Display for Keyword { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Keyword::Acir => write!(f, "acir"), + Keyword::Add => write!(f, "add"), + Keyword::Allocate => write!(f, "allocate"), + Keyword::And => write!(f, "and"), + Keyword::ArrayGet => write!(f, "array_get"), + Keyword::ArraySet => write!(f, "array_set"), + Keyword::As => write!(f, "as"), + Keyword::At => write!(f, "at"), + Keyword::Bits => write!(f, "bits"), + Keyword::Bool => write!(f, "bool"), + Keyword::Brillig => write!(f, "brillig"), + Keyword::Call => write!(f, "call"), + Keyword::Cast => write!(f, "cast"), + Keyword::Constrain => write!(f, "constrain"), + Keyword::DecRc => write!(f, "dec_rc"), + Keyword::Div => write!(f, "div"), + Keyword::Else => write!(f, "else"), + Keyword::EnableSideEffects => write!(f, "enable_side_effects"), + Keyword::Eq => write!(f, "eq"), + Keyword::Field => write!(f, "Field"), + Keyword::Fold => write!(f, "fold"), + Keyword::Fn => write!(f, "fn"), + Keyword::IncRc => write!(f, "inc_rc"), + Keyword::Index => write!(f, "index"), + Keyword::Inline => write!(f, "inline"), + Keyword::InlineAlways => write!(f, "inline_always"), + Keyword::Jmp => write!(f, "jmp"), + Keyword::Jmpif => write!(f, "jmpif"), + Keyword::Load => write!(f, "load"), + Keyword::Lt => write!(f, "lt"), + Keyword::MaxBitSize => write!(f, "max_bit_size"), + Keyword::Mod => write!(f, "mod"), + Keyword::Mul => write!(f, "mul"), + Keyword::Mut => write!(f, "mut"), + Keyword::NoPredicates => write!(f, "no_predicates"), + Keyword::Not => write!(f, "not"), + Keyword::Of => write!(f, "of"), + Keyword::Or => write!(f, "or"), + Keyword::RangeCheck => write!(f, "range_check"), + Keyword::Return => write!(f, "return"), + Keyword::Shl => write!(f, "shl"), + Keyword::Shr => write!(f, "shr"), + Keyword::Store => write!(f, "store"), + Keyword::Sub => write!(f, "sub"), + Keyword::Then => write!(f, "then"), + Keyword::To => write!(f, "to"), + Keyword::Truncate => write!(f, "truncate"), + Keyword::Value => write!(f, "value"), + Keyword::Xor => write!(f, "xor"), + } + } +} diff --git a/noir/noir-repo/compiler/noirc_frontend/Cargo.toml b/noir/noir-repo/compiler/noirc_frontend/Cargo.toml index d729dabcb048..581d7f1b61d8 100644 --- a/noir/noir-repo/compiler/noirc_frontend/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_frontend/Cargo.toml @@ -36,6 +36,8 @@ strum_macros = "0.24" [dev-dependencies] base64.workspace = true +proptest.workspace = true +proptest-derive = "0.5.0" [features] experimental_parser = [] diff --git a/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/hir_def/types/arithmetic.txt b/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/hir_def/types/arithmetic.txt new file mode 100644 index 000000000000..80f5c7f1ead9 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/hir_def/types/arithmetic.txt @@ -0,0 +1,7 @@ +# Seeds for failure cases proptest has generated in the past. It is +# automatically read and these particular cases re-run before any +# novel cases are generated. +# +# It is recommended to check this file in to source control so that +# everyone who runs the test benefits from these saved cases. +cc fc27f4091dfa5f938973048209b5fcf22aefa1cfaffaaa3e349f30e9b1f93f49 # shrinks to infix_and_bindings = (((0: numeric bool) % (Numeric(Shared(RefCell { value: Unbound('2, Numeric(bool)) }): bool) + Numeric(Shared(RefCell { value: Unbound('0, Numeric(bool)) }): bool))), [('0, (0: numeric bool)), ('1, (0: numeric bool)), ('2, (0: numeric bool))]) diff --git a/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/tests/arithmetic_generics.txt b/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/tests/arithmetic_generics.txt new file mode 100644 index 000000000000..80f5c7f1ead9 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_frontend/proptest-regressions/tests/arithmetic_generics.txt @@ -0,0 +1,7 @@ +# Seeds for failure cases proptest has generated in the past. It is +# automatically read and these particular cases re-run before any +# novel cases are generated. +# +# It is recommended to check this file in to source control so that +# everyone who runs the test benefits from these saved cases. +cc fc27f4091dfa5f938973048209b5fcf22aefa1cfaffaaa3e349f30e9b1f93f49 # shrinks to infix_and_bindings = (((0: numeric bool) % (Numeric(Shared(RefCell { value: Unbound('2, Numeric(bool)) }): bool) + Numeric(Shared(RefCell { value: Unbound('0, Numeric(bool)) }): bool))), [('0, (0: numeric bool)), ('1, (0: numeric bool)), ('2, (0: numeric bool))]) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs index 67ddffe3277b..2c8a9b6508dd 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs @@ -98,7 +98,7 @@ impl UnresolvedGeneric { UnresolvedGeneric::Variable(_) => Ok(Kind::Normal), UnresolvedGeneric::Numeric { typ, .. } => { let typ = self.resolve_numeric_kind_type(typ)?; - Ok(Kind::Numeric(Box::new(typ))) + Ok(Kind::numeric(typ)) } UnresolvedGeneric::Resolved(..) => { panic!("Don't know the kind of a resolved generic here") @@ -504,7 +504,7 @@ impl FunctionDefinition { } pub fn is_test(&self) -> bool { - if let Some(attribute) = &self.attributes.function { + if let Some(attribute) = self.attributes.function() { matches!(attribute, FunctionAttribute::Test(..)) } else { false diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/function.rs index beeea3ffac5a..99ae78c93ea7 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/function.rs @@ -77,7 +77,7 @@ impl NoirFunction { &self.def.attributes } pub fn function_attribute(&self) -> Option<&FunctionAttribute> { - self.def.attributes.function.as_ref() + self.def.attributes.function() } pub fn secondary_attributes(&self) -> &[SecondaryAttribute] { self.def.attributes.secondary.as_ref() @@ -108,7 +108,7 @@ impl NoirFunction { impl From for NoirFunction { fn from(fd: FunctionDefinition) -> Self { // The function type is determined by the existence of a function attribute - let kind = match fd.attributes.function { + let kind = match fd.attributes.function() { Some(FunctionAttribute::Builtin(_)) => FunctionKind::Builtin, Some(FunctionAttribute::Foreign(_)) => FunctionKind::LowLevel, Some(FunctionAttribute::Test { .. }) => FunctionKind::Normal, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs index e85563691bad..3c6664dd569e 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/mod.rs @@ -19,6 +19,9 @@ pub use visitor::Visitor; pub use expression::*; pub use function::*; +#[cfg(test)] +use proptest_derive::Arbitrary; + use acvm::FieldElement; pub use docs::*; use noirc_errors::Span; @@ -37,6 +40,7 @@ use crate::{ use acvm::acir::AcirField; use iter_extended::vecmap; +#[cfg_attr(test, derive(Arbitrary))] #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd)] pub enum IntegerBitSize { One, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs index 49f585894d96..7244be371afe 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs @@ -445,11 +445,6 @@ impl Path { self.span } - pub fn first_segment(&self) -> PathSegment { - assert!(!self.segments.is_empty()); - self.segments.first().unwrap().clone() - } - pub fn last_segment(&self) -> PathSegment { assert!(!self.segments.is_empty()); self.segments.last().unwrap().clone() @@ -459,9 +454,8 @@ impl Path { self.last_segment().ident } - pub fn first_name(&self) -> &str { - assert!(!self.segments.is_empty()); - &self.segments.first().unwrap().ident.0.contents + pub fn first_name(&self) -> Option<&str> { + self.segments.first().map(|segment| segment.ident.0.contents.as_str()) } pub fn last_name(&self) -> &str { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/visitor.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/visitor.rs index 9e12b29677c3..f149c998eca1 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/visitor.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/visitor.rs @@ -16,7 +16,7 @@ use crate::{ InternedUnresolvedTypeData, QuotedTypeId, }, parser::{Item, ItemKind, ParsedSubModule}, - token::{CustomAttribute, SecondaryAttribute, Tokens}, + token::{MetaAttribute, SecondaryAttribute, Tokens}, ParsedModule, QuotedType, }; @@ -474,7 +474,9 @@ pub trait Visitor { true } - fn visit_custom_attribute(&mut self, _: &CustomAttribute, _target: AttributeTarget) {} + fn visit_meta_attribute(&mut self, _: &MetaAttribute, _target: AttributeTarget) -> bool { + true + } } impl ParsedModule { @@ -1441,15 +1443,22 @@ impl SecondaryAttribute { } pub fn accept_children(&self, target: AttributeTarget, visitor: &mut impl Visitor) { - if let SecondaryAttribute::Meta(custom) = self { - custom.accept(target, visitor); + if let SecondaryAttribute::Meta(meta_attribute) = self { + meta_attribute.accept(target, visitor); } } } -impl CustomAttribute { +impl MetaAttribute { pub fn accept(&self, target: AttributeTarget, visitor: &mut impl Visitor) { - visitor.visit_custom_attribute(self, target); + if visitor.visit_meta_attribute(self, target) { + self.accept_children(visitor); + } + } + + pub fn accept_children(&self, visitor: &mut impl Visitor) { + self.name.accept(visitor); + visit_expressions(&self.arguments, visitor); } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs index 13f51abe6bac..279adc331eaf 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs @@ -19,10 +19,9 @@ use crate::{ resolution::errors::ResolverError, }, hir_def::expr::{HirExpression, HirIdent}, - lexer::Lexer, node_interner::{DefinitionKind, DependencyId, FuncId, NodeInterner, StructId, TraitId}, - parser::{Item, ItemKind, Parser}, - token::SecondaryAttribute, + parser::{Item, ItemKind}, + token::{MetaAttribute, SecondaryAttribute}, Type, TypeBindings, UnificationError, }; @@ -162,10 +161,9 @@ impl<'context> Elaborator<'context> { if let SecondaryAttribute::Meta(attribute) = attribute { self.elaborate_in_comptime_context(|this| { if let Err(error) = this.run_comptime_attribute_name_on_item( - &attribute.contents, + attribute, item.clone(), span, - attribute.contents_span, attribute_context, generated_items, ) { @@ -177,27 +175,21 @@ impl<'context> Elaborator<'context> { fn run_comptime_attribute_name_on_item( &mut self, - attribute: &str, + attribute: &MetaAttribute, item: Value, span: Span, - attribute_span: Span, attribute_context: AttributeContext, generated_items: &mut CollectedItems, ) -> Result<(), (CompilationError, FileId)> { self.file = attribute_context.attribute_file; self.local_module = attribute_context.attribute_module; - let location = Location::new(attribute_span, self.file); - let Some((function, arguments)) = Self::parse_attribute(attribute, location)? else { - return Err(( - ResolverError::UnableToParseAttribute { - attribute: attribute.to_string(), - span: attribute_span, - } - .into(), - self.file, - )); + let location = Location::new(attribute.span, self.file); + let function = Expression { + kind: ExpressionKind::Variable(attribute.name.clone()), + span: attribute.span, }; + let arguments = attribute.arguments.clone(); // Elaborate the function, rolling back any errors generated in case it is unknown let error_count = self.errors.len(); @@ -211,7 +203,7 @@ impl<'context> Elaborator<'context> { return Err(( ResolverError::AttributeFunctionIsNotAPath { function: function_string, - span: attribute_span, + span: attribute.span, } .into(), self.file, @@ -223,7 +215,7 @@ impl<'context> Elaborator<'context> { return Err(( ResolverError::AttributeFunctionNotInScope { name: function_string, - span: attribute_span, + span: attribute.span, } .into(), self.file, @@ -269,38 +261,6 @@ impl<'context> Elaborator<'context> { Ok(()) } - /// Parses an attribute in the form of a function call (e.g. `#[foo(a b, c d)]`) into - /// the function and quoted arguments called (e.g. `("foo", vec![(a b, location), (c d, location)])`) - #[allow(clippy::type_complexity)] - pub(crate) fn parse_attribute( - annotation: &str, - location: Location, - ) -> Result)>, (CompilationError, FileId)> { - let (tokens, mut lexing_errors) = Lexer::lex(annotation); - if !lexing_errors.is_empty() { - return Err((lexing_errors.swap_remove(0).into(), location.file)); - } - - let Some(expression) = Parser::for_tokens(tokens).parse_option(Parser::parse_expression) - else { - return Ok(None); - }; - - let (mut func, mut arguments) = match expression.kind { - ExpressionKind::Call(call) => (*call.func, call.arguments), - ExpressionKind::Variable(_) => (expression, Vec::new()), - _ => return Ok(None), - }; - - func.span = func.span.shift_by(location.span.start()); - - for argument in &mut arguments { - argument.span = argument.span.shift_by(location.span.start()); - } - - Ok(Some((func, arguments))) - } - fn handle_attribute_arguments( interpreter: &mut Interpreter, item: &Value, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs index 249fed90a606..d3b776bea243 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs @@ -67,7 +67,7 @@ pub(super) fn low_level_function_outside_stdlib( crate_id: CrateId, ) -> Option { let is_low_level_function = - modifiers.attributes.function.as_ref().map_or(false, |func| func.is_low_level()); + modifiers.attributes.function().map_or(false, |func| func.is_low_level()); if !crate_id.is_stdlib() && is_low_level_function { let ident = func_meta_name_ident(func, modifiers); Some(ResolverError::LowLevelFunctionOutsideOfStdlib { ident }) @@ -81,8 +81,7 @@ pub(super) fn oracle_not_marked_unconstrained( func: &FuncMeta, modifiers: &FunctionModifiers, ) -> Option { - let is_oracle_function = - modifiers.attributes.function.as_ref().map_or(false, |func| func.is_oracle()); + let is_oracle_function = modifiers.attributes.function().map_or(false, |func| func.is_oracle()); if is_oracle_function && !modifiers.is_unconstrained { let ident = func_meta_name_ident(func, modifiers); Some(ResolverError::OracleMarkedAsConstrained { ident }) @@ -105,8 +104,7 @@ pub(super) fn oracle_called_from_constrained_function( } let function_attributes = interner.function_attributes(called_func); - let is_oracle_call = - function_attributes.function.as_ref().map_or(false, |func| func.is_oracle()); + let is_oracle_call = function_attributes.function().map_or(false, |func| func.is_oracle()); if is_oracle_call { Some(ResolverError::UnconstrainedOracleReturnToConstrained { span }) } else { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs index 14901303b922..084bcbe3f8d8 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs @@ -4,9 +4,8 @@ use std::{ }; use crate::{ - ast::ItemVisibility, hir::resolution::import::PathResolutionItem, - hir_def::traits::ResolvedTraitBound, usage_tracker::UsageTracker, StructField, StructType, - TypeBindings, + ast::ItemVisibility, hir_def::traits::ResolvedTraitBound, usage_tracker::UsageTracker, + StructField, StructType, TypeBindings, }; use crate::{ ast::{ @@ -24,7 +23,6 @@ use crate::{ def_map::{DefMaps, ModuleData}, def_map::{LocalModuleId, ModuleId, MAIN_FUNCTION}, resolution::errors::ResolverError, - resolution::import::PathResolution, scope::ScopeForest as GenericScopeForest, type_check::{generics::TraitGenerics, TypeCheckError}, Context, @@ -40,13 +38,14 @@ use crate::{ DefinitionKind, DependencyId, ExprId, FuncId, FunctionModifiers, GlobalId, NodeInterner, ReferenceId, StructId, TraitId, TraitImplId, TypeAliasId, }, - token::{CustomAttribute, SecondaryAttribute}, + token::SecondaryAttribute, Shared, Type, TypeVariable, }; mod comptime; mod expressions; mod lints; +mod path_resolution; mod patterns; mod scope; mod statements; @@ -58,6 +57,7 @@ mod unquote; use fm::FileId; use iter_extended::vecmap; use noirc_errors::{Location, Span, Spanned}; +use path_resolution::{PathResolution, PathResolutionItem}; use types::bind_ordered_generics; use self::traits::check_trait_impl_method_matches_declaration; @@ -641,7 +641,7 @@ impl<'context> Elaborator<'context> { let typ = if unresolved_typ.is_type_expression() { self.resolve_type_inner( unresolved_typ.clone(), - &Kind::Numeric(Box::new(Type::default_int_type())), + &Kind::numeric(Type::default_int_type()), ) } else { self.resolve_type(unresolved_typ.clone()) @@ -654,7 +654,7 @@ impl<'context> Elaborator<'context> { }); self.push_err(unsupported_typ_err); } - Kind::Numeric(Box::new(typ)) + Kind::numeric(typ) } else { Kind::Normal } @@ -839,11 +839,6 @@ impl<'context> Elaborator<'context> { None }; - let attributes = func.secondary_attributes().iter(); - let attributes = - attributes.filter_map(|secondary_attribute| secondary_attribute.as_custom()); - let attributes: Vec = attributes.cloned().collect(); - let meta = FuncMeta { name: name_ident, kind: func.kind, @@ -867,7 +862,6 @@ impl<'context> Elaborator<'context> { function_body: FunctionBody::Unresolved(func.kind, body, func.def.span), self_type: self.self_type.clone(), source_file: self.file, - custom_attributes: attributes, }; self.interner.push_fn_meta(meta, func_id); @@ -896,6 +890,10 @@ impl<'context> Elaborator<'context> { Type::Alias(alias_type, generics) => { self.mark_type_as_used(&alias_type.borrow().get_type(generics)); } + Type::CheckedCast { from, to } => { + self.mark_type_as_used(from); + self.mark_type_as_used(to); + } Type::MutableReference(typ) => { self.mark_type_as_used(typ); } @@ -1498,6 +1496,10 @@ impl<'context> Elaborator<'context> { span, ); } + Type::CheckedCast { from, to } => { + self.check_type_is_not_more_private_then_item(name, visibility, from, span); + self.check_type_is_not_more_private_then_item(name, visibility, to, span); + } Type::Function(args, return_type, env, _) => { for arg in args { self.check_type_is_not_more_private_then_item(name, visibility, arg, span); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/path_resolution.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/path_resolution.rs new file mode 100644 index 000000000000..a68991becb7f --- /dev/null +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/path_resolution.rs @@ -0,0 +1,347 @@ +use noirc_errors::{Location, Span}; + +use crate::ast::{Path, PathKind, UnresolvedType}; +use crate::hir::def_map::{ModuleDefId, ModuleId}; +use crate::hir::resolution::import::{resolve_path_kind, PathResolutionError}; + +use crate::hir::resolution::errors::ResolverError; +use crate::hir::resolution::visibility::item_in_module_is_visible; + +use crate::locations::ReferencesTracker; +use crate::node_interner::{FuncId, GlobalId, StructId, TraitId, TypeAliasId}; +use crate::Type; + +use super::types::SELF_TYPE_NAME; +use super::Elaborator; + +#[derive(Debug)] +pub(crate) struct PathResolution { + pub(crate) item: PathResolutionItem, + pub(crate) errors: Vec, +} + +/// All possible items that result from resolving a Path. +/// Note that this item doesn't include the last turbofish in a Path, +/// only intermediate ones, if any. +#[derive(Debug, Clone)] +pub enum PathResolutionItem { + Module(ModuleId), + Struct(StructId), + TypeAlias(TypeAliasId), + Trait(TraitId), + Global(GlobalId), + ModuleFunction(FuncId), + StructFunction(StructId, Option, FuncId), + TypeAliasFunction(TypeAliasId, Option, FuncId), + TraitFunction(TraitId, Option, FuncId), +} + +impl PathResolutionItem { + pub fn function_id(&self) -> Option { + match self { + PathResolutionItem::ModuleFunction(func_id) + | PathResolutionItem::StructFunction(_, _, func_id) + | PathResolutionItem::TypeAliasFunction(_, _, func_id) + | PathResolutionItem::TraitFunction(_, _, func_id) => Some(*func_id), + _ => None, + } + } + + pub fn module_id(&self) -> Option { + match self { + Self::Module(module_id) => Some(*module_id), + _ => None, + } + } + + pub fn description(&self) -> &'static str { + match self { + PathResolutionItem::Module(..) => "module", + PathResolutionItem::Struct(..) => "type", + PathResolutionItem::TypeAlias(..) => "type alias", + PathResolutionItem::Trait(..) => "trait", + PathResolutionItem::Global(..) => "global", + PathResolutionItem::ModuleFunction(..) + | PathResolutionItem::StructFunction(..) + | PathResolutionItem::TypeAliasFunction(..) + | PathResolutionItem::TraitFunction(..) => "function", + } + } +} + +#[derive(Debug, Clone)] +pub struct Turbofish { + pub generics: Vec, + pub span: Span, +} + +/// Any item that can appear before the last segment in a path. +#[derive(Debug)] +enum IntermediatePathResolutionItem { + Module(ModuleId), + Struct(StructId, Option), + TypeAlias(TypeAliasId, Option), + Trait(TraitId, Option), +} + +pub(crate) type PathResolutionResult = Result; + +impl<'context> Elaborator<'context> { + pub(super) fn resolve_path_or_error( + &mut self, + path: Path, + ) -> Result { + let path_resolution = self.resolve_path(path)?; + + for error in path_resolution.errors { + self.push_err(error); + } + + Ok(path_resolution.item) + } + + /// Resolves a path in the current module. + /// If the referenced name can't be found, `Err` will be returned. If it can be found, `Ok` + /// will be returned with a potential list of errors if, for example, one of the segments + /// is not accessible from the current module (e.g. because it's private). + pub(super) fn resolve_path(&mut self, mut path: Path) -> PathResolutionResult { + let mut module_id = self.module_id(); + + if path.kind == PathKind::Plain && path.first_name() == Some(SELF_TYPE_NAME) { + if let Some(Type::Struct(struct_type, _)) = &self.self_type { + let struct_type = struct_type.borrow(); + if path.segments.len() == 1 { + return Ok(PathResolution { + item: PathResolutionItem::Struct(struct_type.id), + errors: Vec::new(), + }); + } + + module_id = struct_type.id.module_id(); + path.segments.remove(0); + } + } + + self.resolve_path_in_module(path, module_id) + } + + /// Resolves a path in `current_module`. + /// `importing_module` is the module where the lookup originally started. + fn resolve_path_in_module( + &mut self, + path: Path, + importing_module: ModuleId, + ) -> PathResolutionResult { + let references_tracker = if self.interner.is_in_lsp_mode() { + Some(ReferencesTracker::new(self.interner, self.file)) + } else { + None + }; + let (path, module_id, _) = + resolve_path_kind(path, importing_module, self.def_maps, references_tracker)?; + self.resolve_name_in_module(path, module_id, importing_module) + } + + /// Resolves a Path assuming we are inside `starting_module`. + /// `importing_module` is the module where the lookup originally started. + fn resolve_name_in_module( + &mut self, + path: Path, + starting_module: ModuleId, + importing_module: ModuleId, + ) -> PathResolutionResult { + // There is a possibility that the import path is empty. In that case, early return. + if path.segments.is_empty() { + return Ok(PathResolution { + item: PathResolutionItem::Module(starting_module), + errors: Vec::new(), + }); + } + + let plain_or_crate = matches!(path.kind, PathKind::Plain | PathKind::Crate); + + // The current module and module ID as we resolve path segments + let mut current_module_id = starting_module; + let mut current_module = self.get_module(starting_module); + + let mut intermediate_item = IntermediatePathResolutionItem::Module(current_module_id); + + let first_segment = + &path.segments.first().expect("ice: could not fetch first segment").ident; + let mut current_ns = current_module.find_name(first_segment); + if current_ns.is_none() { + return Err(PathResolutionError::Unresolved(first_segment.clone())); + } + + self.usage_tracker.mark_as_referenced(current_module_id, first_segment); + + let mut errors = Vec::new(); + for (index, (last_segment, current_segment)) in + path.segments.iter().zip(path.segments.iter().skip(1)).enumerate() + { + let last_ident = &last_segment.ident; + let current_ident = ¤t_segment.ident; + let last_segment_generics = &last_segment.generics; + + let (typ, visibility) = match current_ns.types { + None => return Err(PathResolutionError::Unresolved(last_ident.clone())), + Some((typ, visibility, _)) => (typ, visibility), + }; + + let location = Location::new(last_segment.span, self.file); + self.interner.add_module_def_id_reference( + typ, + location, + last_segment.ident.is_self_type_name(), + ); + + (current_module_id, intermediate_item) = match typ { + ModuleDefId::ModuleId(id) => { + if last_segment_generics.is_some() { + errors.push(PathResolutionError::TurbofishNotAllowedOnItem { + item: format!("module `{last_ident}`"), + span: last_segment.turbofish_span(), + }); + } + + (id, IntermediatePathResolutionItem::Module(id)) + } + ModuleDefId::TypeId(id) => ( + id.module_id(), + IntermediatePathResolutionItem::Struct( + id, + last_segment_generics.as_ref().map(|generics| Turbofish { + generics: generics.clone(), + span: last_segment.turbofish_span(), + }), + ), + ), + ModuleDefId::TypeAliasId(id) => { + let type_alias = self.interner.get_type_alias(id); + let type_alias = type_alias.borrow(); + + let module_id = match &type_alias.typ { + Type::Struct(struct_id, _generics) => struct_id.borrow().id.module_id(), + Type::Error => { + return Err(PathResolutionError::Unresolved(last_ident.clone())); + } + _ => { + // For now we only allow type aliases that point to structs. + // The more general case is captured here: https://github.com/noir-lang/noir/issues/6398 + panic!("Type alias in path not pointing to struct not yet supported") + } + }; + + ( + module_id, + IntermediatePathResolutionItem::TypeAlias( + id, + last_segment_generics.as_ref().map(|generics| Turbofish { + generics: generics.clone(), + span: last_segment.turbofish_span(), + }), + ), + ) + } + ModuleDefId::TraitId(id) => ( + id.0, + IntermediatePathResolutionItem::Trait( + id, + last_segment_generics.as_ref().map(|generics| Turbofish { + generics: generics.clone(), + span: last_segment.turbofish_span(), + }), + ), + ), + ModuleDefId::FunctionId(_) => panic!("functions cannot be in the type namespace"), + ModuleDefId::GlobalId(_) => panic!("globals cannot be in the type namespace"), + }; + + // If the path is plain or crate, the first segment will always refer to + // something that's visible from the current module. + if !((plain_or_crate && index == 0) + || item_in_module_is_visible( + self.def_maps, + importing_module, + current_module_id, + visibility, + )) + { + errors.push(PathResolutionError::Private(last_ident.clone())); + } + + current_module = self.get_module(current_module_id); + + // Check if namespace + let found_ns = current_module.find_name(current_ident); + if found_ns.is_none() { + return Err(PathResolutionError::Unresolved(current_ident.clone())); + } + + self.usage_tracker.mark_as_referenced(current_module_id, current_ident); + + current_ns = found_ns; + } + + let (module_def_id, visibility, _) = + current_ns.values.or(current_ns.types).expect("Found empty namespace"); + + let name = path.last_ident(); + let is_self_type = name.is_self_type_name(); + let location = Location::new(name.span(), self.file); + self.interner.add_module_def_id_reference(module_def_id, location, is_self_type); + + let item = merge_intermediate_path_resolution_item_with_module_def_id( + intermediate_item, + module_def_id, + ); + + if !(self.self_type_module_id() == Some(current_module_id) + || item_in_module_is_visible( + self.def_maps, + importing_module, + current_module_id, + visibility, + )) + { + errors.push(PathResolutionError::Private(name.clone())); + } + + Ok(PathResolution { item, errors }) + } + + fn self_type_module_id(&self) -> Option { + if let Some(Type::Struct(struct_type, _)) = &self.self_type { + Some(struct_type.borrow().id.module_id()) + } else { + None + } + } +} + +fn merge_intermediate_path_resolution_item_with_module_def_id( + intermediate_item: IntermediatePathResolutionItem, + module_def_id: ModuleDefId, +) -> PathResolutionItem { + match module_def_id { + ModuleDefId::ModuleId(module_id) => PathResolutionItem::Module(module_id), + ModuleDefId::TypeId(struct_id) => PathResolutionItem::Struct(struct_id), + ModuleDefId::TypeAliasId(type_alias_id) => PathResolutionItem::TypeAlias(type_alias_id), + ModuleDefId::TraitId(trait_id) => PathResolutionItem::Trait(trait_id), + ModuleDefId::GlobalId(global_id) => PathResolutionItem::Global(global_id), + ModuleDefId::FunctionId(func_id) => match intermediate_item { + IntermediatePathResolutionItem::Module(_) => { + PathResolutionItem::ModuleFunction(func_id) + } + IntermediatePathResolutionItem::Struct(struct_id, generics) => { + PathResolutionItem::StructFunction(struct_id, generics, func_id) + } + IntermediatePathResolutionItem::TypeAlias(alias_id, generics) => { + PathResolutionItem::TypeAliasFunction(alias_id, generics, func_id) + } + IntermediatePathResolutionItem::Trait(trait_id, generics) => { + PathResolutionItem::TraitFunction(trait_id, generics, func_id) + } + }, + } +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/patterns.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/patterns.rs index 9e60adcbc6ff..3928362db11a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/patterns.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/patterns.rs @@ -9,7 +9,7 @@ use crate::{ }, hir::{ def_collector::dc_crate::CompilationError, - resolution::{errors::ResolverError, import::PathResolutionItem}, + resolution::errors::ResolverError, type_check::{Source, TypeCheckError}, }, hir_def::{ @@ -20,7 +20,7 @@ use crate::{ Kind, Shared, StructType, Type, TypeAlias, TypeBindings, }; -use super::{Elaborator, ResolverMeta}; +use super::{path_resolution::PathResolutionItem, Elaborator, ResolverMeta}; impl<'context> Elaborator<'context> { pub(super) fn elaborate_pattern( diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/scope.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/scope.rs index 33e97c1df224..fe01e3cb7f32 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/scope.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/scope.rs @@ -1,9 +1,8 @@ -use noirc_errors::{Location, Spanned}; +use noirc_errors::Spanned; -use crate::ast::{Ident, Path, PathKind, ERROR_IDENT}; +use crate::ast::{Ident, Path, ERROR_IDENT}; use crate::hir::def_map::{LocalModuleId, ModuleId}; -use crate::hir::resolution::import::{PathResolution, PathResolutionItem, PathResolutionResult}; -use crate::hir::resolution::path_resolver::{PathResolver, StandardPathResolver}; + use crate::hir::scope::{Scope as GenericScope, ScopeTree as GenericScopeTree}; use crate::{ hir::resolution::errors::ResolverError, @@ -16,6 +15,7 @@ use crate::{ }; use crate::{Type, TypeAlias}; +use super::path_resolution::PathResolutionItem; use super::types::SELF_TYPE_NAME; use super::{Elaborator, ResolverMeta}; @@ -37,99 +37,6 @@ impl<'context> Elaborator<'context> { current_module } - pub(super) fn resolve_path_or_error( - &mut self, - path: Path, - ) -> Result { - let path_resolution = self.resolve_path(path)?; - - for error in path_resolution.errors { - self.push_err(error); - } - - Ok(path_resolution.item) - } - - pub(super) fn resolve_path(&mut self, path: Path) -> PathResolutionResult { - let mut module_id = self.module_id(); - let mut path = path; - - if path.kind == PathKind::Plain && path.first_name() == SELF_TYPE_NAME { - if let Some(Type::Struct(struct_type, _)) = &self.self_type { - let struct_type = struct_type.borrow(); - if path.segments.len() == 1 { - return Ok(PathResolution { - item: PathResolutionItem::Struct(struct_type.id), - errors: Vec::new(), - }); - } - - module_id = struct_type.id.module_id(); - path = Path { - segments: path.segments[1..].to_vec(), - kind: PathKind::Plain, - span: path.span(), - }; - } - } - - self.resolve_path_in_module(path, module_id) - } - - fn resolve_path_in_module(&mut self, path: Path, module_id: ModuleId) -> PathResolutionResult { - let self_type_module_id = if let Some(Type::Struct(struct_type, _)) = &self.self_type { - Some(struct_type.borrow().id.module_id()) - } else { - None - }; - - let resolver = StandardPathResolver::new(module_id, self_type_module_id); - - if !self.interner.lsp_mode { - return resolver.resolve( - self.interner, - self.def_maps, - path, - self.usage_tracker, - &mut None, - ); - } - - let last_segment = path.last_ident(); - let location = Location::new(last_segment.span(), self.file); - let is_self_type_name = last_segment.is_self_type_name(); - - let mut references: Vec<_> = Vec::new(); - let path_resolution = resolver.resolve( - self.interner, - self.def_maps, - path.clone(), - self.usage_tracker, - &mut Some(&mut references), - ); - - for (referenced, segment) in references.iter().zip(path.segments) { - self.interner.add_reference( - *referenced, - Location::new(segment.ident.span(), self.file), - segment.ident.is_self_type_name(), - ); - } - - let path_resolution = match path_resolution { - Ok(path_resolution) => path_resolution, - Err(err) => return Err(err), - }; - - self.interner.add_path_resolution_kind_reference( - path_resolution.item.clone(), - location, - is_self_type_name, - ); - - Ok(path_resolution) - } - pub(super) fn get_struct(&self, type_id: StructId) -> Shared { self.interner.get_struct(type_id) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/traits.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/traits.rs index ae278616e034..e1be45927ca2 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/traits.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/traits.rs @@ -23,6 +23,8 @@ use super::Elaborator; impl<'context> Elaborator<'context> { pub fn collect_traits(&mut self, traits: &BTreeMap) { for (trait_id, unresolved_trait) in traits { + self.local_module = unresolved_trait.module_id; + self.recover_generics(|this| { this.current_trait = Some(*trait_id); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/types.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/types.rs index c8a16a6cd9bb..b296c4f18056 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/types.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/types.rs @@ -14,10 +14,7 @@ use crate::{ hir::{ comptime::{Interpreter, Value}, def_collector::dc_crate::CompilationError, - resolution::{ - errors::ResolverError, - import::{PathResolutionError, PathResolutionItem}, - }, + resolution::{errors::ResolverError, import::PathResolutionError}, type_check::{ generics::{Generic, TraitGenerics}, NoMatchingImplFoundError, Source, TypeCheckError, @@ -41,7 +38,7 @@ use crate::{ UnificationError, }; -use super::{lints, Elaborator}; +use super::{lints, path_resolution::PathResolutionItem, Elaborator}; pub const SELF_TYPE_NAME: &str = "Self"; pub const WILDCARD_TYPE: &str = "_"; @@ -195,7 +192,7 @@ impl<'context> Elaborator<'context> { // Resolve Self::Foo to an associated type on the current trait or trait impl fn lookup_associated_type_on_self(&self, path: &Path) -> Option { - if path.segments.len() == 2 && path.first_name() == SELF_TYPE_NAME { + if path.segments.len() == 2 && path.first_name() == Some(SELF_TYPE_NAME) { if let Some(trait_id) = self.current_trait { let the_trait = self.interner.get_trait(trait_id); if let Some(typ) = the_trait.get_associated_type(path.last_name()) { @@ -417,7 +414,7 @@ impl<'context> Elaborator<'context> { let kind = self .interner .get_global_let_statement(id) - .map(|let_statement| Kind::Numeric(Box::new(let_statement.r#type))) + .map(|let_statement| Kind::numeric(let_statement.r#type)) .unwrap_or(Kind::u32()); // TODO(https://github.com/noir-lang/noir/issues/6238): @@ -465,14 +462,26 @@ impl<'context> Elaborator<'context> { }); return Type::Error; } - if let Some(result) = op.function(lhs, rhs, &lhs_kind) { - Type::Constant(result, lhs_kind) - } else { - self.push_err(ResolverError::OverflowInType { lhs, op, rhs, span }); - Type::Error + match op.function(lhs, rhs, &lhs_kind, span) { + Ok(result) => Type::Constant(result, lhs_kind), + Err(err) => { + let err = Box::new(err); + self.push_err(ResolverError::BinaryOpError { + lhs, + op, + rhs, + err, + span, + }); + Type::Error + } } } - (lhs, rhs) => Type::InfixExpr(Box::new(lhs), op, Box::new(rhs)).canonicalize(), + (lhs, rhs) => { + let infix = Type::InfixExpr(Box::new(lhs), op, Box::new(rhs)); + Type::CheckedCast { from: Box::new(infix.clone()), to: Box::new(infix) } + .canonicalize() + } } } UnresolvedTypeExpression::AsTraitPath(path) => { @@ -1741,6 +1750,11 @@ impl<'context> Elaborator<'context> { | Type::Quoted(_) | Type::Forall(_, _) => (), + Type::CheckedCast { from, to } => { + Self::find_numeric_generics_in_type(from, found); + Self::find_numeric_generics_in_type(to, found); + } + Type::TraitAsType(_, _, args) => { for arg in &args.ordered { Self::find_numeric_generics_in_type(arg, found); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/display.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/display.rs index bfbe39df241c..560d11cfa2e0 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/display.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/display.rs @@ -281,8 +281,7 @@ impl<'interner> TokenPrettyPrinter<'interner> { | Token::Whitespace(_) | Token::LineComment(..) | Token::BlockComment(..) - | Token::Attribute(..) - | Token::InnerAttribute(..) + | Token::AttributeStart { .. } | Token::Invalid(_) => { if last_was_alphanumeric { write!(f, " ")?; diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs index dfd328f85f0e..198ba91156e8 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs @@ -3,7 +3,10 @@ use std::rc::Rc; use crate::{ ast::TraitBound, - hir::{def_collector::dc_crate::CompilationError, type_check::NoMatchingImplFoundError}, + hir::{ + def_collector::dc_crate::CompilationError, + type_check::{NoMatchingImplFoundError, TypeCheckError}, + }, parser::ParserError, Type, }; @@ -87,6 +90,7 @@ pub enum InterpreterError { }, NonIntegerArrayLength { typ: Type, + err: Option>, location: Location, }, NonNumericCasted { @@ -228,6 +232,7 @@ pub enum InterpreterError { }, UnknownArrayLength { length: Type, + err: Box, location: Location, }, @@ -435,9 +440,13 @@ impl<'a> From<&'a InterpreterError> for CustomDiagnostic { let secondary = "This is likely a bug".into(); CustomDiagnostic::simple_error(msg, secondary, location.span) } - InterpreterError::NonIntegerArrayLength { typ, location } => { + InterpreterError::NonIntegerArrayLength { typ, err, location } => { let msg = format!("Non-integer array length: `{typ}`"); - let secondary = "Array lengths must be integers".into(); + let secondary = if let Some(err) = err { + format!("Array lengths must be integers, but evaluating `{typ}` resulted in `{err}`") + } else { + "Array lengths must be integers".to_string() + }; CustomDiagnostic::simple_error(msg, secondary, location.span) } InterpreterError::NonNumericCasted { typ, location } => { @@ -640,9 +649,10 @@ impl<'a> From<&'a InterpreterError> for CustomDiagnostic { let msg = format!("`{expression}` is not a valid function body"); CustomDiagnostic::simple_error(msg, String::new(), location.span) } - InterpreterError::UnknownArrayLength { length, location } => { + InterpreterError::UnknownArrayLength { length, err, location } => { let msg = format!("Could not determine array length `{length}`"); - CustomDiagnostic::simple_error(msg, String::new(), location.span) + let secondary = format!("Evaluating the length failed with: `{err}`"); + CustomDiagnostic::simple_error(msg, secondary, location.span) } } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/hir_to_display_ast.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/hir_to_display_ast.rs index 260c4e3848a3..5540a199cec2 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/hir_to_display_ast.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/hir_to_display_ast.rs @@ -340,6 +340,7 @@ impl Type { let name = Path::from_single(name.as_ref().clone(), Span::default()); UnresolvedTypeData::Named(name, GenericTypeArgs::default(), true) } + Type::CheckedCast { to, .. } => to.to_display_ast().typ, Type::Function(args, ret, env, unconstrained) => { let args = vecmap(args, |arg| arg.to_display_ast()); let ret = Box::new(ret.to_display_ast()); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index 7205242ead94..994318a371ae 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -223,7 +223,7 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { location: Location, ) -> IResult { let attributes = self.elaborator.interner.function_attributes(&function); - let func_attrs = attributes.function.as_ref() + let func_attrs = attributes.function() .expect("all builtin functions must contain a function attribute which contains the opcode which it links to"); if let Some(builtin) = func_attrs.builtin() { @@ -585,20 +585,25 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { } DefinitionKind::NumericGeneric(type_variable, numeric_typ) => { let value = match &*type_variable.borrow() { - TypeBinding::Unbound(_, _) => None, + TypeBinding::Unbound(_, _) => { + let typ = self.elaborator.interner.id_type(id); + let location = self.elaborator.interner.expr_location(&id); + Err(InterpreterError::NonIntegerArrayLength { typ, err: None, location }) + } TypeBinding::Bound(binding) => { - binding.evaluate_to_field_element(&Kind::Numeric(numeric_typ.clone())) + let span = self.elaborator.interner.id_location(id).span; + binding + .evaluate_to_field_element(&Kind::Numeric(numeric_typ.clone()), span) + .map_err(|err| { + let typ = Type::TypeVariable(type_variable.clone()); + let err = Some(Box::new(err)); + let location = self.elaborator.interner.expr_location(&id); + InterpreterError::NonIntegerArrayLength { typ, err, location } + }) } - }; + }?; - if let Some(value) = value { - let typ = self.elaborator.interner.id_type(id); - self.evaluate_integer(value, false, id) - } else { - let location = self.elaborator.interner.expr_location(&id); - let typ = Type::TypeVariable(type_variable.clone()); - Err(InterpreterError::NonIntegerArrayLength { typ, location }) - } + self.evaluate_integer(value, false, id) } } } @@ -805,12 +810,17 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { HirArrayLiteral::Repeated { repeated_element, length } => { let element = self.evaluate(repeated_element)?; - if let Some(length) = length.evaluate_to_u32() { - let elements = (0..length).map(|_| element.clone()).collect(); - Ok(Value::Array(elements, typ)) - } else { - let location = self.elaborator.interner.expr_location(&id); - Err(InterpreterError::NonIntegerArrayLength { typ: length, location }) + let span = self.elaborator.interner.id_location(id).span; + match length.evaluate_to_u32(span) { + Ok(length) => { + let elements = (0..length).map(|_| element.clone()).collect(); + Ok(Value::Array(elements, typ)) + } + Err(err) => { + let err = Some(Box::new(err)); + let location = self.elaborator.interner.expr_location(&id); + Err(InterpreterError::NonIntegerArrayLength { typ: length, err, location }) + } } } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs index d8842215a29a..8a6c46ca50c5 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs @@ -12,7 +12,7 @@ use builtin_helpers::{ }; use im::Vector; use iter_extended::{try_vecmap, vecmap}; -use noirc_errors::Location; +use noirc_errors::{Location, Span}; use num_bigint::BigUint; use rustc_hash::FxHashMap as HashMap; @@ -37,7 +37,7 @@ use crate::{ hir_def::{self}, node_interner::{DefinitionKind, NodeInterner, TraitImplKind}, parser::{Parser, StatementOrExpressionOrLValue}, - token::{Attribute, SecondaryAttribute, Token}, + token::{Attribute, Token}, Kind, QuotedType, ResolvedGeneric, Shared, Type, TypeVariable, }; @@ -230,7 +230,7 @@ impl<'local, 'context> Interpreter<'local, 'context> { "unresolved_type_is_bool" => unresolved_type_is_bool(interner, arguments, location), "unresolved_type_is_field" => unresolved_type_is_field(interner, arguments, location), "unresolved_type_is_unit" => unresolved_type_is_unit(interner, arguments, location), - "zeroed" => zeroed(return_type), + "zeroed" => zeroed(return_type, location.span), _ => { let item = format!("Comptime evaluation for builtin function {name}"); Err(InterpreterError::Unimplemented { item, location }) @@ -348,24 +348,9 @@ fn struct_def_add_attribute( let (self_argument, attribute) = check_two_arguments(arguments, location)?; let attribute_location = attribute.1; let attribute = get_str(interner, attribute)?; - - let mut tokens = lex(&format!("#[{}]", attribute)); - if tokens.len() != 1 { - return Err(InterpreterError::InvalidAttribute { - attribute: attribute.to_string(), - location: attribute_location, - }); - } - - let token = tokens.remove(0); - let Token::Attribute(attribute) = token else { - return Err(InterpreterError::InvalidAttribute { - attribute: attribute.to_string(), - location: attribute_location, - }); - }; - - let Attribute::Secondary(attribute) = attribute else { + let attribute = format!("#[{}]", attribute); + let mut parser = Parser::for_str(&attribute); + let Some((Attribute::Secondary(attribute), _span)) = parser.parse_attribute() else { return Err(InterpreterError::InvalidAttribute { attribute: attribute.to_string(), location: attribute_location, @@ -374,7 +359,7 @@ fn struct_def_add_attribute( let struct_id = get_struct(self_argument)?; interner.update_struct_attributes(struct_id, |attributes| { - attributes.push(attribute.clone()); + attributes.push(attribute); }); Ok(Value::Unit) @@ -710,7 +695,7 @@ fn quoted_as_expr( }, ); - option(return_type, value) + option(return_type, value, location.span) } // fn as_module(quoted: Quoted) -> Option @@ -737,7 +722,7 @@ fn quoted_as_module( module.map(Value::ModuleDefinition) }); - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn as_trait_constraint(quoted: Quoted) -> TraitConstraint @@ -869,11 +854,22 @@ fn type_as_constant( return_type: Type, location: Location, ) -> IResult { - type_as(arguments, return_type, location, |typ| { + type_as_or_err(arguments, return_type, location, |typ| { // Prefer to use `evaluate_to_u32` over matching on `Type::Constant` // since arithmetic generics may be `Type::InfixExpr`s which evaluate to // constants but are not actually the `Type::Constant` variant. - typ.evaluate_to_u32().map(Value::U32) + match typ.evaluate_to_u32(location.span) { + Ok(constant) => Ok(Some(Value::U32(constant))), + Err(err) => { + // Evaluating to a non-constant returns 'None' in user code + if err.is_non_constant_evaluated() { + Ok(None) + } else { + let err = Some(Box::new(err)); + Err(InterpreterError::NonIntegerArrayLength { typ, err, location }) + } + } + } }) } @@ -979,7 +975,6 @@ fn type_as_tuple( }) } -// Helper function for implementing the `type_as_...` functions. fn type_as( arguments: Vec<(Value, Location)>, return_type: Type, @@ -988,13 +983,26 @@ fn type_as( ) -> IResult where F: FnOnce(Type) -> Option, +{ + type_as_or_err(arguments, return_type, location, |x| Ok(f(x))) +} + +// Helper function for implementing the `type_as_...` functions. +fn type_as_or_err( + arguments: Vec<(Value, Location)>, + return_type: Type, + location: Location, + f: F, +) -> IResult +where + F: FnOnce(Type) -> IResult>, { let value = check_one_argument(arguments, location)?; let typ = get_type(value)?.follow_bindings(); - let option_value = f(typ); + let option_value = f(typ)?; - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn type_eq(_first: Type, _second: Type) -> bool @@ -1029,7 +1037,7 @@ fn type_get_trait_impl( _ => None, }; - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn implements(self, constraint: TraitConstraint) -> bool @@ -1150,7 +1158,7 @@ fn typed_expr_as_function_definition( } else { None }; - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn get_type(self) -> Option @@ -1172,7 +1180,7 @@ fn typed_expr_get_type( } else { None }; - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn as_mutable_reference(self) -> Option @@ -1256,16 +1264,16 @@ where let option_value = f(typ); - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn zeroed() -> T -fn zeroed(return_type: Type) -> IResult { +fn zeroed(return_type: Type, span: Span) -> IResult { match return_type { Type::FieldElement => Ok(Value::Field(0u128.into())), Type::Array(length_type, elem) => { - if let Some(length) = length_type.evaluate_to_u32() { - let element = zeroed(elem.as_ref().clone())?; + if let Ok(length) = length_type.evaluate_to_u32(span) { + let element = zeroed(elem.as_ref().clone(), span)?; let array = std::iter::repeat(element).take(length as usize).collect(); Ok(Value::Array(array, Type::Array(length_type, elem))) } else { @@ -1288,7 +1296,7 @@ fn zeroed(return_type: Type) -> IResult { }, Type::Bool => Ok(Value::Bool(false)), Type::String(length_type) => { - if let Some(length) = length_type.evaluate_to_u32() { + if let Ok(length) = length_type.evaluate_to_u32(span) { Ok(Value::String(Rc::new("\0".repeat(length as usize)))) } else { // Assume we can resolve the length later @@ -1296,9 +1304,9 @@ fn zeroed(return_type: Type) -> IResult { } } Type::FmtString(length_type, captures) => { - let length = length_type.evaluate_to_u32(); + let length = length_type.evaluate_to_u32(span); let typ = Type::FmtString(length_type, captures); - if let Some(length) = length { + if let Ok(length) = length { Ok(Value::FormatString(Rc::new("\0".repeat(length as usize)), typ)) } else { // Assume we can resolve the length later @@ -1306,26 +1314,27 @@ fn zeroed(return_type: Type) -> IResult { } } Type::Unit => Ok(Value::Unit), - Type::Tuple(fields) => Ok(Value::Tuple(try_vecmap(fields, zeroed)?)), + Type::Tuple(fields) => Ok(Value::Tuple(try_vecmap(fields, |field| zeroed(field, span))?)), Type::Struct(struct_type, generics) => { let fields = struct_type.borrow().get_fields(&generics); let mut values = HashMap::default(); for (field_name, field_type) in fields { - let field_value = zeroed(field_type)?; + let field_value = zeroed(field_type, span)?; values.insert(Rc::new(field_name), field_value); } let typ = Type::Struct(struct_type, generics); Ok(Value::Struct(values, typ)) } - Type::Alias(alias, generics) => zeroed(alias.borrow().get_type(&generics)), + Type::Alias(alias, generics) => zeroed(alias.borrow().get_type(&generics), span), + Type::CheckedCast { to, .. } => zeroed(*to, span), typ @ Type::Function(..) => { // Using Value::Zeroed here is probably safer than using FuncId::dummy_id() or similar Ok(Value::Zeroed(typ)) } Type::MutableReference(element) => { - let element = zeroed(*element)?; + let element = zeroed(*element, span)?; Ok(Value::Pointer(Shared::new(element), false)) } // Optimistically assume we can resolve this type later or that the value is unused @@ -1389,7 +1398,7 @@ fn expr_as_assert( let option_type = tuple_types.pop().unwrap(); let message = message.map(|msg| Value::expression(msg.kind)); - let message = option(option_type, message).ok()?; + let message = option(option_type, message, location.span).ok()?; Some(Value::Tuple(vec![predicate, message])) } else { @@ -1435,7 +1444,7 @@ fn expr_as_assert_eq( let option_type = tuple_types.pop().unwrap(); let message = message.map(|message| Value::expression(message.kind)); - let message = option(option_type, message).ok()?; + let message = option(option_type, message, location.span).ok()?; Some(Value::Tuple(vec![lhs, rhs, message])) } else { @@ -1611,7 +1620,7 @@ fn expr_as_constructor( None }; - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn as_for(self) -> Option<(Quoted, Expr, Expr)> @@ -1705,6 +1714,7 @@ fn expr_as_if( let alternative = option( alternative_option_type, if_expr.alternative.map(|e| Value::expression(e.kind)), + location.span, ); Some(Value::Tuple(vec![ @@ -1793,7 +1803,7 @@ fn expr_as_lambda( } else { Some(Value::UnresolvedType(typ.typ)) }; - let typ = option(option_unresolved_type.clone(), typ).unwrap(); + let typ = option(option_unresolved_type.clone(), typ, location.span).unwrap(); Value::Tuple(vec![pattern, typ]) }) .collect(); @@ -1812,7 +1822,7 @@ fn expr_as_lambda( Some(return_type) }; let return_type = return_type.map(Value::UnresolvedType); - let return_type = option(option_unresolved_type, return_type).ok()?; + let return_type = option(option_unresolved_type, return_type, location.span).ok()?; let body = Value::expression(lambda.body.kind); @@ -1846,7 +1856,7 @@ fn expr_as_let( Some(Value::UnresolvedType(let_statement.r#type.typ)) }; - let typ = option(option_type, typ).ok()?; + let typ = option(option_type, typ, location.span).ok()?; Some(Value::Tuple(vec![ Value::pattern(let_statement.pattern), @@ -2098,7 +2108,7 @@ where let expr_value = unwrap_expr_value(interner, expr_value); let option_value = f(expr_value); - option(return_type, option_value) + option(return_type, option_value, location.span) } // fn resolve(self, in_function: Option) -> TypedExpr @@ -2225,17 +2235,9 @@ fn function_def_add_attribute( let (self_argument, attribute) = check_two_arguments(arguments, location)?; let attribute_location = attribute.1; let attribute = get_str(interpreter.elaborator.interner, attribute)?; - - let mut tokens = lex(&format!("#[{}]", attribute)); - if tokens.len() != 1 { - return Err(InterpreterError::InvalidAttribute { - attribute: attribute.to_string(), - location: attribute_location, - }); - } - - let token = tokens.remove(0); - let Token::Attribute(attribute) = token else { + let attribute = format!("#[{}]", attribute); + let mut parser = Parser::for_str(&attribute); + let Some((attribute, _span)) = parser.parse_attribute() else { return Err(InterpreterError::InvalidAttribute { attribute: attribute.to_string(), location: attribute_location, @@ -2249,21 +2251,13 @@ fn function_def_add_attribute( match &attribute { Attribute::Function(attribute) => { - function_modifiers.attributes.function = Some(attribute.clone()); + function_modifiers.attributes.set_function(attribute.clone()); } Attribute::Secondary(attribute) => { function_modifiers.attributes.secondary.push(attribute.clone()); } } - if let Attribute::Secondary( - SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute), - ) = attribute - { - let func_meta = interpreter.elaborator.interner.function_meta_mut(&func_id); - func_meta.custom_attributes.push(attribute); - } - Ok(Value::Unit) } @@ -2295,7 +2289,7 @@ fn function_def_has_named_attribute( let name = &*get_str(interner, name)?; let modifiers = interner.function_modifiers(&func_id); - if let Some(attribute) = &modifiers.attributes.function { + if let Some(attribute) = modifiers.attributes.function() { if name == attribute.name() { return Ok(Value::Bool(true)); } @@ -2764,12 +2758,12 @@ fn trait_def_as_trait_constraint( /// Creates a value that holds an `Option`. /// `option_type` must be a Type referencing the `Option` type. -pub(crate) fn option(option_type: Type, value: Option) -> IResult { +pub(crate) fn option(option_type: Type, value: Option, span: Span) -> IResult { let t = extract_option_generic_type(option_type.clone()); let (is_some, value) = match value { Some(value) => (Value::Bool(true), value), - None => (Value::Bool(false), zeroed(t)?), + None => (Value::Bool(false), zeroed(t, span)?), }; let mut fields = HashMap::default(); @@ -2818,9 +2812,10 @@ fn derive_generators( _ => panic!("ICE: Should only have an array return type"), }; - let Some(num_generators) = size.evaluate_to_u32() else { - return Err(InterpreterError::UnknownArrayLength { length: *size, location }); - }; + let num_generators = size.evaluate_to_u32(location.span).map_err(|err| { + let err = Box::new(err); + InterpreterError::UnknownArrayLength { length: *size, err, location } + })?; let generators = bn254_blackbox_solver::derive_generators( &domain_separator_string, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 9917207d217a..51e62599b052 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -5,13 +5,13 @@ use crate::graph::CrateId; use crate::hir::comptime::InterpreterError; use crate::hir::def_map::{CrateDefMap, LocalModuleId, ModuleId}; use crate::hir::resolution::errors::ResolverError; -use crate::hir::resolution::path_resolver; use crate::hir::type_check::TypeCheckError; +use crate::locations::ReferencesTracker; use crate::token::SecondaryAttribute; use crate::usage_tracker::UnusedItem; use crate::{Generics, Type}; -use crate::hir::resolution::import::{resolve_import, ImportDirective, PathResolution}; +use crate::hir::resolution::import::{resolve_import, ImportDirective}; use crate::hir::Context; use crate::ast::Expression; @@ -347,45 +347,23 @@ impl DefCollector { // Resolve unresolved imports collected from the crate, one by one. for collected_import in std::mem::take(&mut def_collector.imports) { - let module_id = collected_import.module_id; - let resolved_import = if context.def_interner.lsp_mode { - let mut references: Vec = Vec::new(); - let resolved_import = resolve_import( - crate_id, - &collected_import, - &context.def_interner, - &context.def_maps, - &mut context.usage_tracker, - &mut Some(&mut references), - ); - - let current_def_map = context.def_maps.get(&crate_id).unwrap(); - let file_id = current_def_map.file_id(module_id); + let local_module_id = collected_import.module_id; + let module_id = ModuleId { krate: crate_id, local_id: local_module_id }; + let current_def_map = context.def_maps.get(&crate_id).unwrap(); + let file_id = current_def_map.file_id(local_module_id); + + let resolved_import = resolve_import( + collected_import.path.clone(), + module_id, + &context.def_maps, + &mut context.usage_tracker, + Some(ReferencesTracker::new(&mut context.def_interner, file_id)), + ); - for (referenced, segment) in references.iter().zip(&collected_import.path.segments) - { - context.def_interner.add_reference( - *referenced, - Location::new(segment.ident.span(), file_id), - false, - ); - } - - resolved_import - } else { - resolve_import( - crate_id, - &collected_import, - &context.def_interner, - &context.def_maps, - &mut context.usage_tracker, - &mut None, - ) - }; match resolved_import { Ok(resolved_import) => { let current_def_map = context.def_maps.get_mut(&crate_id).unwrap(); - let file_id = current_def_map.file_id(module_id); + let file_id = current_def_map.file_id(local_module_id); let has_path_resolution_error = !resolved_import.errors.is_empty(); for error in resolved_import.errors { @@ -396,11 +374,11 @@ impl DefCollector { } // Populate module namespaces according to the imports used - let name = resolved_import.name; + let name = collected_import.name(); let visibility = collected_import.visibility; - let is_prelude = resolved_import.is_prelude; + let is_prelude = collected_import.is_prelude; for (module_def_id, item_visibility, _) in - resolved_import.resolved_namespace.iter_items() + resolved_import.namespace.iter_items() { if item_visibility < visibility { errors.push(( @@ -414,25 +392,26 @@ impl DefCollector { } let visibility = visibility.min(item_visibility); - let result = current_def_map.modules[resolved_import.module_scope.0] - .import(name.clone(), visibility, module_def_id, is_prelude); + let result = current_def_map.modules[local_module_id.0].import( + name.clone(), + visibility, + module_def_id, + is_prelude, + ); // If we error on path resolution don't also say it's unused (in case it ends up being unused) if !has_path_resolution_error { - let module_id = ModuleId { - krate: crate_id, - local_id: resolved_import.module_scope, - }; + let defining_module = + ModuleId { krate: crate_id, local_id: local_module_id }; + context.usage_tracker.add_unused_item( - module_id, + defining_module, name.clone(), UnusedItem::Import, visibility, ); if visibility != ItemVisibility::Private { - let local_id = resolved_import.module_scope; - let defining_module = ModuleId { krate: crate_id, local_id }; context.def_interner.register_name_for_auto_import( name.to_string(), module_def_id, @@ -442,14 +421,6 @@ impl DefCollector { } } - let last_segment = collected_import.path.last_ident(); - - add_import_reference( - module_def_id, - &last_segment, - &mut context.def_interner, - file_id, - ); if let Some(ref alias) = collected_import.alias { add_import_reference( module_def_id, @@ -558,17 +529,18 @@ fn inject_prelude( span: Span::default(), }; - if let Ok(PathResolution { item, errors }) = path_resolver::resolve_path( - &context.def_interner, - &context.def_maps, - ModuleId { krate: crate_id, local_id: crate_root }, - None, + if let Ok(resolved_import) = resolve_import( path, + ModuleId { krate: crate_id, local_id: crate_root }, + &context.def_maps, &mut context.usage_tracker, - &mut None, + None, // references tracker ) { - assert!(errors.is_empty(), "Tried to add private item to prelude"); - let module_id = item.module_id().expect("std::prelude should be a module"); + assert!(resolved_import.errors.is_empty(), "Tried to add private item to prelude"); + + let (module_def_id, _, _) = + resolved_import.namespace.types.expect("couldn't resolve std::prelude"); + let module_id = module_def_id.as_module().expect("std::prelude should be a module"); let prelude = context.module(module_id).scope().names(); for path in prelude { @@ -580,7 +552,6 @@ fn inject_prelude( ImportDirective { visibility: ItemVisibility::Private, module_id: crate_root, - self_type_module_id: None, path: Path { segments, kind: PathKind::Plain, span: Span::default() }, alias: None, is_prelude: true, diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 94c091f97918..a373441b4e0b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -81,7 +81,6 @@ pub fn collect_defs( collector.def_collector.imports.push(ImportDirective { visibility: import.visibility, module_id: collector.module_id, - self_type_module_id: None, path: import.path, alias: import.alias, is_prelude: false, @@ -542,7 +541,7 @@ impl<'a> ModCollector<'a> { name: Rc::new(name.to_string()), type_var: TypeVariable::unbound( type_variable_id, - Kind::Numeric(Box::new(typ)), + Kind::numeric(typ), ), span: name.span(), }); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/mod.rs index 60ee2c52842b..de94f73b44be 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -169,7 +169,7 @@ impl CrateDefMap { module.value_definitions().filter_map(|id| { if let Some(func_id) = id.as_function() { let attributes = interner.function_attributes(&func_id); - match &attributes.function { + match attributes.function() { Some(FunctionAttribute::Test(scope)) => { let location = interner.function_meta(&func_id).name.location; Some(TestFunction::new(func_id, scope.clone(), location)) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs index 67820bfd1b7a..b82eafa5b9d2 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -5,7 +5,7 @@ use thiserror::Error; use crate::{ ast::{Ident, UnsupportedNumericGenericType}, - hir::comptime::InterpreterError, + hir::{comptime::InterpreterError, type_check::TypeCheckError}, parser::ParserError, usage_tracker::UnusedItem, Type, @@ -125,11 +125,12 @@ pub enum ResolverError { NamedTypeArgs { span: Span, item_kind: &'static str }, #[error("Associated constants may only be a field or integer type")] AssociatedConstantsMustBeNumeric { span: Span }, - #[error("Overflow in `{lhs} {op} {rhs}`")] - OverflowInType { + #[error("Computing `{lhs} {op} {rhs}` failed with error {err}")] + BinaryOpError { lhs: FieldElement, op: crate::BinaryTypeOperator, rhs: FieldElement, + err: Box, span: Span, }, #[error("`quote` cannot be used in runtime code")] @@ -518,10 +519,10 @@ impl<'a> From<&'a ResolverError> for Diagnostic { *span, ) } - ResolverError::OverflowInType { lhs, op, rhs, span } => { + ResolverError::BinaryOpError { lhs, op, rhs, err, span } => { Diagnostic::simple_error( - format!("Overflow in `{lhs} {op} {rhs}`"), - "Overflow here".to_string(), + format!("Computing `{lhs} {op} {rhs}` failed with error {err}"), + String::new(), *span, ) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs index 7afb056cbaf6..376b85bfbd97 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -4,110 +4,37 @@ use thiserror::Error; use crate::graph::CrateId; use crate::hir::def_collector::dc_crate::CompilationError; -use crate::node_interner::{ - FuncId, GlobalId, NodeInterner, ReferenceId, StructId, TraitId, TypeAliasId, -}; +use crate::locations::ReferencesTracker; use crate::usage_tracker::UsageTracker; -use crate::Type; use std::collections::BTreeMap; -use crate::ast::{Ident, ItemVisibility, Path, PathKind, PathSegment, UnresolvedType}; -use crate::hir::def_map::{CrateDefMap, LocalModuleId, ModuleDefId, ModuleId, PerNs}; +use crate::ast::{Ident, ItemVisibility, Path, PathKind}; +use crate::hir::def_map::{CrateDefMap, LocalModuleId, ModuleData, ModuleDefId, ModuleId, PerNs}; use super::errors::ResolverError; -use super::visibility::can_reference_module_id; +use super::visibility::item_in_module_is_visible; #[derive(Debug, Clone)] pub struct ImportDirective { pub visibility: ItemVisibility, pub module_id: LocalModuleId, - pub self_type_module_id: Option, pub path: Path, pub alias: Option, pub is_prelude: bool, } -struct NamespaceResolution { - module_id: ModuleId, - item: PathResolutionItem, - namespace: PerNs, - errors: Vec, -} - -type NamespaceResolutionResult = Result; - -#[derive(Debug)] -pub struct PathResolution { - pub item: PathResolutionItem, - pub errors: Vec, -} - -/// All possible items that result from resolving a Path. -/// Note that this item doesn't include the last turbofish in a Path, -/// only intermediate ones, if any. -#[derive(Debug, Clone)] -pub enum PathResolutionItem { - Module(ModuleId), - Struct(StructId), - TypeAlias(TypeAliasId), - Trait(TraitId), - Global(GlobalId), - ModuleFunction(FuncId), - StructFunction(StructId, Option, FuncId), - TypeAliasFunction(TypeAliasId, Option, FuncId), - TraitFunction(TraitId, Option, FuncId), -} - -impl PathResolutionItem { - pub fn function_id(&self) -> Option { - match self { - PathResolutionItem::ModuleFunction(func_id) - | PathResolutionItem::StructFunction(_, _, func_id) - | PathResolutionItem::TypeAliasFunction(_, _, func_id) - | PathResolutionItem::TraitFunction(_, _, func_id) => Some(*func_id), - _ => None, - } - } - - pub fn module_id(&self) -> Option { - match self { - Self::Module(module_id) => Some(*module_id), - _ => None, - } - } - - pub fn description(&self) -> &'static str { - match self { - PathResolutionItem::Module(..) => "module", - PathResolutionItem::Struct(..) => "type", - PathResolutionItem::TypeAlias(..) => "type alias", - PathResolutionItem::Trait(..) => "trait", - PathResolutionItem::Global(..) => "global", - PathResolutionItem::ModuleFunction(..) - | PathResolutionItem::StructFunction(..) - | PathResolutionItem::TypeAliasFunction(..) - | PathResolutionItem::TraitFunction(..) => "function", +impl ImportDirective { + /// Returns the name that's brought into scope: either the alias or the last segment of the path + pub fn name(&self) -> Ident { + match &self.alias { + None => self.path.last_ident(), + Some(ident) => ident.clone(), } } } -#[derive(Debug, Clone)] -pub struct Turbofish { - pub generics: Vec, - pub span: Span, -} - -/// Any item that can appear before the last segment in a path. -#[derive(Debug)] -enum IntermediatePathResolutionItem { - Module(ModuleId), - Struct(StructId, Option), - TypeAlias(TypeAliasId, Option), - Trait(TraitId, Option), -} - -pub(crate) type PathResolutionResult = Result; +type ImportResolutionResult = Result; #[derive(Debug, Clone, PartialEq, Eq, Error)] pub enum PathResolutionError { @@ -119,19 +46,15 @@ pub enum PathResolutionError { NoSuper(Span), #[error("turbofish (`::<_>`) not allowed on {item}")] TurbofishNotAllowedOnItem { item: String, span: Span }, + #[error("{ident} is a {kind}, not a module")] + NotAModule { ident: Ident, kind: &'static str }, } #[derive(Debug)] pub struct ResolvedImport { - // name of the namespace, either last path segment or an alias - pub name: Ident, // The symbol which we have resolved to - pub resolved_namespace: PerNs, - // The item which we have resolved to - pub item: PathResolutionItem, + pub namespace: PerNs, // The module which we must add the resolved namespace to - pub module_scope: LocalModuleId, - pub is_prelude: bool, pub errors: Vec, } @@ -159,452 +82,255 @@ impl<'a> From<&'a PathResolutionError> for CustomDiagnostic { PathResolutionError::TurbofishNotAllowedOnItem { item: _, span } => { CustomDiagnostic::simple_error(error.to_string(), String::new(), *span) } + PathResolutionError::NotAModule { ident, kind: _ } => { + CustomDiagnostic::simple_error(error.to_string(), String::new(), ident.span()) + } } } } +/// Resolves a Path in a `use` statement, assuming it's located in `importing_module`. +/// +/// If the imported name can't be found, `Err` will be returned. If it can be found, `Ok` +/// will be returned with a potential list of errors if, for example, one of the segments +/// is not accessible from the importing module (e.g. because it's private). pub fn resolve_import( - crate_id: CrateId, - import_directive: &ImportDirective, - interner: &NodeInterner, + path: Path, + importing_module: ModuleId, def_maps: &BTreeMap, usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, -) -> Result { - let module_scope = import_directive.module_id; - let NamespaceResolution { - module_id: resolved_module, - item, - namespace: resolved_namespace, - mut errors, - } = resolve_path_to_ns( - import_directive, - crate_id, - crate_id, - interner, - def_maps, - usage_tracker, - path_references, - )?; - - let name = resolve_path_name(import_directive); - - let visibility = resolved_namespace - .values - .or(resolved_namespace.types) - .map(|(_, visibility, _)| visibility) - .expect("Found empty namespace"); - - if !(import_directive.self_type_module_id == Some(resolved_module) - || can_reference_module_id( - def_maps, - crate_id, - import_directive.module_id, - resolved_module, - visibility, - )) - { - errors.push(PathResolutionError::Private(name.clone())); - } - - Ok(ResolvedImport { - name, - resolved_namespace, - item, - module_scope, - is_prelude: import_directive.is_prelude, - errors, - }) + references_tracker: Option, +) -> ImportResolutionResult { + let (path, module_id, references_tracker) = + resolve_path_kind(path, importing_module, def_maps, references_tracker)?; + let mut solver = + ImportSolver::new(importing_module, def_maps, usage_tracker, references_tracker); + solver.resolve_name_in_module(path, module_id) } -fn resolve_path_to_ns( - import_directive: &ImportDirective, - crate_id: CrateId, - importing_crate: CrateId, - interner: &NodeInterner, +/// Given a Path and a ModuleId it's being used in, this function returns a plain Path +/// and a ModuleId where that plain Path should be resolved. That is, this method will +/// resolve the Path kind and translate it to a plain path. +/// +/// The third value in the tuple is a reference tracker that must be passed to this +/// method, which is used in case the path kind is `dep`: the segment after `dep` +/// will be linked to the root module of the external dependency. +pub fn resolve_path_kind<'r>( + path: Path, + importing_module: ModuleId, def_maps: &BTreeMap, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, -) -> NamespaceResolutionResult { - let import_path = &import_directive.path.segments; - - match import_directive.path.kind { - crate::ast::PathKind::Crate => { - // Resolve from the root of the crate - resolve_path_from_crate_root( - crate_id, - importing_crate, - import_path, - interner, - def_maps, - usage_tracker, - path_references, - ) + references_tracker: Option>, +) -> Result<(Path, ModuleId, Option>), PathResolutionError> { + let mut solver = + PathResolutionTargetResolver { importing_module, def_maps, references_tracker }; + let (path, module_id) = solver.resolve(path)?; + Ok((path, module_id, solver.references_tracker)) +} + +struct PathResolutionTargetResolver<'def_maps, 'references_tracker> { + importing_module: ModuleId, + def_maps: &'def_maps BTreeMap, + references_tracker: Option>, +} + +impl<'def_maps, 'references_tracker> PathResolutionTargetResolver<'def_maps, 'references_tracker> { + fn resolve(&mut self, path: Path) -> Result<(Path, ModuleId), PathResolutionError> { + match path.kind { + PathKind::Crate => self.resolve_crate_path(path), + PathKind::Plain => self.resolve_plain_path(path, self.importing_module), + PathKind::Dep => self.resolve_dep_path(path), + PathKind::Super => self.resolve_super_path(path), } - crate::ast::PathKind::Plain => { - // There is a possibility that the import path is empty - // In that case, early return - if import_path.is_empty() { - return resolve_name_in_module( - crate_id, - importing_crate, - import_path, - import_directive.module_id, - interner, - def_maps, - true, // plain or crate - usage_tracker, - path_references, - ); - } + } - let def_map = &def_maps[&crate_id]; - let current_mod_id = ModuleId { krate: crate_id, local_id: import_directive.module_id }; - let current_mod = &def_map.modules[current_mod_id.local_id.0]; - let first_segment = - &import_path.first().expect("ice: could not fetch first segment").ident; - if current_mod.find_name(first_segment).is_none() { - // Resolve externally when first segment is unresolved - return resolve_external_dep( - crate_id, - // def_map, - import_directive, - interner, - def_maps, - usage_tracker, - path_references, - importing_crate, - ); - } + fn resolve_crate_path(&mut self, path: Path) -> Result<(Path, ModuleId), PathResolutionError> { + let root_module = self.def_maps[&self.importing_module.krate].root; + let current_module = ModuleId { krate: self.importing_module.krate, local_id: root_module }; + Ok((path, current_module)) + } - resolve_name_in_module( - crate_id, - importing_crate, - import_path, - import_directive.module_id, - interner, - def_maps, - true, // plain or crate - usage_tracker, - path_references, - ) + fn resolve_plain_path( + &mut self, + path: Path, + current_module: ModuleId, + ) -> Result<(Path, ModuleId), PathResolutionError> { + // There is a possibility that the import path is empty. In that case, early return. + // This happens on import statements such as `use crate` or `use std`. + if path.segments.is_empty() { + return Ok((path, current_module)); } - crate::ast::PathKind::Dep => resolve_external_dep( - crate_id, - import_directive, - interner, - def_maps, - usage_tracker, - path_references, - importing_crate, - ), - - crate::ast::PathKind::Super => { - if let Some(parent_module_id) = - def_maps[&crate_id].modules[import_directive.module_id.0].parent - { - resolve_name_in_module( - crate_id, - importing_crate, - import_path, - parent_module_id, - interner, - def_maps, - false, // plain or crate - usage_tracker, - path_references, - ) - } else { - let span_start = import_directive.path.span().start(); - let span = Span::from(span_start..span_start + 5); // 5 == "super".len() - Err(PathResolutionError::NoSuper(span)) - } + let first_segment = + &path.segments.first().expect("ice: could not fetch first segment").ident; + if get_module(self.def_maps, current_module).find_name(first_segment).is_none() { + // Resolve externally when first segment is unresolved + return self.resolve_dep_path(path); + } + + Ok((path, current_module)) + } + + fn resolve_dep_path( + &mut self, + mut path: Path, + ) -> Result<(Path, ModuleId), PathResolutionError> { + // Use extern_prelude to get the dep + let current_def_map = &self.def_maps[&self.importing_module.krate]; + + // Fetch the root module from the prelude + let crate_name = &path.segments.first().unwrap().ident; + let dep_module = current_def_map + .extern_prelude + .get(&crate_name.0.contents) + .ok_or_else(|| PathResolutionError::Unresolved(crate_name.to_owned()))?; + + if let Some(references_tracker) = &mut self.references_tracker { + let span = crate_name.span(); + references_tracker.add_reference(ModuleDefId::ModuleId(*dep_module), span, false); } + + // Now the path can be solved starting from the second segment as a plain path + path.kind = PathKind::Plain; + path.segments.remove(0); + + Ok((path, *dep_module)) + } + + fn resolve_super_path(&mut self, path: Path) -> Result<(Path, ModuleId), PathResolutionError> { + let Some(parent_module_id) = get_module(self.def_maps, self.importing_module).parent else { + let span_start = path.span.start(); + let span = Span::from(span_start..span_start + 5); // 5 == "super".len() + return Err(PathResolutionError::NoSuper(span)); + }; + + let current_module = + ModuleId { krate: self.importing_module.krate, local_id: parent_module_id }; + Ok((path, current_module)) } } -fn resolve_path_from_crate_root( - crate_id: CrateId, - importing_crate: CrateId, - import_path: &[PathSegment], - interner: &NodeInterner, - def_maps: &BTreeMap, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, -) -> NamespaceResolutionResult { - let starting_mod = def_maps[&crate_id].root; - resolve_name_in_module( - crate_id, - importing_crate, - import_path, - starting_mod, - interner, - def_maps, - true, // plain or crate - usage_tracker, - path_references, - ) +struct ImportSolver<'def_maps, 'usage_tracker, 'references_tracker> { + importing_module: ModuleId, + def_maps: &'def_maps BTreeMap, + usage_tracker: &'usage_tracker mut UsageTracker, + references_tracker: Option>, } -#[allow(clippy::too_many_arguments)] -fn resolve_name_in_module( - krate: CrateId, - importing_crate: CrateId, - import_path: &[PathSegment], - starting_mod: LocalModuleId, - interner: &NodeInterner, - def_maps: &BTreeMap, - plain_or_crate: bool, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, -) -> NamespaceResolutionResult { - let def_map = &def_maps[&krate]; - let mut current_mod_id = ModuleId { krate, local_id: starting_mod }; - let mut current_mod = &def_map.modules[current_mod_id.local_id.0]; - - let mut intermediate_item = IntermediatePathResolutionItem::Module(current_mod_id); - - // There is a possibility that the import path is empty - // In that case, early return - if import_path.is_empty() { - return Ok(NamespaceResolution { - module_id: current_mod_id, - item: PathResolutionItem::Module(current_mod_id), - namespace: PerNs::types(current_mod_id.into()), - errors: Vec::new(), - }); +impl<'def_maps, 'usage_tracker, 'references_tracker> + ImportSolver<'def_maps, 'usage_tracker, 'references_tracker> +{ + fn new( + importing_module: ModuleId, + def_maps: &'def_maps BTreeMap, + usage_tracker: &'usage_tracker mut UsageTracker, + references_tracker: Option>, + ) -> Self { + Self { importing_module, def_maps, usage_tracker, references_tracker } } - let first_segment = &import_path.first().expect("ice: could not fetch first segment").ident; - let mut current_ns = current_mod.find_name(first_segment); - if current_ns.is_none() { - return Err(PathResolutionError::Unresolved(first_segment.clone())); - } + fn resolve_name_in_module( + &mut self, + path: Path, + starting_module: ModuleId, + ) -> ImportResolutionResult { + // There is a possibility that the import path is empty. In that case, early return. + if path.segments.is_empty() { + return Ok(ResolvedImport { + namespace: PerNs::types(starting_module.into()), + errors: Vec::new(), + }); + } - usage_tracker.mark_as_referenced(current_mod_id, first_segment); + let plain_or_crate = matches!(path.kind, PathKind::Plain | PathKind::Crate); - let mut errors = Vec::new(); - for (index, (last_segment, current_segment)) in - import_path.iter().zip(import_path.iter().skip(1)).enumerate() - { - let last_ident = &last_segment.ident; - let current_ident = ¤t_segment.ident; - let last_segment_generics = &last_segment.generics; + // The current module and module ID as we resolve path segments + let mut current_module_id = starting_module; + let mut current_module = get_module(self.def_maps, starting_module); - let (typ, visibility) = match current_ns.types { - None => return Err(PathResolutionError::Unresolved(last_ident.clone())), - Some((typ, visibility, _)) => (typ, visibility), - }; + let first_segment = + &path.segments.first().expect("ice: could not fetch first segment").ident; + let mut current_ns = current_module.find_name(first_segment); + if current_ns.is_none() { + return Err(PathResolutionError::Unresolved(first_segment.clone())); + } - // In the type namespace, only Mod can be used in a path. - (current_mod_id, intermediate_item) = match typ { - ModuleDefId::ModuleId(id) => { - if let Some(path_references) = path_references { - path_references.push(ReferenceId::Module(id)); - } + self.usage_tracker.mark_as_referenced(current_module_id, first_segment); - if last_segment_generics.is_some() { - errors.push(PathResolutionError::TurbofishNotAllowedOnItem { - item: format!("module `{last_ident}`"), - span: last_segment.turbofish_span(), + let mut errors = Vec::new(); + for (index, (last_segment, current_segment)) in + path.segments.iter().zip(path.segments.iter().skip(1)).enumerate() + { + let last_ident = &last_segment.ident; + let current_ident = ¤t_segment.ident; + + let (typ, visibility) = match current_ns.types { + None => return Err(PathResolutionError::Unresolved(last_ident.clone())), + Some((typ, visibility, _)) => (typ, visibility), + }; + + self.add_reference(typ, last_segment.span, last_segment.ident.is_self_type_name()); + + // In the type namespace, only Mod can be used in a path. + current_module_id = match typ { + ModuleDefId::ModuleId(id) => id, + ModuleDefId::TypeId(id) => id.module_id(), + ModuleDefId::TypeAliasId(..) => { + return Err(PathResolutionError::NotAModule { + ident: last_segment.ident.clone(), + kind: "type alias", }); } - - (id, IntermediatePathResolutionItem::Module(id)) + ModuleDefId::TraitId(id) => id.0, + ModuleDefId::FunctionId(_) => panic!("functions cannot be in the type namespace"), + ModuleDefId::GlobalId(_) => panic!("globals cannot be in the type namespace"), + }; + + // If the path is plain or crate, the first segment will always refer to + // something that's visible from the current module. + if !((plain_or_crate && index == 0) + || self.item_in_module_is_visible(current_module_id, visibility)) + { + errors.push(PathResolutionError::Private(last_ident.clone())); } - ModuleDefId::FunctionId(_) => panic!("functions cannot be in the type namespace"), - // TODO: If impls are ever implemented, types can be used in a path - ModuleDefId::TypeId(id) => { - if let Some(path_references) = path_references { - path_references.push(ReferenceId::Struct(id)); - } - ( - id.module_id(), - IntermediatePathResolutionItem::Struct( - id, - last_segment_generics.as_ref().map(|generics| Turbofish { - generics: generics.clone(), - span: last_segment.turbofish_span(), - }), - ), - ) - } - ModuleDefId::TypeAliasId(id) => { - if let Some(path_references) = path_references { - path_references.push(ReferenceId::Alias(id)); - } + current_module = + &self.def_maps[¤t_module_id.krate].modules[current_module_id.local_id.0]; - let type_alias = interner.get_type_alias(id); - let type_alias = type_alias.borrow(); - - let module_id = match &type_alias.typ { - Type::Struct(struct_id, _generics) => struct_id.borrow().id.module_id(), - Type::Error => { - return Err(PathResolutionError::Unresolved(last_ident.clone())); - } - _ => { - // For now we only allow type aliases that point to structs. - // The more general case is captured here: https://github.com/noir-lang/noir/issues/6398 - panic!("Type alias in path not pointing to struct not yet supported") - } - }; - - ( - module_id, - IntermediatePathResolutionItem::TypeAlias( - id, - last_segment_generics.as_ref().map(|generics| Turbofish { - generics: generics.clone(), - span: last_segment.turbofish_span(), - }), - ), - ) + // Check if namespace + let found_ns = current_module.find_name(current_ident); + if found_ns.is_none() { + return Err(PathResolutionError::Unresolved(current_ident.clone())); } - ModuleDefId::TraitId(id) => { - if let Some(path_references) = path_references { - path_references.push(ReferenceId::Trait(id)); - } - ( - id.0, - IntermediatePathResolutionItem::Trait( - id, - last_segment_generics.as_ref().map(|generics| Turbofish { - generics: generics.clone(), - span: last_segment.turbofish_span(), - }), - ), - ) - } - ModuleDefId::GlobalId(_) => panic!("globals cannot be in the type namespace"), - }; + self.usage_tracker.mark_as_referenced(current_module_id, current_ident); - // If the path is plain or crate, the first segment will always refer to - // something that's visible from the current module. - if !((plain_or_crate && index == 0) - || can_reference_module_id( - def_maps, - importing_crate, - starting_mod, - current_mod_id, - visibility, - )) - { - errors.push(PathResolutionError::Private(last_ident.clone())); + current_ns = found_ns; } - current_mod = &def_maps[¤t_mod_id.krate].modules[current_mod_id.local_id.0]; + let (module_def_id, visibility, _) = + current_ns.values.or(current_ns.types).expect("Found empty namespace"); - // Check if namespace - let found_ns = current_mod.find_name(current_ident); + self.add_reference(module_def_id, path.segments.last().unwrap().ident.span(), false); - if found_ns.is_none() { - return Err(PathResolutionError::Unresolved(current_ident.clone())); + if !self.item_in_module_is_visible(current_module_id, visibility) { + errors.push(PathResolutionError::Private(path.last_ident())); } - usage_tracker.mark_as_referenced(current_mod_id, current_ident); - - current_ns = found_ns; + Ok(ResolvedImport { namespace: current_ns, errors }) } - let module_def_id = - current_ns.values.or(current_ns.types).map(|(id, _, _)| id).expect("Found empty namespace"); - - let item = merge_intermediate_path_resolution_item_with_module_def_id( - intermediate_item, - module_def_id, - ); - - Ok(NamespaceResolution { module_id: current_mod_id, item, namespace: current_ns, errors }) -} - -fn resolve_path_name(import_directive: &ImportDirective) -> Ident { - match &import_directive.alias { - None => import_directive.path.last_ident(), - Some(ident) => ident.clone(), + fn add_reference(&mut self, reference_id: ModuleDefId, span: Span, is_self_type_name: bool) { + if let Some(references_tracker) = &mut self.references_tracker { + references_tracker.add_reference(reference_id, span, is_self_type_name); + } } -} -fn resolve_external_dep( - crate_id: CrateId, - directive: &ImportDirective, - interner: &NodeInterner, - def_maps: &BTreeMap, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, - importing_crate: CrateId, -) -> NamespaceResolutionResult { - // Use extern_prelude to get the dep - let path = &directive.path.segments; - - let current_def_map = &def_maps[&crate_id]; - - // Fetch the root module from the prelude - let crate_name = &path.first().unwrap().ident; - let dep_module = current_def_map - .extern_prelude - .get(&crate_name.0.contents) - .ok_or_else(|| PathResolutionError::Unresolved(crate_name.to_owned()))?; - - // Create an import directive for the dependency crate - // XXX: This will panic if the path is of the form `use std`. Ideal algorithm will not distinguish between crate and module - // See `singleton_import.nr` test case for a check that such cases are handled elsewhere. - let path_without_crate_name = &path[1..]; - - if let Some(path_references) = path_references { - path_references.push(ReferenceId::Module(*dep_module)); + fn item_in_module_is_visible(&self, module: ModuleId, visibility: ItemVisibility) -> bool { + item_in_module_is_visible(self.def_maps, self.importing_module, module, visibility) } - - let path = Path { - segments: path_without_crate_name.to_vec(), - kind: PathKind::Plain, - span: Span::default(), - }; - let dep_directive = ImportDirective { - visibility: ItemVisibility::Private, - module_id: dep_module.local_id, - self_type_module_id: directive.self_type_module_id, - path, - alias: directive.alias.clone(), - is_prelude: false, - }; - - resolve_path_to_ns( - &dep_directive, - dep_module.krate, - importing_crate, - interner, - def_maps, - usage_tracker, - path_references, - ) } -fn merge_intermediate_path_resolution_item_with_module_def_id( - intermediate_item: IntermediatePathResolutionItem, - module_def_id: ModuleDefId, -) -> PathResolutionItem { - match module_def_id { - ModuleDefId::ModuleId(module_id) => PathResolutionItem::Module(module_id), - ModuleDefId::TypeId(struct_id) => PathResolutionItem::Struct(struct_id), - ModuleDefId::TypeAliasId(type_alias_id) => PathResolutionItem::TypeAlias(type_alias_id), - ModuleDefId::TraitId(trait_id) => PathResolutionItem::Trait(trait_id), - ModuleDefId::GlobalId(global_id) => PathResolutionItem::Global(global_id), - ModuleDefId::FunctionId(func_id) => match intermediate_item { - IntermediatePathResolutionItem::Module(_) => { - PathResolutionItem::ModuleFunction(func_id) - } - IntermediatePathResolutionItem::Struct(struct_id, generics) => { - PathResolutionItem::StructFunction(struct_id, generics, func_id) - } - IntermediatePathResolutionItem::TypeAlias(alias_id, generics) => { - PathResolutionItem::TypeAliasFunction(alias_id, generics, func_id) - } - IntermediatePathResolutionItem::Trait(trait_id, generics) => { - PathResolutionItem::TraitFunction(trait_id, generics, func_id) - } - }, - } +fn get_module(def_maps: &BTreeMap, module: ModuleId) -> &ModuleData { + let message = "A crate should always be present for a given crate id"; + &def_maps.get(&module.krate).expect(message).modules[module.local_id.0] } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/mod.rs index 223b88b5c5df..44a0114074e6 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/mod.rs @@ -7,5 +7,4 @@ //! will have the same DefinitionId. pub mod errors; pub mod import; -pub mod path_resolver; pub mod visibility; diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/path_resolver.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/path_resolver.rs deleted file mode 100644 index 98d4aee3f5c0..000000000000 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/path_resolver.rs +++ /dev/null @@ -1,102 +0,0 @@ -use super::import::{resolve_import, ImportDirective, PathResolution, PathResolutionResult}; -use crate::ast::{ItemVisibility, Path}; -use crate::node_interner::{NodeInterner, ReferenceId}; -use crate::usage_tracker::UsageTracker; - -use std::collections::BTreeMap; - -use crate::graph::CrateId; -use crate::hir::def_map::{CrateDefMap, LocalModuleId, ModuleId}; - -pub trait PathResolver { - /// Resolve the given path returning the resolved ModuleDefId. - /// If `path_references` is `Some`, a `ReferenceId` for each segment in `path` - /// will be resolved and pushed (some entries will be None if they don't refer to - /// a module or type). - fn resolve( - &self, - interner: &NodeInterner, - def_maps: &BTreeMap, - path: Path, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, - ) -> PathResolutionResult; - - fn local_module_id(&self) -> LocalModuleId; - - fn module_id(&self) -> ModuleId; -} - -pub struct StandardPathResolver { - // Module that we are resolving the path in - module_id: ModuleId, - // The module of the self type, if any (for example, the ModuleId of a struct) - self_type_module_id: Option, -} - -impl StandardPathResolver { - pub fn new(module_id: ModuleId, self_type_module_id: Option) -> StandardPathResolver { - Self { module_id, self_type_module_id } - } -} - -impl PathResolver for StandardPathResolver { - fn resolve( - &self, - interner: &NodeInterner, - def_maps: &BTreeMap, - path: Path, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, - ) -> PathResolutionResult { - resolve_path( - interner, - def_maps, - self.module_id, - self.self_type_module_id, - path, - usage_tracker, - path_references, - ) - } - - fn local_module_id(&self) -> LocalModuleId { - self.module_id.local_id - } - - fn module_id(&self) -> ModuleId { - self.module_id - } -} - -/// Resolve the given path to a function or a type. -/// In the case of a conflict, functions are given priority -pub fn resolve_path( - interner: &NodeInterner, - def_maps: &BTreeMap, - module_id: ModuleId, - self_type_module_id: Option, - path: Path, - usage_tracker: &mut UsageTracker, - path_references: &mut Option<&mut Vec>, -) -> PathResolutionResult { - // lets package up the path into an ImportDirective and resolve it using that - let import = ImportDirective { - visibility: ItemVisibility::Private, - module_id: module_id.local_id, - self_type_module_id, - path, - alias: None, - is_prelude: false, - }; - let resolved_import = resolve_import( - module_id.krate, - &import, - interner, - def_maps, - usage_tracker, - path_references, - )?; - - Ok(PathResolution { item: resolved_import.item, errors: resolved_import.errors }) -} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/visibility.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/visibility.rs index 492f303d2c48..c2fe887fe621 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/visibility.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/visibility.rs @@ -7,34 +7,43 @@ use std::collections::BTreeMap; use crate::ast::ItemVisibility; use crate::hir::def_map::{CrateDefMap, DefMaps, LocalModuleId, ModuleId}; -// Returns false if the given private function is being called from a non-child module, or -// if the given pub(crate) function is being called from another crate. Otherwise returns true. -pub fn can_reference_module_id( +/// Returns true if an item with the given visibility in the target module +/// is visible from the current module. For example: +/// ```text +/// mod foo { +/// ^^^ <-- target module +/// pub(crate) fn bar() {} +/// ^^^^^^^^^^ <- visibility +/// } +/// ``` +pub fn item_in_module_is_visible( def_maps: &BTreeMap, - importing_crate: CrateId, - current_module: LocalModuleId, + current_module: ModuleId, target_module: ModuleId, visibility: ItemVisibility, ) -> bool { // Note that if the target module is in a different crate from the current module then we will either // return true as the target module is public or return false as it is private without looking at the `CrateDefMap` in either case. - let same_crate = target_module.krate == importing_crate; + let same_crate = target_module.krate == current_module.krate; match visibility { ItemVisibility::Public => true, ItemVisibility::PublicCrate => same_crate, ItemVisibility::Private => { + if !same_crate { + return false; + } + let target_crate_def_map = &def_maps[&target_module.krate]; - same_crate - && (module_descendent_of_target( - target_crate_def_map, - target_module.local_id, - current_module, - ) || module_is_parent_of_struct_module( - target_crate_def_map, - current_module, - target_module.local_id, - )) + module_descendent_of_target( + target_crate_def_map, + target_module.local_id, + current_module.local_id, + ) || module_is_parent_of_struct_module( + target_crate_def_map, + current_module.local_id, + target_module.local_id, + ) } } } @@ -116,10 +125,9 @@ pub fn method_call_is_visible( ItemVisibility::Private => { if object_type.is_primitive() { let func_module = interner.function_module(func_id); - can_reference_module_id( + item_in_module_is_visible( def_maps, - current_module.krate, - current_module.local_id, + current_module, func_module, modifiers.visibility, ) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs index cb69053b72a6..a63601a42805 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/type_check/errors.rs @@ -11,7 +11,7 @@ use crate::ast::{ use crate::hir::resolution::errors::ResolverError; use crate::hir_def::expr::HirBinaryOp; use crate::hir_def::traits::TraitConstraint; -use crate::hir_def::types::Type; +use crate::hir_def::types::{BinaryTypeOperator, Kind, Type}; use crate::node_interner::NodeInterner; #[derive(Error, Debug, Clone, PartialEq, Eq)] @@ -34,12 +34,22 @@ pub enum Source { Return(FunctionReturnType, Span), } -#[derive(Error, Debug, Clone)] +#[derive(Error, Debug, Clone, PartialEq, Eq)] pub enum TypeCheckError { #[error("Operator {op:?} cannot be used in a {place:?}")] OpCannotBeUsed { op: HirBinaryOp, place: &'static str, span: Span }, + #[error("Division by zero: {lhs} / {rhs}")] + DivisionByZero { lhs: FieldElement, rhs: FieldElement, span: Span }, + #[error("Modulo on Field elements: {lhs} % {rhs}")] + ModuloOnFields { lhs: FieldElement, rhs: FieldElement, span: Span }, #[error("The value `{expr:?}` cannot fit into `{ty}` which has range `{range}`")] OverflowingAssignment { expr: FieldElement, ty: Type, range: String, span: Span }, + #[error( + "The value `{value}` cannot fit into `{kind}` which has a maximum size of `{maximum_size}`" + )] + OverflowingConstant { value: FieldElement, kind: Kind, maximum_size: FieldElement, span: Span }, + #[error("Evaluating `{op}` on `{lhs}`, `{rhs}` failed")] + FailingBinaryOp { op: BinaryTypeOperator, lhs: i128, rhs: i128, span: Span }, #[error("Type {typ:?} cannot be used in a {place:?}")] TypeCannotBeUsed { typ: Type, place: &'static str, span: Span }, #[error("Expected type {expected_typ:?} is not the same as {expr_typ:?}")] @@ -48,6 +58,14 @@ pub enum TypeCheckError { TypeMismatchWithSource { expected: Type, actual: Type, span: Span, source: Source }, #[error("Expected type {expected_kind:?} is not the same as {expr_kind:?}")] TypeKindMismatch { expected_kind: String, expr_kind: String, expr_span: Span }, + #[error("Evaluating {to} resulted in {to_value}, but {from_value} was expected")] + TypeCanonicalizationMismatch { + to: Type, + from: Type, + to_value: FieldElement, + from_value: FieldElement, + span: Span, + }, // TODO(https://github.com/noir-lang/noir/issues/6238): implement handling for larger types #[error("Expected type {expected_kind} when evaluating globals, but found {expr_kind} (this warning may become an error in the future)")] EvaluatedGlobalIsntU32 { expected_kind: String, expr_kind: String, expr_span: Span }, @@ -158,6 +176,8 @@ pub enum TypeCheckError { Unsafe { span: Span }, #[error("Converting an unconstrained fn to a non-unconstrained fn is unsafe")] UnsafeFn { span: Span }, + #[error("Expected a constant, but found `{typ}`")] + NonConstantEvaluated { typ: Type, span: Span }, #[error("Slices must have constant length")] NonConstantSliceLength { span: Span }, #[error("Only sized types may be used in the entry point to a program")] @@ -196,6 +216,10 @@ impl TypeCheckError { pub fn add_context(self, ctx: &'static str) -> Self { TypeCheckError::Context { err: Box::new(self), ctx } } + + pub(crate) fn is_non_constant_evaluated(&self) -> bool { + matches!(self, TypeCheckError::NonConstantEvaluated { .. }) + } } impl<'a> From<&'a TypeCheckError> for Diagnostic { @@ -216,6 +240,16 @@ impl<'a> From<&'a TypeCheckError> for Diagnostic { String::new(), *span, ), + TypeCheckError::DivisionByZero { lhs, rhs, span } => Diagnostic::simple_error( + format!("Division by zero: {lhs} / {rhs}"), + String::new(), + *span, + ), + TypeCheckError::ModuloOnFields { lhs, rhs, span } => Diagnostic::simple_error( + format!("Modulo on Field elements: {lhs} % {rhs}"), + String::new(), + *span, + ), TypeCheckError::TypeMismatch { expected_typ, expr_typ, expr_span } => { Diagnostic::simple_error( format!("Expected type {expected_typ}, found type {expr_typ}"), @@ -230,6 +264,13 @@ impl<'a> From<&'a TypeCheckError> for Diagnostic { *expr_span, ) } + TypeCheckError::TypeCanonicalizationMismatch { to, from, to_value, from_value, span } => { + Diagnostic::simple_error( + format!("Evaluating {to} resulted in {to_value}, but {from_value} was expected"), + format!("from evaluating {from} without simplifications"), + *span, + ) + } // TODO(https://github.com/noir-lang/noir/issues/6238): implement // handling for larger types TypeCheckError::EvaluatedGlobalIsntU32 { expected_kind, expr_kind, expr_span } => { @@ -320,11 +361,14 @@ impl<'a> From<&'a TypeCheckError> for Diagnostic { | TypeCheckError::AmbiguousBitWidth { span, .. } | TypeCheckError::IntegerAndFieldBinaryOperation { span } | TypeCheckError::OverflowingAssignment { span, .. } + | TypeCheckError::OverflowingConstant { span, .. } + | TypeCheckError::FailingBinaryOp { span, .. } | TypeCheckError::FieldModulo { span } | TypeCheckError::FieldNot { span } | TypeCheckError::ConstrainedReferenceToUnconstrained { span } | TypeCheckError::UnconstrainedReferenceToConstrained { span } | TypeCheckError::UnconstrainedSliceReturnToConstrained { span } + | TypeCheckError::NonConstantEvaluated { span, .. } | TypeCheckError::NonConstantSliceLength { span } | TypeCheckError::StringIndexAssign { span } | TypeCheckError::InvalidShiftSize { span } => { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs index 6ecfdefe996a..db6c3507b151 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/function.rs @@ -9,7 +9,7 @@ use crate::ast::{BlockExpression, FunctionKind, FunctionReturnType, Visibility}; use crate::graph::CrateId; use crate::hir::def_map::LocalModuleId; use crate::node_interner::{ExprId, NodeInterner, StructId, TraitId, TraitImplId}; -use crate::token::CustomAttribute; + use crate::{ResolvedGeneric, Type}; /// A Hir function is a block expression with a list of statements. @@ -164,9 +164,6 @@ pub struct FuncMeta { /// If this function is from an impl (trait or regular impl), this /// is the object type of the impl. Otherwise this is None. pub self_type: Option, - - /// Custom attributes attached to this function. - pub custom_attributes: Vec, } #[derive(Debug, Clone)] diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/stmt.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/stmt.rs index b97e99583bb2..0258cfd8ddb8 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/stmt.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/stmt.rs @@ -105,7 +105,7 @@ impl HirPattern { } } - pub(crate) fn location(&self) -> Location { + pub fn location(&self) -> Location { match self { HirPattern::Identifier(ident) => ident.location, HirPattern::Mutable(_, location) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs index 0eed79348e21..a0fea3aa774a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types.rs @@ -5,6 +5,9 @@ use std::{ rc::Rc, }; +#[cfg(test)] +use proptest_derive::Arbitrary; + use acvm::{AcirField, FieldElement}; use crate::{ @@ -91,6 +94,14 @@ pub enum Type { /// like `fn foo(...) {}`. Unlike TypeVariables, they cannot be bound over. NamedGeneric(TypeVariable, Rc), + /// A cast (to, from) that's checked at monomorphization. + /// + /// Simplifications on arithmetic generics are only allowed on the LHS. + CheckedCast { + from: Box, + to: Box, + }, + /// A functions with arguments, a return type and environment. /// the environment should be `Unit` by default, /// for closures it should contain a `Tuple` type with the captured @@ -161,6 +172,11 @@ pub enum Kind { } impl Kind { + // Kind::Numeric constructor helper + pub fn numeric(typ: Type) -> Kind { + Kind::Numeric(Box::new(typ)) + } + pub(crate) fn is_error(&self) -> bool { match self.follow_bindings() { Self::Numeric(typ) => *typ == Type::Error, @@ -188,7 +204,7 @@ impl Kind { } pub(crate) fn u32() -> Self { - Self::Numeric(Box::new(Type::Integer(Signedness::Unsigned, IntegerBitSize::ThirtyTwo))) + Self::numeric(Type::Integer(Signedness::Unsigned, IntegerBitSize::ThirtyTwo)) } pub(crate) fn follow_bindings(&self) -> Self { @@ -197,7 +213,7 @@ impl Kind { Self::Normal => Self::Normal, Self::Integer => Self::Integer, Self::IntegerOrField => Self::IntegerOrField, - Self::Numeric(typ) => Self::Numeric(Box::new(typ.follow_bindings())), + Self::Numeric(typ) => Self::numeric(typ.follow_bindings()), } } @@ -255,10 +271,21 @@ impl Kind { } /// Ensure the given value fits in self.integral_maximum_size() - fn ensure_value_fits(&self, value: FieldElement) -> Option { + fn ensure_value_fits( + &self, + value: FieldElement, + span: Span, + ) -> Result { match self.integral_maximum_size() { - None => Some(value), - Some(maximum_size) => (value <= maximum_size).then_some(value), + None => Ok(value), + Some(maximum_size) => (value <= maximum_size).then_some(value).ok_or_else(|| { + TypeCheckError::OverflowingConstant { + value, + kind: self.clone(), + maximum_size, + span, + } + }), } } } @@ -652,6 +679,7 @@ impl Shared { /// A restricted subset of binary operators useable on /// type level integers for use in the array length positions of types. +#[cfg_attr(test, derive(Arbitrary))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub enum BinaryTypeOperator { Addition, @@ -863,6 +891,7 @@ impl std::fmt::Display for Type { TypeBinding::Unbound(_, _) if name.is_empty() => write!(f, "_"), TypeBinding::Unbound(_, _) => write!(f, "{name}"), }, + Type::CheckedCast { to, .. } => write!(f, "{to}"), Type::Constant(x, _kind) => write!(f, "{x}"), Type::Forall(typevars, typ) => { let typevars = vecmap(typevars, |var| var.id().to_string()); @@ -887,7 +916,7 @@ impl std::fmt::Display for Type { } Type::Quoted(quoted) => write!(f, "{}", quoted), Type::InfixExpr(lhs, op, rhs) => { - let this = self.canonicalize(); + let this = self.canonicalize_checked(); // Prevent infinite recursion if this != *self { @@ -1064,6 +1093,7 @@ impl Type { | Type::TypeVariable(..) | Type::TraitAsType(..) | Type::NamedGeneric(..) + | Type::CheckedCast { .. } | Type::Forall(..) | Type::Constant(..) | Type::Quoted(..) @@ -1106,6 +1136,10 @@ impl Type { Type::NamedGeneric(_, _) => { named_generic_is_numeric(self, found_names); } + Type::CheckedCast { from, to } => { + to.find_numeric_type_vars(found_names); + from.find_numeric_type_vars(found_names); + } Type::TraitAsType(_, _, args) => { for arg in args.ordered.iter() { @@ -1187,9 +1221,10 @@ impl Type { | Type::Forall(_, _) | Type::Quoted(_) | Type::Slice(_) - | Type::InfixExpr(_, _, _) | Type::TraitAsType(..) => false, + Type::CheckedCast { to, .. } => to.is_valid_for_program_input(), + Type::Alias(alias, generics) => { let alias = alias.borrow(); alias.get_type(generics).is_valid_for_program_input() @@ -1205,6 +1240,10 @@ impl Type { .get_fields(generics) .into_iter() .all(|(_, field)| field.is_valid_for_program_input()), + + Type::InfixExpr(lhs, _, rhs) => { + lhs.is_valid_for_program_input() && rhs.is_valid_for_program_input() + } } } @@ -1239,6 +1278,8 @@ impl Type { | Type::Quoted(_) | Type::TraitAsType(..) => false, + Type::CheckedCast { to, .. } => to.is_valid_non_inlined_function_input(), + Type::Alias(alias, generics) => { let alias = alias.borrow(); alias.get_type(generics).is_valid_non_inlined_function_input() @@ -1280,6 +1321,8 @@ impl Type { } } + Type::CheckedCast { to, .. } => to.is_valid_for_unconstrained_boundary(), + // Quoted objects only exist at compile-time where the only execution // environment is the interpreter. In this environment, they are valid. Type::Quoted(_) => true, @@ -1312,6 +1355,7 @@ impl Type { pub fn generic_count(&self) -> usize { match self { Type::Forall(generics, _) => generics.len(), + Type::CheckedCast { to, .. } => to.generic_count(), Type::TypeVariable(type_variable) | Type::NamedGeneric(type_variable, _) => { match &*type_variable.borrow() { TypeBinding::Bound(binding) => binding.generic_count(), @@ -1351,6 +1395,7 @@ impl Type { pub(crate) fn kind(&self) -> Kind { match self { + Type::CheckedCast { to, .. } => to.kind(), Type::NamedGeneric(var, _) => var.kind(), Type::Constant(_, kind) => kind.clone(), Type::TypeVariable(var) => match &*var.borrow() { @@ -1386,32 +1431,33 @@ impl Type { if self_kind.unifies(&other_kind) { self_kind } else { - Kind::Numeric(Box::new(Type::Error)) + Kind::numeric(Type::Error) } } /// Returns the number of field elements required to represent the type once encoded. - pub fn field_count(&self) -> u32 { + pub fn field_count(&self, location: &Location) -> u32 { match self { Type::FieldElement | Type::Integer { .. } | Type::Bool => 1, Type::Array(size, typ) => { let length = size - .evaluate_to_u32() + .evaluate_to_u32(location.span) .expect("Cannot have variable sized arrays as a parameter to main"); let typ = typ.as_ref(); - length * typ.field_count() + length * typ.field_count(location) } Type::Struct(def, args) => { let struct_type = def.borrow(); let fields = struct_type.get_fields(args); - fields.iter().fold(0, |acc, (_, field_type)| acc + field_type.field_count()) + fields.iter().fold(0, |acc, (_, field_type)| acc + field_type.field_count(location)) } - Type::Alias(def, generics) => def.borrow().get_type(generics).field_count(), + Type::CheckedCast { to, .. } => to.field_count(location), + Type::Alias(def, generics) => def.borrow().get_type(generics).field_count(location), Type::Tuple(fields) => { - fields.iter().fold(0, |acc, field_typ| acc + field_typ.field_count()) + fields.iter().fold(0, |acc, field_typ| acc + field_typ.field_count(location)) } Type::String(size) => size - .evaluate_to_u32() + .evaluate_to_u32(location.span) .expect("Cannot have variable sized strings as a parameter to main"), Type::FmtString(_, _) | Type::Unit @@ -1582,6 +1628,7 @@ impl Type { match self { Type::TypeVariable(var) => Some((var.1.clone(), var.kind())), Type::NamedGeneric(var, _) => Some((var.1.clone(), var.kind())), + Type::CheckedCast { to, .. } => to.get_inner_type_variable(), _ => None, } } @@ -1696,6 +1743,10 @@ impl Type { } } + (CheckedCast { to, .. }, other) | (other, CheckedCast { to, .. }) => { + to.try_unify(other, bindings) + } + (NamedGeneric(binding, _), other) | (other, NamedGeneric(binding, _)) if !binding.borrow().is_unbound() => { @@ -1758,7 +1809,8 @@ impl Type { } (Constant(value, kind), other) | (other, Constant(value, kind)) => { - if let Some(other_value) = other.evaluate_to_field_element(kind) { + let dummy_span = Span::default(); + if let Ok(other_value) = other.evaluate_to_field_element(kind, dummy_span) { if *value == other_value && kind.unifies(&other.kind()) { Ok(()) } else { @@ -1926,41 +1978,106 @@ impl Type { /// If this type is a Type::Constant (used in array lengths), or is bound /// to a Type::Constant, return the constant as a u32. - pub fn evaluate_to_u32(&self) -> Option { - self.evaluate_to_field_element(&Kind::u32()) - .and_then(|field_element| field_element.try_to_u32()) + pub fn evaluate_to_u32(&self, span: Span) -> Result { + self.evaluate_to_field_element(&Kind::u32(), span).map(|field_element| { + field_element + .try_to_u32() + .expect("ICE: size should have already been checked by evaluate_to_field_element") + }) } // TODO(https://github.com/noir-lang/noir/issues/6260): remove // the unifies checks once all kinds checks are implemented? - pub(crate) fn evaluate_to_field_element(&self, kind: &Kind) -> Option { + pub(crate) fn evaluate_to_field_element( + &self, + kind: &Kind, + span: Span, + ) -> Result { + let run_simplifications = true; + self.evaluate_to_field_element_helper(kind, span, run_simplifications) + } + + /// evaluate_to_field_element with optional generic arithmetic simplifications + pub(crate) fn evaluate_to_field_element_helper( + &self, + kind: &Kind, + span: Span, + run_simplifications: bool, + ) -> Result { if let Some((binding, binding_kind)) = self.get_inner_type_variable() { if let TypeBinding::Bound(binding) = &*binding.borrow() { if kind.unifies(&binding_kind) { - return binding.evaluate_to_field_element(&binding_kind); + return binding.evaluate_to_field_element_helper( + &binding_kind, + span, + run_simplifications, + ); } } } - match self.canonicalize() { + let could_be_checked_cast = false; + match self.canonicalize_helper(could_be_checked_cast, run_simplifications) { Type::Constant(x, constant_kind) => { if kind.unifies(&constant_kind) { - kind.ensure_value_fits(x) + kind.ensure_value_fits(x, span) } else { - None + Err(TypeCheckError::TypeKindMismatch { + expected_kind: format!("{}", constant_kind), + expr_kind: format!("{}", kind), + expr_span: span, + }) } } Type::InfixExpr(lhs, op, rhs) => { let infix_kind = lhs.infix_kind(&rhs); if kind.unifies(&infix_kind) { - let lhs_value = lhs.evaluate_to_field_element(&infix_kind)?; - let rhs_value = rhs.evaluate_to_field_element(&infix_kind)?; - op.function(lhs_value, rhs_value, &infix_kind) + let lhs_value = lhs.evaluate_to_field_element_helper( + &infix_kind, + span, + run_simplifications, + )?; + let rhs_value = rhs.evaluate_to_field_element_helper( + &infix_kind, + span, + run_simplifications, + )?; + op.function(lhs_value, rhs_value, &infix_kind, span) } else { - None + Err(TypeCheckError::TypeKindMismatch { + expected_kind: format!("{}", kind), + expr_kind: format!("{}", infix_kind), + expr_span: span, + }) } } - _ => None, + Type::CheckedCast { from, to } => { + let to_value = to.evaluate_to_field_element(kind, span)?; + + // if both 'to' and 'from' evaluate to a constant, + // return None unless they match + let skip_simplifications = false; + if let Ok(from_value) = + from.evaluate_to_field_element_helper(kind, span, skip_simplifications) + { + if to_value == from_value { + Ok(to_value) + } else { + let to = *to.clone(); + let from = *from.clone(); + Err(TypeCheckError::TypeCanonicalizationMismatch { + to, + from, + to_value, + from_value, + span, + }) + } + } else { + Ok(to_value) + } + } + other => Err(TypeCheckError::NonConstantEvaluated { typ: other, span }), } } @@ -2182,6 +2299,11 @@ impl Type { let fields = fields.substitute_helper(type_bindings, substitute_bound_typevars); Type::FmtString(Box::new(size), Box::new(fields)) } + Type::CheckedCast { from, to } => { + let from = from.substitute_helper(type_bindings, substitute_bound_typevars); + let to = to.substitute_helper(type_bindings, substitute_bound_typevars); + Type::CheckedCast { from: Box::new(from), to: Box::new(to) } + } Type::NamedGeneric(binding, _) | Type::TypeVariable(binding) => { substitute_binding(binding) } @@ -2271,6 +2393,7 @@ impl Type { || args.named.iter().any(|arg| arg.typ.occurs(target_id)) } Type::Tuple(fields) => fields.iter().any(|field| field.occurs(target_id)), + Type::CheckedCast { from, to } => from.occurs(target_id) || to.occurs(target_id), Type::NamedGeneric(type_var, _) | Type::TypeVariable(type_var) => { match &*type_var.borrow() { TypeBinding::Bound(binding) => { @@ -2329,6 +2452,11 @@ impl Type { def.borrow().get_type(args).follow_bindings() } Tuple(args) => Tuple(vecmap(args, |arg| arg.follow_bindings())), + CheckedCast { from, to } => { + let from = Box::new(from.follow_bindings()); + let to = Box::new(to.follow_bindings()); + CheckedCast { from, to } + } TypeVariable(var) | NamedGeneric(var, _) => { if let TypeBinding::Bound(typ) = &*var.borrow() { return typ.follow_bindings(); @@ -2425,6 +2553,10 @@ impl Type { generic.typ.replace_named_generics_with_type_variables(); } } + Type::CheckedCast { from, to } => { + from.replace_named_generics_with_type_variables(); + to.replace_named_generics_with_type_variables(); + } Type::NamedGeneric(var, _) => { let type_binding = var.borrow(); if let TypeBinding::Bound(binding) = &*type_binding { @@ -2482,6 +2614,7 @@ impl Type { } } Type::Alias(alias, args) => alias.borrow().get_type(args).integral_maximum_size(), + Type::CheckedCast { to, .. } => to.integral_maximum_size(), Type::NamedGeneric(binding, _name) => match &*binding.borrow() { TypeBinding::Bound(typ) => typ.integral_maximum_size(), TypeBinding::Unbound(_, kind) => kind.integral_maximum_size(), @@ -2541,28 +2674,39 @@ fn convert_array_expression_to_slice( impl BinaryTypeOperator { /// Perform the actual rust numeric operation associated with this operator - pub fn function(self, a: FieldElement, b: FieldElement, kind: &Kind) -> Option { + pub fn function( + self, + a: FieldElement, + b: FieldElement, + kind: &Kind, + span: Span, + ) -> Result { match kind.follow_bindings().integral_maximum_size() { None => match self { - BinaryTypeOperator::Addition => Some(a + b), - BinaryTypeOperator::Subtraction => Some(a - b), - BinaryTypeOperator::Multiplication => Some(a * b), - BinaryTypeOperator::Division => (b != FieldElement::zero()).then(|| a / b), - BinaryTypeOperator::Modulo => None, + BinaryTypeOperator::Addition => Ok(a + b), + BinaryTypeOperator::Subtraction => Ok(a - b), + BinaryTypeOperator::Multiplication => Ok(a * b), + BinaryTypeOperator::Division => (b != FieldElement::zero()) + .then(|| a / b) + .ok_or(TypeCheckError::DivisionByZero { lhs: a, rhs: b, span }), + BinaryTypeOperator::Modulo => { + Err(TypeCheckError::ModuloOnFields { lhs: a, rhs: b, span }) + } }, Some(_maximum_size) => { let a = a.to_i128(); let b = b.to_i128(); + let err = TypeCheckError::FailingBinaryOp { op: self, lhs: a, rhs: b, span }; let result = match self { - BinaryTypeOperator::Addition => a.checked_add(b)?, - BinaryTypeOperator::Subtraction => a.checked_sub(b)?, - BinaryTypeOperator::Multiplication => a.checked_mul(b)?, - BinaryTypeOperator::Division => a.checked_div(b)?, - BinaryTypeOperator::Modulo => a.checked_rem(b)?, + BinaryTypeOperator::Addition => a.checked_add(b).ok_or(err)?, + BinaryTypeOperator::Subtraction => a.checked_sub(b).ok_or(err)?, + BinaryTypeOperator::Multiplication => a.checked_mul(b).ok_or(err)?, + BinaryTypeOperator::Division => a.checked_div(b).ok_or(err)?, + BinaryTypeOperator::Modulo => a.checked_rem(b).ok_or(err)?, }; - Some(result.into()) + Ok(result.into()) } } } @@ -2607,7 +2751,9 @@ impl From<&Type> for PrintableType { match value { Type::FieldElement => PrintableType::Field, Type::Array(size, typ) => { - let length = size.evaluate_to_u32().expect("Cannot print variable sized arrays"); + let dummy_span = Span::default(); + let length = + size.evaluate_to_u32(dummy_span).expect("Cannot print variable sized arrays"); let typ = typ.as_ref(); PrintableType::Array { length, typ: Box::new(typ.into()) } } @@ -2632,7 +2778,9 @@ impl From<&Type> for PrintableType { }, Type::Bool => PrintableType::Boolean, Type::String(size) => { - let size = size.evaluate_to_u32().expect("Cannot print variable sized strings"); + let dummy_span = Span::default(); + let size = + size.evaluate_to_u32(dummy_span).expect("Cannot print variable sized strings"); PrintableType::String { length: size } } Type::FmtString(_, _) => unreachable!("format strings cannot be printed"), @@ -2648,6 +2796,7 @@ impl From<&Type> for PrintableType { Type::Alias(alias, args) => alias.borrow().get_type(args).into(), Type::TraitAsType(..) => unreachable!(), Type::Tuple(types) => PrintableType::Tuple { types: vecmap(types, |typ| typ.into()) }, + Type::CheckedCast { to, .. } => to.as_ref().into(), Type::NamedGeneric(..) => unreachable!(), Type::Forall(..) => unreachable!(), Type::Function(arguments, return_type, env, unconstrained) => PrintableType::Function { @@ -2722,6 +2871,7 @@ impl std::fmt::Debug for Type { } Type::Unit => write!(f, "()"), Type::Error => write!(f, "error"), + Type::CheckedCast { to, .. } => write!(f, "{:?}", to), Type::NamedGeneric(binding, name) => match binding.kind() { Kind::Any | Kind::Normal | Kind::Integer | Kind::IntegerOrField => { write!(f, "{}{:?}", name, binding) @@ -2836,6 +2986,7 @@ impl std::hash::Hash for Type { vars.hash(state); typ.hash(state); } + Type::CheckedCast { to, .. } => to.hash(state), Type::Constant(value, _) => value.hash(state), Type::Quoted(typ) => typ.hash(state), Type::InfixExpr(lhs, op, rhs) => { @@ -2902,6 +3053,7 @@ impl PartialEq for Type { (Forall(lhs_vars, lhs_type), Forall(rhs_vars, rhs_type)) => { lhs_vars == rhs_vars && lhs_type == rhs_type } + (CheckedCast { to, .. }, other) | (other, CheckedCast { to, .. }) => **to == *other, (Constant(lhs, lhs_kind), Constant(rhs, rhs_kind)) => { lhs == rhs && lhs_kind == rhs_kind } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs index 81f638ebca47..8cdf6f5502c7 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs @@ -1,6 +1,7 @@ use std::collections::BTreeMap; use acvm::{AcirField, FieldElement}; +use noirc_errors::Span; use crate::{BinaryTypeOperator, Type, TypeBindings, UnificationError}; @@ -15,34 +16,81 @@ impl Type { /// - `canonicalize[((1 + N) + M) + 2] = (M + N) + 3` /// - `canonicalize[A + 2 * B + 3 - 2] = A + (B * 2) + 3 - 2` pub fn canonicalize(&self) -> Type { + match self.follow_bindings() { + Type::CheckedCast { from, to } => Type::CheckedCast { + from: Box::new(from.canonicalize_checked()), + to: Box::new(to.canonicalize_unchecked()), + }, + + other => { + let non_checked_cast = false; + let run_simplifications = true; + other.canonicalize_helper(non_checked_cast, run_simplifications) + } + } + } + + /// Only simplify constants and drop/skip any CheckedCast's + pub(crate) fn canonicalize_checked(&self) -> Type { + let found_checked_cast = true; + let skip_simplifications = false; + self.canonicalize_helper(found_checked_cast, skip_simplifications) + } + + /// Run all simplifications and drop/skip any CheckedCast's + fn canonicalize_unchecked(&self) -> Type { + let found_checked_cast = true; + let run_simplifications = true; + self.canonicalize_helper(found_checked_cast, run_simplifications) + } + + /// If found_checked_cast, then drop additional CheckedCast's + /// + /// If run_simplifications is false, then only: + /// - Attempt to evaluate each sub-expression to a constant + /// - Drop nested CheckedCast's + /// + /// Otherwise also attempt try_simplify_partial_constants, sort_commutative, + /// and other simplifications + pub(crate) fn canonicalize_helper( + &self, + found_checked_cast: bool, + run_simplifications: bool, + ) -> Type { match self.follow_bindings() { Type::InfixExpr(lhs, op, rhs) => { let kind = lhs.infix_kind(&rhs); + let dummy_span = Span::default(); // evaluate_to_field_element also calls canonicalize so if we just called // `self.evaluate_to_field_element(..)` we'd get infinite recursion. - if let (Some(lhs_u32), Some(rhs_u32)) = - (lhs.evaluate_to_field_element(&kind), rhs.evaluate_to_field_element(&kind)) - { - let kind = lhs.infix_kind(&rhs); - if let Some(result) = op.function(lhs_u32, rhs_u32, &kind) { + if let (Ok(lhs_value), Ok(rhs_value)) = ( + lhs.evaluate_to_field_element_helper(&kind, dummy_span, run_simplifications), + rhs.evaluate_to_field_element_helper(&kind, dummy_span, run_simplifications), + ) { + if let Ok(result) = op.function(lhs_value, rhs_value, &kind, dummy_span) { return Type::Constant(result, kind); } } - let lhs = lhs.canonicalize(); - let rhs = rhs.canonicalize(); + let lhs = lhs.canonicalize_helper(found_checked_cast, run_simplifications); + let rhs = rhs.canonicalize_helper(found_checked_cast, run_simplifications); + + if !run_simplifications { + return Type::InfixExpr(Box::new(lhs), op, Box::new(rhs)); + } + if let Some(result) = Self::try_simplify_non_constants_in_lhs(&lhs, op, &rhs) { - return result.canonicalize(); + return result.canonicalize_unchecked(); } if let Some(result) = Self::try_simplify_non_constants_in_rhs(&lhs, op, &rhs) { - return result.canonicalize(); + return result.canonicalize_unchecked(); } // Try to simplify partially constant expressions in the form `(N op1 C1) op2 C2` // where C1 and C2 are constants that can be combined (e.g. N + 5 - 3 = N + 2) if let Some(result) = Self::try_simplify_partial_constants(&lhs, op, &rhs) { - return result.canonicalize(); + return result.canonicalize_unchecked(); } if op.is_commutative() { @@ -51,6 +99,18 @@ impl Type { Type::InfixExpr(Box::new(lhs), op, Box::new(rhs)) } + Type::CheckedCast { from, to } => { + let inner_found_checked_cast = true; + let to = to.canonicalize_helper(inner_found_checked_cast, run_simplifications); + + if found_checked_cast { + return to; + } + + let from = from.canonicalize_checked(); + + Type::CheckedCast { from: Box::new(from), to: Box::new(to) } + } other => other, } } @@ -70,13 +130,16 @@ impl Type { // Push each non-constant term to `sorted` to sort them. Recur on InfixExprs with the same operator. while let Some(item) = queue.pop() { - match item.canonicalize() { - Type::InfixExpr(lhs, new_op, rhs) if new_op == op => { - queue.push(*lhs); - queue.push(*rhs); + match item.canonicalize_unchecked() { + Type::InfixExpr(lhs_inner, new_op, rhs_inner) if new_op == op => { + queue.push(*lhs_inner); + queue.push(*rhs_inner); } Type::Constant(new_constant, new_constant_kind) => { - if let Some(result) = op.function(constant, new_constant, &new_constant_kind) { + let dummy_span = Span::default(); + if let Ok(result) = + op.function(constant, new_constant, &new_constant_kind, dummy_span) + { constant = result; } else { let constant = Type::Constant(new_constant, new_constant_kind); @@ -126,20 +189,27 @@ impl Type { op: BinaryTypeOperator, rhs: &Type, ) -> Option { - let Type::InfixExpr(l_lhs, l_op, l_rhs) = lhs.follow_bindings() else { - return None; - }; + match lhs.follow_bindings() { + Type::CheckedCast { from, to } => { + // Apply operation directly to `from` while attempting simplification to `to`. + let from = Type::InfixExpr(from, op, Box::new(rhs.clone())); + let to = Self::try_simplify_non_constants_in_lhs(&to, op, rhs)?; + Some(Type::CheckedCast { from: Box::new(from), to: Box::new(to) }) + } + Type::InfixExpr(l_lhs, l_op, l_rhs) => { + // Note that this is exact, syntactic equality, not unification. + // `rhs` is expected to already be in canonical form. + if l_op.approx_inverse() != Some(op) + || l_op == BinaryTypeOperator::Division + || l_rhs.canonicalize_unchecked() != *rhs + { + return None; + } - // Note that this is exact, syntactic equality, not unification. - // `rhs` is expected to already be in canonical form. - if l_op.approx_inverse() != Some(op) - || l_op == BinaryTypeOperator::Division - || l_rhs.canonicalize() != *rhs - { - return None; + Some(*l_lhs) + } + _ => None, } - - Some(*l_lhs) } /// Try to simplify non-constant expressions in the form `N op1 (M op1 N)` @@ -156,23 +226,31 @@ impl Type { op: BinaryTypeOperator, rhs: &Type, ) -> Option { - let Type::InfixExpr(r_lhs, r_op, r_rhs) = rhs.follow_bindings() else { - return None; - }; + match rhs.follow_bindings() { + Type::CheckedCast { from, to } => { + // Apply operation directly to `from` while attempting simplification to `to`. + let from = Type::InfixExpr(Box::new(lhs.clone()), op, from); + let to = Self::try_simplify_non_constants_in_rhs(lhs, op, &to)?; + Some(Type::CheckedCast { from: Box::new(from), to: Box::new(to) }) + } + Type::InfixExpr(r_lhs, r_op, r_rhs) => { + // `N / (M * N)` should be simplified to `1 / M`, but we only handle + // simplifying to `M` in this function. + if op == BinaryTypeOperator::Division && r_op == BinaryTypeOperator::Multiplication + { + return None; + } - // `N / (M * N)` should be simplified to `1 / M`, but we only handle - // simplifying to `M` in this function. - if op == BinaryTypeOperator::Division && r_op == BinaryTypeOperator::Multiplication { - return None; - } + // Note that this is exact, syntactic equality, not unification. + // `lhs` is expected to already be in canonical form. + if r_op.inverse() != Some(op) || *lhs != r_rhs.canonicalize_unchecked() { + return None; + } - // Note that this is exact, syntactic equality, not unification. - // `lhs` is expected to already be in canonical form. - if r_op.inverse() != Some(op) || *lhs != r_rhs.canonicalize() { - return None; + Some(*r_lhs) + } + _ => None, } - - Some(*r_lhs) } /// Given: @@ -187,13 +265,15 @@ impl Type { rhs: &Type, ) -> Option<(Box, BinaryTypeOperator, FieldElement, FieldElement)> { let kind = lhs.infix_kind(rhs); - let rhs = rhs.evaluate_to_field_element(&kind)?; + let dummy_span = Span::default(); + let rhs = rhs.evaluate_to_field_element(&kind, dummy_span).ok()?; let Type::InfixExpr(l_type, l_op, l_rhs) = lhs.follow_bindings() else { return None; }; - let l_rhs = l_rhs.evaluate_to_field_element(&kind)?; + let dummy_span = Span::default(); + let l_rhs = l_rhs.evaluate_to_field_element(&kind, dummy_span).ok()?; Some((l_type, l_op, l_rhs, rhs)) } @@ -218,7 +298,9 @@ impl Type { if l_op == Subtraction { op = op.inverse()?; } - let result = op.function(l_const, r_const, &lhs.infix_kind(rhs))?; + let dummy_span = Span::default(); + let result = + op.function(l_const, r_const, &lhs.infix_kind(rhs), dummy_span).ok()?; let constant = Type::Constant(result, lhs.infix_kind(rhs)); Some(Type::InfixExpr(l_type, l_op, Box::new(constant))) } @@ -231,7 +313,9 @@ impl Type { if op == Division && (r_const == FieldElement::zero() || !divides_evenly) { None } else { - let result = op.function(l_const, r_const, &lhs.infix_kind(rhs))?; + let dummy_span = Span::default(); + let result = + op.function(l_const, r_const, &lhs.infix_kind(rhs), dummy_span).ok()?; let constant = Box::new(Type::Constant(result, lhs.infix_kind(rhs))); Some(Type::InfixExpr(l_type, l_op, constant)) } @@ -250,7 +334,8 @@ impl Type { if let Type::InfixExpr(lhs_a, op_a, rhs_a) = self { if let Some(inverse) = op_a.approx_inverse() { let kind = lhs_a.infix_kind(rhs_a); - if let Some(rhs_a_value) = rhs_a.evaluate_to_field_element(&kind) { + let dummy_span = Span::default(); + if let Ok(rhs_a_value) = rhs_a.evaluate_to_field_element(&kind, dummy_span) { let rhs_a = Box::new(Type::Constant(rhs_a_value, kind)); let new_other = Type::InfixExpr(Box::new(other.clone()), inverse, rhs_a); @@ -266,7 +351,8 @@ impl Type { if let Type::InfixExpr(lhs_b, op_b, rhs_b) = other { if let Some(inverse) = op_b.approx_inverse() { let kind = lhs_b.infix_kind(rhs_b); - if let Some(rhs_b_value) = rhs_b.evaluate_to_field_element(&kind) { + let dummy_span = Span::default(); + if let Ok(rhs_b_value) = rhs_b.evaluate_to_field_element(&kind, dummy_span) { let rhs_b = Box::new(Type::Constant(rhs_b_value, kind)); let new_self = Type::InfixExpr(Box::new(self.clone()), inverse, rhs_b); @@ -282,3 +368,301 @@ impl Type { Err(UnificationError) } } + +#[cfg(test)] +mod tests { + use acvm::{AcirField, FieldElement}; + + use crate::hir_def::types::{BinaryTypeOperator, Kind, Type, TypeVariable, TypeVariableId}; + + #[test] + fn solves_n_minus_one_plus_one_through_checked_casts() { + // We want to test that the inclusion of a `CheckedCast` won't prevent us from canonicalizing + // the expression `(N - 1) + 1` to `N` if there exists a `CheckedCast` on the `N - 1` term. + + let n = Type::NamedGeneric( + TypeVariable::unbound(TypeVariableId(0), Kind::u32()), + std::rc::Rc::new("N".to_owned()), + ); + let n_minus_one = Type::InfixExpr( + Box::new(n.clone()), + BinaryTypeOperator::Subtraction, + Box::new(Type::Constant(FieldElement::one(), Kind::u32())), + ); + let checked_cast_n_minus_one = + Type::CheckedCast { from: Box::new(n_minus_one.clone()), to: Box::new(n_minus_one) }; + + let n_minus_one_plus_one = Type::InfixExpr( + Box::new(checked_cast_n_minus_one.clone()), + BinaryTypeOperator::Addition, + Box::new(Type::Constant(FieldElement::one(), Kind::u32())), + ); + + let canonicalized_typ = n_minus_one_plus_one.canonicalize(); + + assert_eq!(n, canonicalized_typ); + + // We also want to check that if the `CheckedCast` is on the RHS then we'll still be able to canonicalize + // the expression `1 + (N - 1)` to `N`. + + let one_plus_n_minus_one = Type::InfixExpr( + Box::new(Type::Constant(FieldElement::one(), Kind::u32())), + BinaryTypeOperator::Addition, + Box::new(checked_cast_n_minus_one), + ); + + let canonicalized_typ = one_plus_n_minus_one.canonicalize(); + + assert_eq!(n, canonicalized_typ); + } + + #[test] + fn instantiate_after_canonicalize_smoke_test() { + let field_element_kind = Kind::numeric(Type::FieldElement); + let x_var = TypeVariable::unbound(TypeVariableId(0), field_element_kind.clone()); + let x_type = Type::TypeVariable(x_var.clone()); + let one = Type::Constant(FieldElement::one(), field_element_kind.clone()); + + let lhs = Type::InfixExpr( + Box::new(x_type.clone()), + BinaryTypeOperator::Addition, + Box::new(one.clone()), + ); + let rhs = + Type::InfixExpr(Box::new(one), BinaryTypeOperator::Addition, Box::new(x_type.clone())); + + // canonicalize + let lhs = lhs.canonicalize(); + let rhs = rhs.canonicalize(); + + // bind vars + let two = Type::Constant(FieldElement::from(2u128), field_element_kind.clone()); + x_var.bind(two); + + // canonicalize (expect constant) + let lhs = lhs.canonicalize(); + let rhs = rhs.canonicalize(); + + // ensure we've canonicalized to constants + assert!(matches!(lhs, Type::Constant(..))); + assert!(matches!(rhs, Type::Constant(..))); + + // ensure result kinds are the same as the original kind + assert_eq!(lhs.kind(), field_element_kind); + assert_eq!(rhs.kind(), field_element_kind); + + // ensure results are the same + assert_eq!(lhs, rhs); + } +} + +#[cfg(test)] +mod proptests { + + use acvm::{AcirField, FieldElement}; + use proptest::arbitrary::any; + use proptest::collection; + use proptest::prelude::*; + use proptest::result::maybe_ok; + use proptest::strategy; + + use crate::ast::{IntegerBitSize, Signedness}; + use crate::hir_def::types::{BinaryTypeOperator, Kind, Type, TypeVariable, TypeVariableId}; + + prop_compose! { + // maximum_size must be non-zero + fn arbitrary_u128_field_element(maximum_size: u128) + (u128_value in any::()) + -> FieldElement + { + assert!(maximum_size != 0); + FieldElement::from(u128_value % maximum_size) + } + } + + // NOTE: this is roughly the same method from acvm/tests/solver + prop_compose! { + // Use both `u128` and hex proptest strategies + fn arbitrary_field_element() + (u128_or_hex in maybe_ok(any::(), "[0-9a-f]{64}")) + -> FieldElement + { + match u128_or_hex { + Ok(number) => FieldElement::from(number), + Err(hex) => FieldElement::from_hex(&hex).expect("should accept any 32 byte hex string"), + } + } + } + + // Generate (arbitrary_unsigned_type, generator for that type) + fn arbitrary_unsigned_type_with_generator() -> BoxedStrategy<(Type, BoxedStrategy)> + { + prop_oneof![ + strategy::Just((Type::FieldElement, arbitrary_field_element().boxed())), + any::().prop_map(|bit_size| { + let typ = Type::Integer(Signedness::Unsigned, bit_size); + let maximum_size = typ.integral_maximum_size().unwrap().to_u128(); + (typ, arbitrary_u128_field_element(maximum_size).boxed()) + }), + strategy::Just((Type::Bool, arbitrary_u128_field_element(1).boxed())), + ] + .boxed() + } + + prop_compose! { + fn arbitrary_variable(typ: Type, num_variables: usize) + (variable_index in any::()) + -> Type { + assert!(num_variables != 0); + let id = TypeVariableId(variable_index % num_variables); + let kind = Kind::numeric(typ.clone()); + let var = TypeVariable::unbound(id, kind); + Type::TypeVariable(var) + } + } + + fn first_n_variables(typ: Type, num_variables: usize) -> impl Iterator { + (0..num_variables).map(move |id| { + let id = TypeVariableId(id); + let kind = Kind::numeric(typ.clone()); + TypeVariable::unbound(id, kind) + }) + } + + fn arbitrary_infix_expr( + typ: Type, + arbitrary_value: BoxedStrategy, + num_variables: usize, + ) -> impl Strategy { + let leaf = prop_oneof![ + arbitrary_variable(typ.clone(), num_variables), + arbitrary_value + .prop_map(move |value| Type::Constant(value, Kind::numeric(typ.clone()))), + ]; + + leaf.prop_recursive( + 8, // 8 levels deep maximum + 256, // Shoot for maximum size of 256 nodes + 10, // We put up to 10 items per collection + |inner| { + (inner.clone(), any::(), inner) + .prop_map(|(lhs, op, rhs)| Type::InfixExpr(Box::new(lhs), op, Box::new(rhs))) + }, + ) + } + + prop_compose! { + // (infix_expr, type, generator) + fn arbitrary_infix_expr_type_gen(num_variables: usize) + (type_and_gen in arbitrary_unsigned_type_with_generator()) + (infix_expr in arbitrary_infix_expr(type_and_gen.clone().0, type_and_gen.clone().1, num_variables), type_and_gen in Just(type_and_gen)) + -> (Type, Type, BoxedStrategy) { + let (typ, value_generator) = type_and_gen; + (infix_expr, typ, value_generator) + } + } + + prop_compose! { + // (Type::InfixExpr, numeric kind, bindings) + fn arbitrary_infix_expr_with_bindings_sized(num_variables: usize) + (infix_type_gen in arbitrary_infix_expr_type_gen(num_variables)) + (values in collection::vec(infix_type_gen.clone().2, num_variables), infix_type_gen in Just(infix_type_gen)) + -> (Type, Type, Vec<(TypeVariable, Type)>) { + let (infix_expr, typ, _value_generator) = infix_type_gen; + let bindings: Vec<_> = first_n_variables(typ.clone(), num_variables) + .zip(values.iter().map(|value| { + Type::Constant(*value, Kind::numeric(typ.clone())) + })) + .collect(); + (infix_expr, typ, bindings) + } + } + + prop_compose! { + // the lint misfires on 'num_variables' + #[allow(unused_variables)] + fn arbitrary_infix_expr_with_bindings(max_num_variables: usize) + (num_variables in any::().prop_map(move |num_variables| (num_variables % max_num_variables).clamp(1, max_num_variables))) + (infix_type_bindings in arbitrary_infix_expr_with_bindings_sized(num_variables), num_variables in Just(num_variables)) + -> (Type, Type, Vec<(TypeVariable, Type)>) { + infix_type_bindings + } + } + + proptest! { + #[test] + // Expect cases that don't resolve to constants, e.g. see + // `arithmetic_generics_checked_cast_indirect_zeros` + #[should_panic(expected = "matches!(infix, Type :: Constant(..))")] + fn instantiate_before_or_after_canonicalize(infix_type_bindings in arbitrary_infix_expr_with_bindings(10)) { + let (infix, typ, bindings) = infix_type_bindings; + + // canonicalize + let infix_canonicalized = infix.canonicalize(); + + // bind vars + for (var, binding) in bindings { + var.bind(binding); + } + + // attempt to canonicalize to a constant + let infix = infix.canonicalize(); + let infix_canonicalized = infix_canonicalized.canonicalize(); + + // ensure we've canonicalized to constants + prop_assert!(matches!(infix, Type::Constant(..))); + prop_assert!(matches!(infix_canonicalized, Type::Constant(..))); + + // ensure result kinds are the same as the original kind + let kind = Kind::numeric(typ); + prop_assert_eq!(infix.kind(), kind.clone()); + prop_assert_eq!(infix_canonicalized.kind(), kind); + + // ensure results are the same + prop_assert_eq!(infix, infix_canonicalized); + } + + #[test] + fn instantiate_before_or_after_canonicalize_checked_cast(infix_type_bindings in arbitrary_infix_expr_with_bindings(10)) { + let (infix, typ, bindings) = infix_type_bindings; + + // wrap in CheckedCast + let infix = Type::CheckedCast { + from: Box::new(infix.clone()), + to: Box::new(infix) + }; + + // canonicalize + let infix_canonicalized = infix.canonicalize(); + + // bind vars + for (var, binding) in bindings { + var.bind(binding); + } + + // attempt to canonicalize to a constant + let infix = infix.canonicalize(); + let infix_canonicalized = infix_canonicalized.canonicalize(); + + // ensure result kinds are the same as the original kind + let kind = Kind::numeric(typ); + prop_assert_eq!(infix.kind(), kind.clone()); + prop_assert_eq!(infix_canonicalized.kind(), kind.clone()); + + // ensure the results are still wrapped in CheckedCast's + match (&infix, &infix_canonicalized) { + (Type::CheckedCast { from, to }, Type::CheckedCast { from: from_canonicalized, to: to_canonicalized }) => { + // ensure from's are the same + prop_assert_eq!(from, from_canonicalized); + + // ensure to's have the same kinds + prop_assert_eq!(to.kind(), kind.clone()); + prop_assert_eq!(to_canonicalized.kind(), kind); + } + _ => { + prop_assert!(false, "expected CheckedCast"); + } + } + } + } +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/lexer/lexer.rs b/noir/noir-repo/compiler/noirc_frontend/src/lexer/lexer.rs index 91ae544ddf09..68dc142ff10b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/lexer/lexer.rs @@ -1,4 +1,4 @@ -use crate::token::{Attribute, DocStyle}; +use crate::token::DocStyle; use super::{ errors::LexerErrorKind, @@ -139,7 +139,7 @@ impl<'a> Lexer<'a> { Some('f') => self.eat_format_string_or_alpha_numeric(), Some('r') => self.eat_raw_string_or_alpha_numeric(), Some('q') => self.eat_quote_or_alpha_numeric(), - Some('#') => self.eat_attribute(), + Some('#') => self.eat_attribute_start(), Some(ch) if ch.is_ascii_alphanumeric() || ch == '_' => self.eat_alpha_numeric(ch), Some(ch) => { // We don't report invalid tokens in the source as errors until parsing to @@ -282,7 +282,7 @@ impl<'a> Lexer<'a> { } } - fn eat_attribute(&mut self) -> SpannedTokenResult { + fn eat_attribute_start(&mut self) -> SpannedTokenResult { let start = self.position; let is_inner = if self.peek_char_is('!') { @@ -306,40 +306,9 @@ impl<'a> Lexer<'a> { self.next_char(); } - let contents_start = self.position + 1; - - let word = self.eat_while(None, |ch| ch != ']'); - - let contents_end = self.position; - - if !self.peek_char_is(']') { - return Err(LexerErrorKind::UnexpectedCharacter { - span: Span::single_char(self.position), - expected: "]".to_owned(), - found: self.next_char(), - }); - } - self.next_char(); - let end = self.position; - let span = Span::inclusive(start, end); - let contents_span = Span::inclusive(contents_start, contents_end); - - let attribute = Attribute::lookup_attribute(&word, span, contents_span, is_tag)?; - if is_inner { - match attribute { - Attribute::Function(attribute) => Err(LexerErrorKind::InvalidInnerAttribute { - span: Span::from(start..end), - found: attribute.to_string(), - }), - Attribute::Secondary(attribute) => { - Ok(Token::InnerAttribute(attribute).into_span(start, end)) - } - } - } else { - Ok(Token::Attribute(attribute).into_span(start, end)) - } + Ok(Token::AttributeStart { is_inner, is_tag }.into_span(start, end)) } //XXX(low): Can increase performance if we use iterator semantic and utilize some of the methods on String. See below @@ -371,11 +340,11 @@ impl<'a> Lexer<'a> { // Check if word an int type // if no error occurred, then it is either a valid integer type or it is not an int type - let parsed_token = IntType::lookup_int_type(&word)?; + let parsed_token = IntType::lookup_int_type(&word); // Check if it is an int type - if let Some(int_type_token) = parsed_token { - return Ok(int_type_token.into_span(start, end)); + if let Some(int_type) = parsed_token { + return Ok(Token::IntType(int_type).into_span(start, end)); } // Else it is just an identifier @@ -725,7 +694,6 @@ mod tests { use iter_extended::vecmap; use super::*; - use crate::token::{CustomAttribute, FunctionAttribute, SecondaryAttribute, TestScope}; #[test] fn test_single_multi_char() { @@ -785,173 +753,39 @@ mod tests { } #[test] - fn deprecated_attribute() { - let input = r#"#[deprecated]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Secondary(SecondaryAttribute::Deprecated(None))) - ); - } - - #[test] - fn test_attribute_with_common_punctuation() { - let input = - r#"#[test(should_fail_with = "stmt. q? exclaim! & symbols, 1% shouldn't fail")]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next_token().unwrap().token().clone(); - assert_eq!( - token, - Token::Attribute(Attribute::Function(FunctionAttribute::Test( - TestScope::ShouldFailWith { - reason: "stmt. q? exclaim! & symbols, 1% shouldn't fail".to_owned().into() - } - ))) - ); - } - - #[test] - fn deprecated_attribute_with_note() { - let input = r#"#[deprecated("hello")]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Secondary(crate::token::SecondaryAttribute::Deprecated( - "hello".to_string().into() - ))) - ); - } - - #[test] - fn test_custom_gate_syntax() { - let input = "#[foreign(sha256)]#[foreign(blake2s)]#[builtin(sum)]"; - - let expected = vec![ - Token::Attribute(Attribute::Function(FunctionAttribute::Foreign("sha256".to_string()))), - Token::Attribute(Attribute::Function(FunctionAttribute::Foreign( - "blake2s".to_string(), - ))), - Token::Attribute(Attribute::Function(FunctionAttribute::Builtin("sum".to_string()))), - ]; - - let mut lexer = Lexer::new(input); - for token in expected.into_iter() { - let got = lexer.next_token().unwrap(); - assert_eq!(got, token); - } - } - - #[test] - fn tag_attribute() { - let input = r#"#['custom(hello)]"#; + fn test_attribute_start() { + let input = r#"#[something]"#; let mut lexer = Lexer::new(input); let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Secondary(SecondaryAttribute::Tag(CustomAttribute { - contents: "custom(hello)".to_string(), - span: Span::from(0..17), - contents_span: Span::from(3..16) - }))) - ); + assert_eq!(token.token(), &Token::AttributeStart { is_inner: false, is_tag: false }); } #[test] - fn test_attribute() { - let input = r#"#[test]"#; + fn test_attribute_start_with_tag() { + let input = r#"#['something]"#; let mut lexer = Lexer::new(input); let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Function(FunctionAttribute::Test(TestScope::None))) - ); + assert_eq!(token.token(), &Token::AttributeStart { is_inner: false, is_tag: true }); } #[test] - fn fold_attribute() { - let input = r#"#[fold]"#; - - let mut lexer = Lexer::new(input); - let token = lexer.next_token().unwrap(); - - assert_eq!(token.token(), &Token::Attribute(Attribute::Function(FunctionAttribute::Fold))); - } - - #[test] - fn contract_library_method_attribute() { - let input = r#"#[contract_library_method]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Secondary(SecondaryAttribute::ContractLibraryMethod)) - ); - } - - #[test] - fn test_attribute_with_valid_scope() { - let input = r#"#[test(should_fail)]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Function(FunctionAttribute::Test( - TestScope::ShouldFailWith { reason: None } - ))) - ); - } - - #[test] - fn test_attribute_with_valid_scope_should_fail_with() { - let input = r#"#[test(should_fail_with = "hello")]"#; + fn test_inner_attribute_start() { + let input = r#"#![something]"#; let mut lexer = Lexer::new(input); let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::Attribute(Attribute::Function(FunctionAttribute::Test( - TestScope::ShouldFailWith { reason: Some("hello".to_owned()) } - ))) - ); + assert_eq!(token.token(), &Token::AttributeStart { is_inner: true, is_tag: false }); } #[test] - fn test_attribute_with_invalid_scope() { - let input = r#"#[test(invalid_scope)]"#; - let mut lexer = Lexer::new(input); - - let token = lexer.next().unwrap(); - let err = match token { - Ok(_) => panic!("test has an invalid scope, so expected an error"), - Err(err) => err, - }; - - assert!(matches!(err, LexerErrorKind::MalformedTestAttribute { .. })); - } - - #[test] - fn test_inner_attribute() { - let input = r#"#![something]"#; + fn test_inner_attribute_start_with_tag() { + let input = r#"#!['something]"#; let mut lexer = Lexer::new(input); let token = lexer.next_token().unwrap(); - assert_eq!( - token.token(), - &Token::InnerAttribute(SecondaryAttribute::Meta(CustomAttribute { - contents: "something".to_string(), - span: Span::from(0..13), - contents_span: Span::from(3..12), - })) - ); + assert_eq!(token.token(), &Token::AttributeStart { is_inner: true, is_tag: true }); } #[test] diff --git a/noir/noir-repo/compiler/noirc_frontend/src/lexer/token.rs b/noir/noir-repo/compiler/noirc_frontend/src/lexer/token.rs index 11001d277684..dbb28cf78c0d 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/lexer/token.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/lexer/token.rs @@ -1,9 +1,9 @@ use acvm::FieldElement; use noirc_errors::{Position, Span, Spanned}; -use std::fmt; +use std::fmt::{self, Display}; use crate::{ - lexer::errors::LexerErrorKind, + ast::{Expression, Path}, node_interner::{ ExprId, InternedExpressionKind, InternedPattern, InternedStatementKind, InternedUnresolvedTypeData, QuotedTypeId, @@ -28,8 +28,10 @@ pub enum BorrowedToken<'input> { FmtStr(&'input str), Keyword(Keyword), IntType(IntType), - Attribute(Attribute), - InnerAttribute(SecondaryAttribute), + AttributeStart { + is_inner: bool, + is_tag: bool, + }, LineComment(&'input str, Option), BlockComment(&'input str, Option), Quote(&'input Tokens), @@ -137,8 +139,10 @@ pub enum Token { FmtStr(String), Keyword(Keyword), IntType(IntType), - Attribute(Attribute), - InnerAttribute(SecondaryAttribute), + AttributeStart { + is_inner: bool, + is_tag: bool, + }, LineComment(String, Option), BlockComment(String, Option), // A `quote { ... }` along with the tokens in its token stream. @@ -254,8 +258,9 @@ pub fn token_to_borrowed_token(token: &Token) -> BorrowedToken<'_> { Token::FmtStr(ref b) => BorrowedToken::FmtStr(b), Token::RawStr(ref b, hashes) => BorrowedToken::RawStr(b, *hashes), Token::Keyword(k) => BorrowedToken::Keyword(*k), - Token::Attribute(ref a) => BorrowedToken::Attribute(a.clone()), - Token::InnerAttribute(ref a) => BorrowedToken::InnerAttribute(a.clone()), + Token::AttributeStart { is_inner, is_tag } => { + BorrowedToken::AttributeStart { is_inner: *is_inner, is_tag: *is_tag } + } Token::LineComment(ref s, _style) => BorrowedToken::LineComment(s, *_style), Token::BlockComment(ref s, _style) => BorrowedToken::BlockComment(s, *_style), Token::Quote(stream) => BorrowedToken::Quote(stream), @@ -376,8 +381,17 @@ impl fmt::Display for Token { write!(f, "r{h}{b:?}{h}") } Token::Keyword(k) => write!(f, "{k}"), - Token::Attribute(ref a) => write!(f, "{a}"), - Token::InnerAttribute(ref a) => write!(f, "#![{}]", a.contents()), + Token::AttributeStart { is_inner, is_tag } => { + write!(f, "#")?; + if is_inner { + write!(f, "!")?; + } + write!(f, "[")?; + if is_tag { + write!(f, "'")?; + } + Ok(()) + } Token::LineComment(ref s, style) => match style { Some(DocStyle::Inner) => write!(f, "//!{s}"), Some(DocStyle::Outer) => write!(f, "///{s}"), @@ -503,8 +517,6 @@ impl Token { | Token::RawStr(..) | Token::FmtStr(_) => TokenKind::Literal, Token::Keyword(_) => TokenKind::Keyword, - Token::Attribute(_) => TokenKind::Attribute, - Token::InnerAttribute(_) => TokenKind::InnerAttribute, Token::UnquoteMarker(_) => TokenKind::UnquoteMarker, Token::Quote(_) => TokenKind::Quote, Token::QuotedType(_) => TokenKind::QuotedType, @@ -585,7 +597,7 @@ impl IntType { // XXX: Result // Is not the best API. We could split this into two functions. One that checks if the // word is a integer, which only returns an Option - pub(crate) fn lookup_int_type(word: &str) -> Result, LexerErrorKind> { + pub fn lookup_int_type(word: &str) -> Option { // Check if the first string is a 'u' or 'i' let is_signed = if word.starts_with('i') { @@ -593,20 +605,20 @@ impl IntType { } else if word.starts_with('u') { false } else { - return Ok(None); + return None; }; // Word start with 'u' or 'i'. Check if the latter is an integer let str_as_u32 = match word[1..].parse::() { Ok(str_as_u32) => str_as_u32, - Err(_) => return Ok(None), + Err(_) => return None, }; if is_signed { - Ok(Some(Token::IntType(IntType::Signed(str_as_u32)))) + Some(IntType::Signed(str_as_u32)) } else { - Ok(Some(Token::IntType(IntType::Unsigned(str_as_u32)))) + Some(IntType::Unsigned(str_as_u32)) } } } @@ -622,25 +634,6 @@ pub enum TestScope { None, } -impl TestScope { - fn lookup_str(string: &str) -> Option { - match string.trim() { - "should_fail" => Some(TestScope::ShouldFailWith { reason: None }), - s if s.starts_with("should_fail_with") => { - let parts: Vec<&str> = s.splitn(2, '=').collect(); - if parts.len() == 2 { - let reason = parts[1].trim(); - let reason = reason.trim_matches('"'); - Some(TestScope::ShouldFailWith { reason: Some(reason.to_string()) }) - } else { - None - } - } - _ => None, - } - } -} - impl fmt::Display for TestScope { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { @@ -653,13 +646,13 @@ impl fmt::Display for TestScope { } } -#[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] +#[derive(PartialEq, Eq, Debug, Clone)] // Attributes are special language markers in the target language // An example of one is `#[SHA256]` . Currently only Foreign attributes are supported // Calls to functions which have the foreign attribute are executed in the host language pub struct Attributes { // Each function can have a single Primary Attribute - pub function: Option, + pub function: Option<(FunctionAttribute, usize /* index in list */)>, // Each function can have many Secondary Attributes pub secondary: Vec, } @@ -669,6 +662,15 @@ impl Attributes { Self { function: None, secondary: Vec::new() } } + pub fn function(&self) -> Option<&FunctionAttribute> { + self.function.as_ref().map(|(attr, _)| attr) + } + + pub fn set_function(&mut self, function: FunctionAttribute) { + // Assume the index in the list doesn't matter anymore at this point + self.function = Some((function, 0)); + } + /// Returns true if one of the secondary attributes is `contract_library_method` /// /// This is useful for finding out if we should compile a contract method @@ -680,7 +682,7 @@ impl Attributes { } pub fn is_test_function(&self) -> bool { - matches!(self.function, Some(FunctionAttribute::Test(_))) + matches!(self.function(), Some(FunctionAttribute::Test(_))) } /// True if these attributes mean the given function is an entry point function if it was @@ -708,11 +710,11 @@ impl Attributes { } pub fn is_foldable(&self) -> bool { - self.function.as_ref().map_or(false, |func_attribute| func_attribute.is_foldable()) + self.function().map_or(false, |func_attribute| func_attribute.is_foldable()) } pub fn is_no_predicates(&self) -> bool { - self.function.as_ref().map_or(false, |func_attribute| func_attribute.is_no_predicates()) + self.function().map_or(false, |func_attribute| func_attribute.is_no_predicates()) } pub fn has_varargs(&self) -> bool { @@ -727,7 +729,7 @@ impl Attributes { /// An Attribute can be either a Primary Attribute or a Secondary Attribute /// A Primary Attribute can alter the function type, thus there can only be one /// A secondary attribute has no effect and is either consumed by a library or used as a notice for the developer -#[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum Attribute { Function(FunctionAttribute), Secondary(SecondaryAttribute), @@ -742,115 +744,6 @@ impl fmt::Display for Attribute { } } -impl Attribute { - /// If the string is a fixed attribute return that, else - /// return the custom attribute - pub(crate) fn lookup_attribute( - word: &str, - span: Span, - contents_span: Span, - is_tag: bool, - ) -> Result { - // See if we can parse the word into "name ( contents )". - // We first split into "first_segment ( rest". - let word_segments = if let Some((first_segment, rest)) = word.trim().split_once('(') { - // Now we try to remove the final ")" (it must be at the end, if it exists) - if let Some(middle) = rest.strip_suffix(')') { - vec![first_segment.trim(), middle.trim()] - } else { - vec![word] - } - } else { - vec![word] - }; - - let validate = |slice: &str| { - let is_valid = slice - .chars() - .all(|ch| { - ch.is_ascii_alphabetic() - || ch.is_numeric() - || ch.is_ascii_punctuation() - || ch == ' ' - }) - .then_some(()); - - is_valid.ok_or(LexerErrorKind::MalformedFuncAttribute { span, found: word.to_owned() }) - }; - - if is_tag { - return Ok(Attribute::Secondary(SecondaryAttribute::Tag(CustomAttribute { - contents: word.to_owned(), - span, - contents_span, - }))); - } - - let attribute = match &word_segments[..] { - // Primary Attributes - ["foreign", name] => { - validate(name)?; - Attribute::Function(FunctionAttribute::Foreign(name.to_string())) - } - ["builtin", name] => { - validate(name)?; - Attribute::Function(FunctionAttribute::Builtin(name.to_string())) - } - ["oracle", name] => { - validate(name)?; - Attribute::Function(FunctionAttribute::Oracle(name.to_string())) - } - ["test"] => Attribute::Function(FunctionAttribute::Test(TestScope::None)), - ["fold"] => Attribute::Function(FunctionAttribute::Fold), - ["no_predicates"] => Attribute::Function(FunctionAttribute::NoPredicates), - ["inline_always"] => Attribute::Function(FunctionAttribute::InlineAlways), - ["test", name] => { - validate(name)?; - match TestScope::lookup_str(name) { - Some(scope) => Attribute::Function(FunctionAttribute::Test(scope)), - None => return Err(LexerErrorKind::MalformedTestAttribute { span }), - } - } - ["field", name] => { - validate(name)?; - Attribute::Secondary(SecondaryAttribute::Field(name.to_string())) - } - // Secondary attributes - ["deprecated"] => Attribute::Secondary(SecondaryAttribute::Deprecated(None)), - ["contract_library_method"] => { - Attribute::Secondary(SecondaryAttribute::ContractLibraryMethod) - } - ["abi", tag] => Attribute::Secondary(SecondaryAttribute::Abi(tag.to_string())), - ["export"] => Attribute::Secondary(SecondaryAttribute::Export), - ["deprecated", name] => { - if !name.starts_with('"') && !name.ends_with('"') { - return Err(LexerErrorKind::MalformedFuncAttribute { - span, - found: word.to_owned(), - }); - } - - Attribute::Secondary(SecondaryAttribute::Deprecated( - name.trim_matches('"').to_string().into(), - )) - } - ["varargs"] => Attribute::Secondary(SecondaryAttribute::Varargs), - ["use_callers_scope"] => Attribute::Secondary(SecondaryAttribute::UseCallersScope), - ["allow", tag] => Attribute::Secondary(SecondaryAttribute::Allow(tag.to_string())), - tokens => { - tokens.iter().try_for_each(|token| validate(token))?; - Attribute::Secondary(SecondaryAttribute::Meta(CustomAttribute { - contents: word.to_owned(), - span, - contents_span, - })) - } - }; - - Ok(attribute) - } -} - /// Primary Attributes are those which a function can only have one of. /// They change the FunctionKind and thus have direct impact on the IR output #[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] @@ -946,7 +839,7 @@ impl fmt::Display for FunctionAttribute { /// Secondary attributes are those which a function can have many of. /// They are not able to change the `FunctionKind` and thus do not have direct impact on the IR output /// They are often consumed by libraries or used as notices for the developer -#[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum SecondaryAttribute { Deprecated(Option), // This is an attribute to specify that a function @@ -960,7 +853,7 @@ pub enum SecondaryAttribute { Tag(CustomAttribute), /// An attribute expected to run a comptime function of the same name: #[foo] - Meta(CustomAttribute), + Meta(MetaAttribute), Abi(String), @@ -977,14 +870,6 @@ pub enum SecondaryAttribute { } impl SecondaryAttribute { - pub(crate) fn as_custom(&self) -> Option<&CustomAttribute> { - if let Self::Tag(attribute) = self { - Some(attribute) - } else { - None - } - } - pub(crate) fn name(&self) -> Option { match self { SecondaryAttribute::Deprecated(_) => Some("deprecated".to_string()), @@ -994,7 +879,7 @@ impl SecondaryAttribute { SecondaryAttribute::Export => Some("export".to_string()), SecondaryAttribute::Field(_) => Some("field".to_string()), SecondaryAttribute::Tag(custom) => custom.name(), - SecondaryAttribute::Meta(custom) => custom.name(), + SecondaryAttribute::Meta(meta) => Some(meta.name.last_name().to_string()), SecondaryAttribute::Abi(_) => Some("abi".to_string()), SecondaryAttribute::Varargs => Some("varargs".to_string()), SecondaryAttribute::UseCallersScope => Some("use_callers_scope".to_string()), @@ -1020,7 +905,7 @@ impl SecondaryAttribute { format!("deprecated({note:?})") } SecondaryAttribute::Tag(ref attribute) => format!("'{}", attribute.contents), - SecondaryAttribute::Meta(ref attribute) => attribute.contents.to_string(), + SecondaryAttribute::Meta(ref meta) => meta.to_string(), SecondaryAttribute::ContractLibraryMethod => "contract_library_method".to_string(), SecondaryAttribute::Export => "export".to_string(), SecondaryAttribute::Field(ref k) => format!("field({k})"), @@ -1038,6 +923,25 @@ impl fmt::Display for SecondaryAttribute { } } +#[derive(PartialEq, Eq, Debug, Clone)] +pub struct MetaAttribute { + pub name: Path, + pub arguments: Vec, + pub span: Span, +} + +impl Display for MetaAttribute { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.arguments.is_empty() { + write!(f, "{}", self.name) + } else { + let args = + self.arguments.iter().map(ToString::to_string).collect::>().join(", "); + write!(f, "{}({})", self.name, args) + } + } +} + #[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] pub struct CustomAttribute { pub contents: String, @@ -1059,38 +963,6 @@ impl CustomAttribute { } } -impl AsRef for FunctionAttribute { - fn as_ref(&self) -> &str { - match self { - FunctionAttribute::Foreign(string) => string, - FunctionAttribute::Builtin(string) => string, - FunctionAttribute::Oracle(string) => string, - FunctionAttribute::Test { .. } => "", - FunctionAttribute::Fold => "", - FunctionAttribute::NoPredicates => "", - FunctionAttribute::InlineAlways => "", - } - } -} - -impl AsRef for SecondaryAttribute { - fn as_ref(&self) -> &str { - match self { - SecondaryAttribute::Deprecated(Some(string)) => string, - SecondaryAttribute::Deprecated(None) => "", - SecondaryAttribute::Tag(attribute) => &attribute.contents, - SecondaryAttribute::Meta(attribute) => &attribute.contents, - SecondaryAttribute::Field(string) - | SecondaryAttribute::Abi(string) - | SecondaryAttribute::Allow(string) => string, - SecondaryAttribute::ContractLibraryMethod => "", - SecondaryAttribute::Export => "", - SecondaryAttribute::Varargs => "", - SecondaryAttribute::UseCallersScope => "", - } - } -} - /// Note that `self` is not present - it is a contextual keyword rather than a true one as it is /// only special within `impl`s. Otherwise `self` functions as a normal identifier. #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone, PartialOrd, Ord, strum_macros::EnumIter)] diff --git a/noir/noir-repo/compiler/noirc_frontend/src/locations.rs b/noir/noir-repo/compiler/noirc_frontend/src/locations.rs index 4dd699251a6a..ecae5b19a95a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/locations.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/locations.rs @@ -1,14 +1,11 @@ use fm::FileId; -use noirc_errors::Location; +use noirc_errors::{Location, Span}; use rangemap::RangeMap; use rustc_hash::FxHashMap as HashMap; use crate::{ ast::{FunctionDefinition, ItemVisibility}, - hir::{ - def_map::{ModuleDefId, ModuleId}, - resolution::import::PathResolutionItem, - }, + hir::def_map::{ModuleDefId, ModuleId}, node_interner::{ DefinitionId, FuncId, GlobalId, NodeInterner, ReferenceId, StructId, TraitId, TypeAliasId, }, @@ -37,6 +34,27 @@ impl LocationIndices { } } +pub struct ReferencesTracker<'a> { + interner: &'a mut NodeInterner, + file_id: FileId, +} + +impl<'a> ReferencesTracker<'a> { + pub fn new(interner: &'a mut NodeInterner, file_id: FileId) -> Self { + Self { interner, file_id } + } + + pub(crate) fn add_reference( + &mut self, + module_def_id: ModuleDefId, + span: Span, + is_self_type: bool, + ) { + let location = Location::new(span, self.file_id); + self.interner.add_module_def_id_reference(module_def_id, location, is_self_type); + } +} + impl NodeInterner { pub fn reference_location(&self, reference: ReferenceId) -> Location { match reference { @@ -102,37 +120,6 @@ impl NodeInterner { }; } - pub(crate) fn add_path_resolution_kind_reference( - &mut self, - kind: PathResolutionItem, - location: Location, - is_self_type: bool, - ) { - match kind { - PathResolutionItem::Module(module_id) => { - self.add_module_reference(module_id, location); - } - PathResolutionItem::Struct(struct_id) => { - self.add_struct_reference(struct_id, location, is_self_type); - } - PathResolutionItem::TypeAlias(type_alias_id) => { - self.add_alias_reference(type_alias_id, location); - } - PathResolutionItem::Trait(trait_id) => { - self.add_trait_reference(trait_id, location, is_self_type); - } - PathResolutionItem::Global(global_id) => { - self.add_global_reference(global_id, location); - } - PathResolutionItem::ModuleFunction(func_id) - | PathResolutionItem::StructFunction(_, _, func_id) - | PathResolutionItem::TypeAliasFunction(_, _, func_id) - | PathResolutionItem::TraitFunction(_, _, func_id) => { - self.add_function_reference(func_id, location); - } - } - } - pub(crate) fn add_module_reference(&mut self, id: ModuleId, location: Location) { self.add_reference(ReferenceId::Module(id), location, false); } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs index 7c7f87b7b8bd..8f6817dc15d0 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -237,13 +237,11 @@ pub enum InlineType { impl From<&Attributes> for InlineType { fn from(attributes: &Attributes) -> Self { - attributes.function.as_ref().map_or(InlineType::default(), |func_attribute| { - match func_attribute { - FunctionAttribute::Fold => InlineType::Fold, - FunctionAttribute::NoPredicates => InlineType::NoPredicates, - FunctionAttribute::InlineAlways => InlineType::InlineAlways, - _ => InlineType::default(), - } + attributes.function().map_or(InlineType::default(), |func_attribute| match func_attribute { + FunctionAttribute::Fold => InlineType::Fold, + FunctionAttribute::NoPredicates => InlineType::NoPredicates, + FunctionAttribute::InlineAlways => InlineType::InlineAlways, + _ => InlineType::default(), }) } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/errors.rs index e2ff94f521bf..c137a6fc90ab 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/errors.rs @@ -1,10 +1,13 @@ use noirc_errors::{CustomDiagnostic, FileDiagnostic, Location}; -use crate::{hir::comptime::InterpreterError, Type}; +use crate::{ + hir::{comptime::InterpreterError, type_check::TypeCheckError}, + Type, +}; #[derive(Debug)] pub enum MonomorphizationError { - UnknownArrayLength { length: Type, location: Location }, + UnknownArrayLength { length: Type, err: TypeCheckError, location: Location }, UnknownConstant { location: Location }, NoDefaultType { location: Location }, InternalError { message: &'static str, location: Location }, @@ -12,6 +15,7 @@ pub enum MonomorphizationError { ComptimeFnInRuntimeCode { name: String, location: Location }, ComptimeTypeInRuntimeCode { typ: String, location: Location }, CheckedTransmuteFailed { actual: Type, expected: Type, location: Location }, + CheckedCastFailed { actual: Type, expected: Type, location: Location }, } impl MonomorphizationError { @@ -23,6 +27,7 @@ impl MonomorphizationError { | MonomorphizationError::ComptimeFnInRuntimeCode { location, .. } | MonomorphizationError::ComptimeTypeInRuntimeCode { location, .. } | MonomorphizationError::CheckedTransmuteFailed { location, .. } + | MonomorphizationError::CheckedCastFailed { location, .. } | MonomorphizationError::NoDefaultType { location, .. } => *location, MonomorphizationError::InterpreterError(error) => error.get_location(), } @@ -41,14 +46,17 @@ impl From for FileDiagnostic { impl MonomorphizationError { fn into_diagnostic(self) -> CustomDiagnostic { let message = match &self { - MonomorphizationError::UnknownArrayLength { length, .. } => { - format!("Could not determine array length `{length}`") + MonomorphizationError::UnknownArrayLength { length, err, .. } => { + format!("Could not determine array length `{length}`, encountered error: `{err}`") } MonomorphizationError::UnknownConstant { .. } => { "Could not resolve constant".to_string() } MonomorphizationError::CheckedTransmuteFailed { actual, expected, .. } => { - format!("checked_transmute failed: `{actual}` != `{expected}`") + format!("checked_transmute failed: `{actual:?}` != `{expected:?}`") + } + MonomorphizationError::CheckedCastFailed { actual, expected, .. } => { + format!("Arithmetic generics simplification failed: `{actual:?}` != `{expected:?}`") } MonomorphizationError::NoDefaultType { location } => { let message = "Type annotation needed".into(); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs index 21a2d5333548..0ec26a5ca83d 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -10,7 +10,7 @@ //! function, will monomorphize the entire reachable program. use crate::ast::{FunctionKind, IntegerBitSize, Signedness, UnaryOp, Visibility}; use crate::hir::comptime::InterpreterError; -use crate::hir::type_check::NoMatchingImplFoundError; +use crate::hir::type_check::{NoMatchingImplFoundError, TypeCheckError}; use crate::node_interner::{ExprId, ImplSearchErrorKind}; use crate::{ debug::DebugInstrumenter, @@ -221,14 +221,14 @@ impl<'interner> Monomorphizer<'interner> { let attributes = self.interner.function_attributes(&id); match self.interner.function_meta(&id).kind { FunctionKind::LowLevel => { - let attribute = attributes.function.as_ref().expect("all low level functions must contain a function attribute which contains the opcode which it links to"); + let attribute = attributes.function().expect("all low level functions must contain a function attribute which contains the opcode which it links to"); let opcode = attribute.foreign().expect( "ice: function marked as foreign, but attribute kind does not match this", ); Definition::LowLevel(opcode.to_string()) } FunctionKind::Builtin => { - let attribute = attributes.function.as_ref().expect("all builtin functions must contain a function attribute which contains the opcode which it links to"); + let attribute = attributes.function().expect("all builtin functions must contain a function attribute which contains the opcode which it links to"); let opcode = attribute.builtin().expect( "ice: function marked as builtin, but attribute kind does not match this", ); @@ -240,7 +240,7 @@ impl<'interner> Monomorphizer<'interner> { Definition::Function(id) } FunctionKind::Oracle => { - let attribute = attributes.function.as_ref().expect("all oracle functions must contain a function attribute which contains the opcode which it links to"); + let attribute = attributes.function().expect("all oracle functions must contain a function attribute which contains the opcode which it links to"); let opcode = attribute.oracle().expect( "ice: function marked as builtin, but attribute kind does not match this", ); @@ -570,9 +570,9 @@ impl<'interner> Monomorphizer<'interner> { let location = self.interner.expr_location(&array); let typ = Self::convert_type(&self.interner.id_type(array), location)?; - let length = length.evaluate_to_u32().ok_or_else(|| { + let length = length.evaluate_to_u32(location.span).map_err(|err| { let location = self.interner.expr_location(&array); - MonomorphizationError::UnknownArrayLength { location, length } + MonomorphizationError::UnknownArrayLength { location, err, length } })?; let contents = try_vecmap(0..length, |_| self.expr(repeated_element))?; @@ -922,17 +922,23 @@ impl<'interner> Monomorphizer<'interner> { TypeBinding::Unbound(_, _) => { unreachable!("Unbound type variable used in expression") } - TypeBinding::Bound(binding) => binding - .evaluate_to_field_element(&Kind::Numeric(numeric_typ.clone())) - .unwrap_or_else(|| { - panic!("Non-numeric type variable used in expression expecting a value") - }), + TypeBinding::Bound(binding) => { + let location = self.interner.id_location(expr_id); + binding + .evaluate_to_field_element( + &Kind::Numeric(numeric_typ.clone()), + location.span, + ) + .map_err(|err| MonomorphizationError::UnknownArrayLength { + length: binding.clone(), + err, + location, + })? + } }; let location = self.interner.id_location(expr_id); - if !Kind::Numeric(numeric_typ.clone()) - .unifies(&Kind::Numeric(Box::new(typ.clone()))) - { + if !Kind::Numeric(numeric_typ.clone()).unifies(&Kind::numeric(typ.clone())) { let message = "ICE: Generic's kind does not match expected type"; return Err(MonomorphizationError::InternalError { location, message }); } @@ -951,20 +957,51 @@ impl<'interner> Monomorphizer<'interner> { HirType::FieldElement => ast::Type::Field, HirType::Integer(sign, bits) => ast::Type::Integer(*sign, *bits), HirType::Bool => ast::Type::Bool, - HirType::String(size) => ast::Type::String(size.evaluate_to_u32().unwrap_or(0)), + HirType::String(size) => { + let size = match size.evaluate_to_u32(location.span) { + Ok(size) => size, + // only default variable sizes to size 0 + Err(TypeCheckError::NonConstantEvaluated { .. }) => 0, + Err(err) => { + let length = size.as_ref().clone(); + return Err(MonomorphizationError::UnknownArrayLength { + location, + err, + length, + }); + } + }; + ast::Type::String(size) + } HirType::FmtString(size, fields) => { - let size = size.evaluate_to_u32().unwrap_or(0); + let size = match size.evaluate_to_u32(location.span) { + Ok(size) => size, + // only default variable sizes to size 0 + Err(TypeCheckError::NonConstantEvaluated { .. }) => 0, + Err(err) => { + let length = size.as_ref().clone(); + return Err(MonomorphizationError::UnknownArrayLength { + location, + err, + length, + }); + } + }; let fields = Box::new(Self::convert_type(fields.as_ref(), location)?); ast::Type::FmtString(size, fields) } HirType::Unit => ast::Type::Unit, HirType::Array(length, element) => { let element = Box::new(Self::convert_type(element.as_ref(), location)?); - let length = match length.evaluate_to_u32() { - Some(length) => length, - None => { + let length = match length.evaluate_to_u32(location.span) { + Ok(length) => length, + Err(err) => { let length = length.as_ref().clone(); - return Err(MonomorphizationError::UnknownArrayLength { location, length }); + return Err(MonomorphizationError::UnknownArrayLength { + location, + err, + length, + }); } }; ast::Type::Array(length, element) @@ -988,6 +1025,11 @@ impl<'interner> Monomorphizer<'interner> { ast::Type::Field } + HirType::CheckedCast { from, to } => { + Self::check_checked_cast(from, to, location)?; + Self::convert_type(to, location)? + } + HirType::TypeVariable(ref binding) => { let type_var_kind = match &*binding.borrow() { TypeBinding::Bound(ref binding) => { @@ -1094,6 +1136,11 @@ impl<'interner> Monomorphizer<'interner> { Ok(()) } } + HirType::CheckedCast { from, to } => { + Self::check_checked_cast(from, to, location)?; + Self::check_type(to, location) + } + HirType::FmtString(_size, fields) => Self::check_type(fields.as_ref(), location), HirType::Array(_length, element) => Self::check_type(element.as_ref(), location), HirType::Slice(element) => Self::check_type(element.as_ref(), location), @@ -1165,6 +1212,40 @@ impl<'interner> Monomorphizer<'interner> { } } + /// Check that the 'from' and to' sides of a CheckedCast unify and + /// that if the 'to' side evaluates to a field element, that the 'from' side + /// evaluates to the same field element + fn check_checked_cast( + from: &Type, + to: &Type, + location: Location, + ) -> Result<(), MonomorphizationError> { + if from.unify(to).is_err() { + return Err(MonomorphizationError::CheckedCastFailed { + actual: to.clone(), + expected: from.clone(), + location, + }); + } + let to_value = to.evaluate_to_field_element(&to.kind(), location.span); + if to_value.is_ok() { + let skip_simplifications = false; + let from_value = from.evaluate_to_field_element_helper( + &to.kind(), + location.span, + skip_simplifications, + ); + if from_value.is_err() || from_value.unwrap() != to_value.clone().unwrap() { + return Err(MonomorphizationError::CheckedCastFailed { + actual: HirType::Constant(to_value.unwrap(), to.kind()), + expected: from.clone(), + location, + }); + } + } + Ok(()) + } + fn is_function_closure(&self, t: ast::Type) -> bool { if self.is_function_closure_type(&t) { true diff --git a/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs b/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs index c743d5643395..736d37fe83f1 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/node_interner.rs @@ -2439,6 +2439,7 @@ fn get_type_method_key(typ: &Type) -> Option { | Type::Error | Type::Struct(_, _) | Type::InfixExpr(..) + | Type::CheckedCast { .. } | Type::TraitAsType(..) => None, } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/errors.rs index 3315b38a351c..63471efac43b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/errors.rs @@ -95,6 +95,15 @@ pub enum ParserErrorReason { AssociatedTypesNotAllowedInPaths, #[error("Associated types are not allowed on a method call")] AssociatedTypesNotAllowedInMethodCalls, + #[error( + "Wrong number of arguments for attribute `{}`. Expected {}, found {}", + name, + if min == max { min.to_string() } else { format!("between {} and {}", min, max) }, + found + )] + WrongNumberOfAttributeArguments { name: String, min: usize, max: usize, found: usize }, + #[error("The `deprecated` attribute expects a string argument")] + DeprecatedAttributeExpectsAStringArgument, } /// Represents a parsing error, or a parsing error in the making. diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs index 0030144b5e15..f369839ddd45 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser.rs @@ -318,6 +318,30 @@ impl<'a> Parser<'a> { } } + fn eat_attribute_start(&mut self) -> Option { + if matches!(self.token.token(), Token::AttributeStart { is_inner: false, .. }) { + let token = self.bump(); + match token.into_token() { + Token::AttributeStart { is_tag, .. } => Some(is_tag), + _ => unreachable!(), + } + } else { + None + } + } + + fn eat_inner_attribute_start(&mut self) -> Option { + if matches!(self.token.token(), Token::AttributeStart { is_inner: true, .. }) { + let token = self.bump(); + match token.into_token() { + Token::AttributeStart { is_tag, .. } => Some(is_tag), + _ => unreachable!(), + } + } else { + None + } + } + fn eat_comma(&mut self) -> bool { self.eat(Token::Comma) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/attributes.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/attributes.rs index ffba74003b7a..12cb37edb4b7 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/attributes.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/attributes.rs @@ -1,32 +1,87 @@ use noirc_errors::Span; +use crate::ast::{Expression, ExpressionKind, Ident, Literal, Path}; +use crate::lexer::errors::LexerErrorKind; +use crate::parser::labels::ParsingRuleLabel; use crate::parser::ParserErrorReason; -use crate::token::SecondaryAttribute; -use crate::token::{Attribute, Token, TokenKind}; +use crate::token::{Attribute, FunctionAttribute, MetaAttribute, TestScope, Token}; +use crate::token::{CustomAttribute, SecondaryAttribute}; use super::parse_many::without_separator; use super::Parser; impl<'a> Parser<'a> { - /// InnerAttribute = inner_attribute + /// InnerAttribute = '#![' SecondaryAttribute ']' pub(super) fn parse_inner_attribute(&mut self) -> Option { - let token = self.eat_kind(TokenKind::InnerAttribute)?; - match token.into_token() { - Token::InnerAttribute(attribute) => Some(attribute), - _ => unreachable!(), + let start_span = self.current_token_span; + let is_tag = self.eat_inner_attribute_start()?; + let attribute = if is_tag { + self.parse_tag_attribute(start_span) + } else { + self.parse_non_tag_attribute(start_span) + }; + + match attribute { + Attribute::Function(function_attribute) => { + self.errors.push( + LexerErrorKind::InvalidInnerAttribute { + span: self.span_since(start_span), + found: function_attribute.to_string(), + } + .into(), + ); + None + } + Attribute::Secondary(secondary_attribute) => Some(secondary_attribute), } } - /// Attributes = attribute* + /// Attributes = Attribute* pub(super) fn parse_attributes(&mut self) -> Vec<(Attribute, Span)> { self.parse_many("attributes", without_separator(), Self::parse_attribute) } - fn parse_attribute(&mut self) -> Option<(Attribute, Span)> { - self.eat_kind(TokenKind::Attribute).map(|token| match token.into_token() { - Token::Attribute(attribute) => (attribute, self.previous_token_span), - _ => unreachable!(), - }) + /// Attribute = '#[' (FunctionAttribute | SecondaryAttribute) ']' + /// + /// FunctionAttribute + /// = 'builtin' '(' AttributeValue ')' + /// | 'fold' + /// | 'foreign' '(' AttributeValue ')' + /// | 'inline_always' + /// | 'no_predicates' + /// | 'oracle' '(' AttributeValue ')' + /// | 'recursive' + /// | 'test' + /// | 'test' '(' 'should_fail' ')' + /// | 'test' '(' 'should_fail_with' '=' string ')' + /// + /// SecondaryAttribute + /// = 'abi' '(' AttributeValue ')' + /// | 'allow' '(' AttributeValue ')' + /// | 'deprecated' + /// | 'deprecated' '(' string ')' + /// | 'contract_library_method' + /// | 'export' + /// | 'field' '(' AttributeValue ')' + /// | 'use_callers_scope' + /// | 'varargs' + /// | MetaAttribute + /// + /// MetaAttribute + /// = Path Arguments? + /// + /// AttributeValue + /// = Path + /// | integer + pub(crate) fn parse_attribute(&mut self) -> Option<(Attribute, Span)> { + let start_span = self.current_token_span; + let is_tag = self.eat_attribute_start()?; + let attribute = if is_tag { + self.parse_tag_attribute(start_span) + } else { + self.parse_non_tag_attribute(start_span) + }; + Some((attribute, self.span_since(start_span))) } pub(super) fn validate_secondary_attributes( @@ -44,17 +99,315 @@ impl<'a> Parser<'a> { }) .collect() } + + fn parse_tag_attribute(&mut self, start_span: Span) -> Attribute { + let contents_start_span = self.current_token_span; + let mut contents_span = contents_start_span; + let mut contents = String::new(); + + let mut brackets_count = 1; // 1 because of the starting `#[` + + while !self.at_eof() { + if self.at(Token::LeftBracket) { + brackets_count += 1; + } else if self.at(Token::RightBracket) { + brackets_count -= 1; + if brackets_count == 0 { + contents_span = self.span_since(contents_start_span); + self.bump(); + break; + } + } + + contents.push_str(&self.token.to_string()); + self.bump(); + } + + Attribute::Secondary(SecondaryAttribute::Tag(CustomAttribute { + contents, + span: self.span_since(start_span), + contents_span, + })) + } + + fn parse_non_tag_attribute(&mut self, start_span: Span) -> Attribute { + if matches!(&self.token.token(), Token::Keyword(..)) + && (self.next_is(Token::LeftParen) || self.next_is(Token::RightBracket)) + { + // This is a Meta attribute with the syntax `keyword(arg1, arg2, .., argN)` + let path = Path::from_single(self.token.to_string(), self.current_token_span); + self.bump(); + self.parse_meta_attribute(path, start_span) + } else if let Some(path) = self.parse_path_no_turbofish() { + if let Some(ident) = path.as_ident() { + if ident.0.contents == "test" { + // The test attribute is the only secondary attribute that has `a = b` in its syntax + // (`should_fail_with = "..."``) so we parse it differently. + self.parse_test_attribute(start_span) + } else { + // Every other attribute has the form `name(arg1, arg2, .., argN)` + self.parse_ident_attribute_other_than_test(ident, start_span) + } + } else { + // This is a Meta attribute with the syntax `path(arg1, arg2, .., argN)` + self.parse_meta_attribute(path, start_span) + } + } else { + self.expected_label(ParsingRuleLabel::Path); + self.parse_tag_attribute(start_span) + } + } + + fn parse_meta_attribute(&mut self, name: Path, start_span: Span) -> Attribute { + let arguments = self.parse_arguments().unwrap_or_default(); + self.skip_until_right_bracket(); + Attribute::Secondary(SecondaryAttribute::Meta(MetaAttribute { + name, + arguments, + span: self.span_since(start_span), + })) + } + + fn parse_ident_attribute_other_than_test( + &mut self, + ident: &Ident, + start_span: Span, + ) -> Attribute { + let arguments = self.parse_arguments().unwrap_or_default(); + self.skip_until_right_bracket(); + match ident.0.contents.as_str() { + "abi" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Secondary(SecondaryAttribute::Abi(name)) + }), + "allow" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Secondary(SecondaryAttribute::Allow(name)) + }), + "builtin" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Function(FunctionAttribute::Builtin(name)) + }), + "deprecated" => self.parse_deprecated_attribute(ident, arguments), + "contract_library_method" => { + let attr = Attribute::Secondary(SecondaryAttribute::ContractLibraryMethod); + self.parse_no_args_attribute(ident, arguments, attr) + } + "export" => { + let attr = Attribute::Secondary(SecondaryAttribute::Export); + self.parse_no_args_attribute(ident, arguments, attr) + } + "field" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Secondary(SecondaryAttribute::Field(name)) + }), + "fold" => { + let attr = Attribute::Function(FunctionAttribute::Fold); + self.parse_no_args_attribute(ident, arguments, attr) + } + "foreign" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Function(FunctionAttribute::Foreign(name)) + }), + "inline_always" => { + let attr = Attribute::Function(FunctionAttribute::InlineAlways); + self.parse_no_args_attribute(ident, arguments, attr) + } + "no_predicates" => { + let attr = Attribute::Function(FunctionAttribute::NoPredicates); + self.parse_no_args_attribute(ident, arguments, attr) + } + "oracle" => self.parse_single_name_attribute(ident, arguments, start_span, |name| { + Attribute::Function(FunctionAttribute::Oracle(name)) + }), + "use_callers_scope" => { + let attr = Attribute::Secondary(SecondaryAttribute::UseCallersScope); + self.parse_no_args_attribute(ident, arguments, attr) + } + "varargs" => { + let attr = Attribute::Secondary(SecondaryAttribute::Varargs); + self.parse_no_args_attribute(ident, arguments, attr) + } + _ => Attribute::Secondary(SecondaryAttribute::Meta(MetaAttribute { + name: Path::from_ident(ident.clone()), + arguments, + span: self.span_since(start_span), + })), + } + } + + fn parse_deprecated_attribute( + &mut self, + ident: &Ident, + mut arguments: Vec, + ) -> Attribute { + if arguments.is_empty() { + return Attribute::Secondary(SecondaryAttribute::Deprecated(None)); + } + + if arguments.len() > 1 { + self.push_error( + ParserErrorReason::WrongNumberOfAttributeArguments { + name: ident.to_string(), + min: 0, + max: 1, + found: arguments.len(), + }, + ident.span(), + ); + return Attribute::Secondary(SecondaryAttribute::Deprecated(None)); + } + + let argument = arguments.remove(0); + let ExpressionKind::Literal(Literal::Str(message)) = argument.kind else { + self.push_error( + ParserErrorReason::DeprecatedAttributeExpectsAStringArgument, + argument.span, + ); + return Attribute::Secondary(SecondaryAttribute::Deprecated(None)); + }; + + Attribute::Secondary(SecondaryAttribute::Deprecated(Some(message))) + } + + fn parse_test_attribute(&mut self, start_span: Span) -> Attribute { + let scope = if self.eat_left_paren() { + let scope = if let Some(ident) = self.eat_ident() { + match ident.0.contents.as_str() { + "should_fail" => Some(TestScope::ShouldFailWith { reason: None }), + "should_fail_with" => { + self.eat_or_error(Token::Assign); + if let Some(reason) = self.eat_str() { + Some(TestScope::ShouldFailWith { reason: Some(reason) }) + } else { + Some(TestScope::ShouldFailWith { reason: None }) + } + } + _ => None, + } + } else { + None + }; + self.eat_or_error(Token::RightParen); + scope + } else { + Some(TestScope::None) + }; + + self.skip_until_right_bracket(); + + let scope = if let Some(scope) = scope { + scope + } else { + self.errors.push( + LexerErrorKind::MalformedTestAttribute { span: self.span_since(start_span) }.into(), + ); + TestScope::None + }; + + Attribute::Function(FunctionAttribute::Test(scope)) + } + + fn parse_single_name_attribute( + &mut self, + ident: &Ident, + mut arguments: Vec, + start_span: Span, + f: F, + ) -> Attribute + where + F: FnOnce(String) -> Attribute, + { + if arguments.len() != 1 { + self.push_error( + ParserErrorReason::WrongNumberOfAttributeArguments { + name: ident.to_string(), + min: 1, + max: 1, + found: arguments.len(), + }, + self.current_token_span, + ); + return f(String::new()); + } + + let argument = arguments.remove(0); + match argument.kind { + ExpressionKind::Variable(..) | ExpressionKind::Literal(Literal::Integer(..)) => { + f(argument.to_string()) + } + _ => { + let span = self.span_since(start_span); + self.errors.push( + LexerErrorKind::MalformedFuncAttribute { span, found: argument.to_string() } + .into(), + ); + f(String::new()) + } + } + } + + fn parse_no_args_attribute( + &mut self, + ident: &Ident, + arguments: Vec, + attribute: Attribute, + ) -> Attribute { + if !arguments.is_empty() { + self.push_error( + ParserErrorReason::WrongNumberOfAttributeArguments { + name: ident.to_string(), + min: 0, + max: 0, + found: arguments.len(), + }, + ident.span(), + ); + } + + attribute + } + + fn skip_until_right_bracket(&mut self) { + let mut brackets_count = 1; // 1 because of the starting `#[` + + while !self.at_eof() { + if self.at(Token::LeftBracket) { + brackets_count += 1; + } else if self.at(Token::RightBracket) { + brackets_count -= 1; + if brackets_count == 0 { + self.bump(); + break; + } + } + + self.expected_token(Token::RightBracket); + self.bump(); + } + } } #[cfg(test)] mod tests { + use noirc_errors::Span; + use crate::{ parser::{parser::tests::expect_no_errors, Parser}, token::{Attribute, FunctionAttribute, SecondaryAttribute, TestScope}, }; + fn parse_inner_secondary_attribute_no_errors(src: &str, expected: SecondaryAttribute) { + let mut parser = Parser::for_str(src); + let attribute = parser.parse_inner_attribute(); + expect_no_errors(&parser.errors); + assert_eq!(attribute.unwrap(), expected); + } + + fn parse_attribute_no_errors(src: &str, expected: Attribute) { + let mut parser = Parser::for_str(src); + let (attribute, _span) = parser.parse_attribute().unwrap(); + expect_no_errors(&parser.errors); + assert_eq!(attribute, expected); + } + #[test] - fn parses_inner_attribute() { + fn parses_inner_attribute_as_tag() { let src = "#!['hello]"; let mut parser = Parser::for_str(src); let Some(SecondaryAttribute::Tag(custom)) = parser.parse_inner_attribute() else { @@ -62,6 +415,210 @@ mod tests { }; expect_no_errors(&parser.errors); assert_eq!(custom.contents, "hello"); + assert_eq!(custom.span, Span::from(0..src.len() as u32)); + assert_eq!(custom.contents_span, Span::from(4..src.len() as u32 - 1)); + } + + #[test] + fn parses_inner_attribute_as_tag_with_nested_brackets() { + let src = "#!['hello[1]]"; + let mut parser = Parser::for_str(src); + let Some(SecondaryAttribute::Tag(custom)) = parser.parse_inner_attribute() else { + panic!("Expected inner tag attribute"); + }; + expect_no_errors(&parser.errors); + assert_eq!(custom.contents, "hello[1]"); + } + + #[test] + fn parses_inner_attribute_deprecated() { + let src = "#![deprecated]"; + let expected = SecondaryAttribute::Deprecated(None); + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_inner_attribute_deprecated_with_message() { + let src = "#![deprecated(\"use something else\")]"; + let expected = SecondaryAttribute::Deprecated(Some("use something else".to_string())); + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_inner_attribute_contract_library_method() { + let src = "#![contract_library_method]"; + let expected = SecondaryAttribute::ContractLibraryMethod; + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_inner_attribute_export() { + let src = "#![export]"; + let expected = SecondaryAttribute::Export; + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_inner_attribute_varargs() { + let src = "#![varargs]"; + let expected = SecondaryAttribute::Varargs; + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_inner_attribute_use_callers_scope() { + let src = "#![use_callers_scope]"; + let expected = SecondaryAttribute::UseCallersScope; + parse_inner_secondary_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_abi() { + let src = "#[abi(foo)]"; + let expected = Attribute::Secondary(SecondaryAttribute::Abi("foo".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_foreign() { + let src = "#[foreign(foo)]"; + let expected = Attribute::Function(FunctionAttribute::Foreign("foo".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_builtin() { + let src = "#[builtin(foo)]"; + let expected = Attribute::Function(FunctionAttribute::Builtin("foo".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_oracle() { + let src = "#[oracle(foo)]"; + let expected = Attribute::Function(FunctionAttribute::Oracle("foo".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_fold() { + let src = "#[fold]"; + let expected = Attribute::Function(FunctionAttribute::Fold); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_no_predicates() { + let src = "#[no_predicates]"; + let expected = Attribute::Function(FunctionAttribute::NoPredicates); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_inline_always() { + let src = "#[inline_always]"; + let expected = Attribute::Function(FunctionAttribute::InlineAlways); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_field() { + let src = "#[field(bn254)]"; + let expected = Attribute::Secondary(SecondaryAttribute::Field("bn254".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_field_with_integer() { + let src = "#[field(23)]"; + let expected = Attribute::Secondary(SecondaryAttribute::Field("23".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_allow() { + let src = "#[allow(unused_vars)]"; + let expected = Attribute::Secondary(SecondaryAttribute::Allow("unused_vars".to_string())); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_test_no_scope() { + let src = "#[test]"; + let expected = Attribute::Function(FunctionAttribute::Test(TestScope::None)); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_test_should_fail() { + let src = "#[test(should_fail)]"; + let expected = Attribute::Function(FunctionAttribute::Test(TestScope::ShouldFailWith { + reason: None, + })); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_attribute_test_should_fail_with() { + let src = "#[test(should_fail_with = \"reason\")]"; + let expected = Attribute::Function(FunctionAttribute::Test(TestScope::ShouldFailWith { + reason: Some("reason".to_string()), + })); + parse_attribute_no_errors(src, expected); + } + + #[test] + fn parses_meta_attribute_single_identifier_no_arguments() { + let src = "#[foo]"; + let mut parser = Parser::for_str(src); + let (attribute, _span) = parser.parse_attribute().unwrap(); + expect_no_errors(&parser.errors); + let Attribute::Secondary(SecondaryAttribute::Meta(meta)) = attribute else { + panic!("Expected meta attribute"); + }; + assert_eq!(meta.name.to_string(), "foo"); + assert!(meta.arguments.is_empty()); + } + + #[test] + fn parses_meta_attribute_single_identifier_as_keyword() { + let src = "#[dep]"; + let mut parser = Parser::for_str(src); + let (attribute, _span) = parser.parse_attribute().unwrap(); + expect_no_errors(&parser.errors); + let Attribute::Secondary(SecondaryAttribute::Meta(meta)) = attribute else { + panic!("Expected meta attribute"); + }; + assert_eq!(meta.name.to_string(), "dep"); + assert!(meta.arguments.is_empty()); + } + + #[test] + fn parses_meta_attribute_single_identifier_with_arguments() { + let src = "#[foo(1, 2, 3)]"; + let mut parser = Parser::for_str(src); + let (attribute, _span) = parser.parse_attribute().unwrap(); + expect_no_errors(&parser.errors); + let Attribute::Secondary(SecondaryAttribute::Meta(meta)) = attribute else { + panic!("Expected meta attribute"); + }; + assert_eq!(meta.name.to_string(), "foo"); + assert_eq!(meta.arguments.len(), 3); + assert_eq!(meta.arguments[0].to_string(), "1"); + } + + #[test] + fn parses_meta_attribute_path_with_arguments() { + let src = "#[foo::bar(1, 2, 3)]"; + let mut parser = Parser::for_str(src); + let (attribute, _span) = parser.parse_attribute().unwrap(); + expect_no_errors(&parser.errors); + let Attribute::Secondary(SecondaryAttribute::Meta(meta)) = attribute else { + panic!("Expected meta attribute"); + }; + assert_eq!(meta.name.to_string(), "foo::bar"); + assert_eq!(meta.arguments.len(), 3); + assert_eq!(meta.arguments[0].to_string(), "1"); } #[test] diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs index a60bc6e7c1dc..438757b5d791 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs @@ -246,22 +246,23 @@ impl<'a> Parser<'a> { } fn validate_attributes(&mut self, attributes: Vec<(Attribute, Span)>) -> Attributes { - let mut primary = None; + let mut function = None; let mut secondary = Vec::new(); - for (attribute, span) in attributes { + for (index, (attribute, span)) in attributes.into_iter().enumerate() { match attribute { Attribute::Function(attr) => { - if primary.is_some() { + if function.is_none() { + function = Some((attr, index)); + } else { self.push_error(ParserErrorReason::MultipleFunctionAttributesFound, span); } - primary = Some(attr); } Attribute::Secondary(attr) => secondary.push(attr), } } - Attributes { function: primary, secondary } + Attributes { function, secondary } } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs index 17accbd8366c..f72741721d8b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs @@ -1,6 +1,7 @@ #![cfg(test)] mod aliases; +mod arithmetic_generics; mod bound_checks; mod imports; mod metaprogramming; @@ -36,6 +37,8 @@ use crate::hir::def_collector::dc_crate::DefCollector; use crate::hir::def_map::{CrateDefMap, LocalModuleId}; use crate::hir_def::expr::HirExpression; use crate::hir_def::stmt::HirStatement; +use crate::monomorphization::ast::Program; +use crate::monomorphization::errors::MonomorphizationError; use crate::monomorphization::monomorphize; use crate::parser::{ItemKind, ParserErrorReason}; use crate::token::SecondaryAttribute; @@ -57,6 +60,15 @@ pub(crate) fn remove_experimental_warnings(errors: &mut Vec<(CompilationError, F } pub(crate) fn get_program(src: &str) -> (ParsedModule, Context, Vec<(CompilationError, FileId)>) { + get_program_with_maybe_parser_errors( + src, false, // allow parser errors + ) +} + +pub(crate) fn get_program_with_maybe_parser_errors( + src: &str, + allow_parser_errors: bool, +) -> (ParsedModule, Context, Vec<(CompilationError, FileId)>) { let root = std::path::Path::new("/"); let fm = FileManager::new(root); @@ -69,7 +81,7 @@ pub(crate) fn get_program(src: &str) -> (ParsedModule, Context, Vec<(Compilation let mut errors = vecmap(parser_errors, |e| (e.into(), root_file_id)); remove_experimental_warnings(&mut errors); - if !has_parser_error(&errors) { + if allow_parser_errors || !has_parser_error(&errors) { let inner_attributes: Vec = program .items .iter() @@ -1239,10 +1251,18 @@ fn resolve_fmt_strings() { } } -fn check_rewrite(src: &str, expected: &str) { +fn monomorphize_program(src: &str) -> Result { let (_program, mut context, _errors) = get_program(src); let main_func_id = context.def_interner.find_function("main").unwrap(); - let program = monomorphize(main_func_id, &mut context.def_interner).unwrap(); + monomorphize(main_func_id, &mut context.def_interner) +} + +fn get_monomorphization_error(src: &str) -> Option { + monomorphize_program(src).err() +} + +fn check_rewrite(src: &str, expected: &str) { + let program = monomorphize_program(src).unwrap(); assert!(format!("{}", program) == expected); } @@ -1982,9 +2002,9 @@ fn numeric_generic_u16_array_size() { fn numeric_generic_field_larger_than_u32() { let src = r#" global A: Field = 4294967297; - + fn foo() { } - + fn main() { let _ = foo::(); } @@ -2014,14 +2034,14 @@ fn numeric_generic_field_arithmetic_larger_than_u32() { F } } - + // 2^32 - 1 global A: Field = 4294967295; - + fn foo() -> Foo { Foo {} } - + fn main() { let _ = foo::().size(); } @@ -3189,25 +3209,6 @@ fn as_trait_path_syntax_no_impl() { assert!(matches!(&errors[0].0, TypeError(TypeCheckError::NoMatchingImplFound { .. }))); } -#[test] -fn arithmetic_generics_canonicalization_deduplication_regression() { - let source = r#" - struct ArrData { - a: [Field; N], - b: [Field; N + N - 1], - } - - fn main() { - let _f: ArrData<5> = ArrData { - a: [0; 5], - b: [0; 9], - }; - } - "#; - let errors = get_program_errors(source); - assert_eq!(errors.len(), 0); -} - #[test] fn infer_globals_to_u32_from_type_use() { let src = r#" @@ -3393,6 +3394,36 @@ fn arithmetic_generics_rounding_fail() { let errors = get_program_errors(src); assert_eq!(errors.len(), 1); + assert!(matches!( + errors[0].0, + CompilationError::TypeError(TypeCheckError::TypeMismatch { .. }) + )); +} + +#[test] +fn arithmetic_generics_rounding_fail_on_struct() { + let src = r#" + struct W {} + + fn foo(_x: W, _y: W) -> W { + W {} + } + + fn main() { + let w_2: W<2> = W {}; + let w_3: W<3> = W {}; + // Do not simplify N/M*M to just N + // This should be 3/2*2 = 2, not 3 + let _: W<3> = foo(w_3, w_2); + } + "#; + + let errors = get_program_errors(src); + assert_eq!(errors.len(), 1); + assert!(matches!( + errors[0].0, + CompilationError::TypeError(TypeCheckError::TypeMismatch { .. }) + )); } #[test] @@ -3438,7 +3469,7 @@ fn unconditional_recursion_fail() { fn main() -> pub u64 { foo(1, main()) } - fn foo(a: u64, b: u64) -> u64 { + fn foo(a: u64, b: u64) -> u64 { a + b } "#, @@ -3623,3 +3654,41 @@ fn use_type_alias_to_generic_concrete_type_in_method_call() { "#; assert_no_errors(src); } + +#[test] +fn allows_struct_with_generic_infix_type_as_main_input_1() { + let src = r#" + struct Foo { + x: [u64; N * 2], + } + + fn main(_x: Foo<18>) {} + "#; + assert_no_errors(src); +} + +#[test] +fn allows_struct_with_generic_infix_type_as_main_input_2() { + let src = r#" + struct Foo { + x: [u64; N * 2], + } + + fn main(_x: Foo<2 * 9>) {} + "#; + assert_no_errors(src); +} + +#[test] +fn allows_struct_with_generic_infix_type_as_main_input_3() { + let src = r#" + struct Foo { + x: [u64; N * 2], + } + + global N = 9; + + fn main(_x: Foo) {} + "#; + assert_no_errors(src); +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests/arithmetic_generics.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests/arithmetic_generics.rs new file mode 100644 index 000000000000..3328fe439ae1 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests/arithmetic_generics.rs @@ -0,0 +1,155 @@ +#![cfg(test)] + +use acvm::{AcirField, FieldElement}; + +use super::get_program_errors; +use crate::hir::type_check::TypeCheckError; +use crate::hir_def::types::{BinaryTypeOperator, Type}; +use crate::monomorphization::errors::MonomorphizationError; +use crate::tests::get_monomorphization_error; + +#[test] +fn arithmetic_generics_canonicalization_deduplication_regression() { + let source = r#" + struct ArrData { + a: [Field; N], + b: [Field; N + N - 1], + } + + fn main() { + let _f: ArrData<5> = ArrData { + a: [0; 5], + b: [0; 9], + }; + } + "#; + let errors = get_program_errors(source); + assert_eq!(errors.len(), 0); +} + +#[test] +fn checked_casts_do_not_prevent_canonicalization() { + // Regression test for https://github.com/noir-lang/noir/issues/6495 + let source = r#" + pub trait Serialize { + fn serialize(self) -> [Field; N]; + } + + pub struct Counted { + pub inner: T, + } + + pub fn append(array1: [T; N]) -> [T; N + 1] { + [array1[0]; N + 1] + } + + impl Serialize for Counted + where + T: Serialize, + { + fn serialize(self) -> [Field; N] { + append(self.inner.serialize()) + } + } + "#; + let errors = get_program_errors(source); + println!("{:?}", errors); + assert_eq!(errors.len(), 0); +} + +#[test] +fn arithmetic_generics_checked_cast_zeros() { + let source = r#" + struct W {} + + fn foo(_x: W) -> W<(0 * N) / (N % N)> { + W {} + } + + fn bar(_x: W) -> u1 { + N + } + + fn main() -> pub u1 { + let w_0: W<0> = W {}; + let w: W<_> = foo(w_0); + bar(w) + } + "#; + + let errors = get_program_errors(source); + assert_eq!(errors.len(), 0); + + let monomorphization_error = get_monomorphization_error(source); + assert!(monomorphization_error.is_some()); + + // Expect a CheckedCast (0 % 0) failure + let monomorphization_error = monomorphization_error.unwrap(); + if let MonomorphizationError::UnknownArrayLength { ref length, ref err, location: _ } = + monomorphization_error + { + match length { + Type::CheckedCast { from, to } => { + assert!(matches!(*from.clone(), Type::InfixExpr { .. })); + assert!(matches!(*to.clone(), Type::InfixExpr { .. })); + } + _ => panic!("unexpected length: {:?}", length), + } + assert!(matches!( + err, + TypeCheckError::FailingBinaryOp { op: BinaryTypeOperator::Modulo, lhs: 0, rhs: 0, .. } + )); + } else { + panic!("unexpected error: {:?}", monomorphization_error); + } +} + +#[test] +fn arithmetic_generics_checked_cast_indirect_zeros() { + let source = r#" + struct W {} + + fn foo(_x: W) -> W<(N - N) % (N - N)> { + W {} + } + + fn bar(_x: W) -> Field { + N + } + + fn main() { + let w_0: W<0> = W {}; + let w = foo(w_0); + let _ = bar(w); + } + "#; + + let errors = get_program_errors(source); + assert_eq!(errors.len(), 0); + + let monomorphization_error = get_monomorphization_error(source); + assert!(monomorphization_error.is_some()); + + // Expect a CheckedCast (0 % 0) failure + let monomorphization_error = monomorphization_error.unwrap(); + if let MonomorphizationError::UnknownArrayLength { ref length, ref err, location: _ } = + monomorphization_error + { + match length { + Type::CheckedCast { from, to } => { + assert!(matches!(*from.clone(), Type::InfixExpr { .. })); + assert!(matches!(*to.clone(), Type::InfixExpr { .. })); + } + _ => panic!("unexpected length: {:?}", length), + } + match err { + TypeCheckError::ModuloOnFields { lhs, rhs, .. } => { + assert_eq!(lhs.clone(), FieldElement::zero()); + assert_eq!(rhs.clone(), FieldElement::zero()); + } + _ => panic!("expected ModuloOnFields, but found: {:?}", err), + } + } else { + panic!("unexpected error: {:?}", monomorphization_error); + } +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests/imports.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests/imports.rs index 1da7f5ce0ce8..8598d8296e59 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests/imports.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests/imports.rs @@ -127,3 +127,30 @@ fn warns_on_re_export_of_item_with_less_visibility() { ) )); } + +#[test] +fn errors_if_using_alias_in_import() { + let src = r#" + mod foo { + pub type bar = i32; + } + + use foo::bar::baz; + + fn main() { + } + "#; + + let errors = get_program_errors(src); + assert_eq!(errors.len(), 1); + + let CompilationError::DefinitionError(DefCollectorErrorKind::PathResolutionError( + PathResolutionError::NotAModule { ident, kind }, + )) = &errors[0].0 + else { + panic!("Expected a 'not a module' error, got {:?}", errors[0].0); + }; + + assert_eq!(ident.to_string(), "bar"); + assert_eq!(*kind, "type alias"); +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests/traits.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests/traits.rs index 42900d094b8c..0adf5c90beaa 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests/traits.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests/traits.rs @@ -1,6 +1,6 @@ use crate::hir::def_collector::dc_crate::CompilationError; use crate::hir::resolution::errors::ResolverError; -use crate::tests::get_program_errors; +use crate::tests::{get_program_errors, get_program_with_maybe_parser_errors}; use super::assert_no_errors; @@ -390,3 +390,19 @@ fn trait_bounds_which_are_dependent_on_generic_types_are_resolved_correctly() { "#; assert_no_errors(src); } + +#[test] +fn does_not_crash_on_as_trait_path_with_empty_path() { + let src = r#" + struct Foo { + x: , + } + + fn main() {} + "#; + + let (_, _, errors) = get_program_with_maybe_parser_errors( + src, true, // allow parser errors + ); + assert!(!errors.is_empty()); +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests/unused_items.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests/unused_items.rs index 86f77fc397aa..5f9fc887b275 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests/unused_items.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests/unused_items.rs @@ -294,3 +294,23 @@ fn no_warning_on_self_in_trait_impl() { "#; assert_no_errors(src); } + +#[test] +fn resolves_trait_where_clause_in_the_correct_module() { + // This is a regression test for https://github.com/noir-lang/noir/issues/6479 + let src = r#" + mod foo { + pub trait Foo {} + } + + use foo::Foo; + + pub trait Bar + where + T: Foo, + {} + + fn main() {} + "#; + assert_no_errors(src); +} diff --git a/noir/noir-repo/compiler/wasm/package.json b/noir/noir-repo/compiler/wasm/package.json index bbb3b1ede01b..9b819ef64bb8 100644 --- a/noir/noir-repo/compiler/wasm/package.json +++ b/noir/noir-repo/compiler/wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.37.0", + "version": "0.38.0", "license": "(MIT OR Apache-2.0)", "main": "dist/main.js", "types": "./dist/types/src/index.d.cts", diff --git a/noir/noir-repo/compiler/wasm/src/compile.rs b/noir/noir-repo/compiler/wasm/src/compile.rs index 2e178739bc5b..e823f90add58 100644 --- a/noir/noir-repo/compiler/wasm/src/compile.rs +++ b/noir/noir-repo/compiler/wasm/src/compile.rs @@ -180,13 +180,13 @@ pub fn compile_program( .0; let optimized_program = nargo::ops::transform_program(compiled_program, expression_width); - // nargo::ops::check_program(&optimized_program).map_err(|errs| { - // CompileError::with_file_diagnostics( - // "Compiled program is not solvable", - // errs, - // &context.file_manager, - // ) - // })?; + nargo::ops::check_program(&optimized_program).map_err(|errs| { + CompileError::with_file_diagnostics( + "Compiled program is not solvable", + errs, + &context.file_manager, + ) + })?; let warnings = optimized_program.warnings.clone(); Ok(JsCompileProgramResult::new(optimized_program.into(), warnings)) diff --git a/noir/noir-repo/compiler/wasm/src/compile_new.rs b/noir/noir-repo/compiler/wasm/src/compile_new.rs index 3def12d9bfe4..ac2f79147b3e 100644 --- a/noir/noir-repo/compiler/wasm/src/compile_new.rs +++ b/noir/noir-repo/compiler/wasm/src/compile_new.rs @@ -118,13 +118,13 @@ impl CompilerContext { .0; let optimized_program = nargo::ops::transform_program(compiled_program, expression_width); - // nargo::ops::check_program(&optimized_program).map_err(|errs| { - // CompileError::with_file_diagnostics( - // "Compiled program is not solvable", - // errs, - // &self.context.file_manager, - // ) - // })?; + nargo::ops::check_program(&optimized_program).map_err(|errs| { + CompileError::with_file_diagnostics( + "Compiled program is not solvable", + errs, + &self.context.file_manager, + ) + })?; let warnings = optimized_program.warnings.clone(); Ok(JsCompileProgramResult::new(optimized_program.into(), warnings)) diff --git a/noir/noir-repo/cspell.json b/noir/noir-repo/cspell.json index 2577bf74548c..d8315c359102 100644 --- a/noir/noir-repo/cspell.json +++ b/noir/noir-repo/cspell.json @@ -38,7 +38,10 @@ "callsites", "callstack", "callstacks", + "canonicalization", "canonicalize", + "canonicalized", + "canonicalizing", "castable", "catmcgee", "Celo", @@ -173,6 +176,7 @@ "prettytable", "printstd", "proptest", + "proptests", "pseudocode", "pubkey", "quantile", @@ -199,8 +203,8 @@ "stdlib", "structs", "subexpression", - "subtrait", "subshell", + "subtrait", "subtyping", "supertrait", "supertraits", diff --git a/noir/noir-repo/deny.toml b/noir/noir-repo/deny.toml index 3518628ee44b..661c8095281e 100644 --- a/noir/noir-repo/deny.toml +++ b/noir/noir-repo/deny.toml @@ -6,7 +6,8 @@ version = 2 yanked = "warn" ignore = [ - "RUSTSEC-2020-0168", # mach unmaintained + "RUSTSEC-2024-0388", # derivative unmaintained + "RUSTSEC-2024-0384", # instant unmaintained "RUSTSEC-2020-0016", # net2 unmaintained ] @@ -49,12 +50,9 @@ allow = [ "ISC", "0BSD", "Unicode-DFS-2016", + "Unicode-3.0", "Unlicense", "Zlib", - # https://github.com/briansmith/ring/issues/902 - "LicenseRef-ring", - # https://github.com/rustls/webpki/blob/main/LICENSE ISC Style - "LicenseRef-rustls-webpki", # bitmaps 2.1.0, im 15.1.0 "MPL-2.0", # Boost Software License @@ -76,16 +74,6 @@ exceptions = [ { allow = ["CDDL-1.0"], name = "inferno" }, ] -[[licenses.clarify]] -name = "ring" -expression = "LicenseRef-ring" -license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] - -[[licenses.clarify]] -name = "rustls-webpki" -expression = "LicenseRef-rustls-webpki" -license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] - # This section is considered when running `cargo deny check sources`. # More documentation about the 'sources' section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html diff --git a/noir/noir-repo/docs/docs/how_to/how-to-oracles.md b/noir/noir-repo/docs/docs/how_to/how-to-oracles.md index dc49b192384e..4763b7788d62 100644 --- a/noir/noir-repo/docs/docs/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/docs/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,44 +141,38 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: ## Step 3 - Usage with Nargo -Using the [`nargo` CLI tool](../getting_started/noir_installation.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: +Using the [`nargo` CLI tool](../reference/nargo_commands.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: ```bash nargo test --oracle-resolver http://localhost:5555 @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.32.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.32.0/how_to/how-to-oracles.md index 2f69902062c7..94a89710e668 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.32.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.32.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -137,38 +135,32 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} - -interface ArrayForeignCallParam { - Array: string[], -} +export type ForeignCallSingle = string; -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: @@ -233,17 +225,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.33.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.33.0/how_to/how-to-oracles.md index 2f69902062c7..392dd8b452e7 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.33.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.33.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,38 +141,32 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip @@ -270,4 +272,4 @@ app.use(cors()) Hopefully by the end of this guide, you should be able to: - Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.34.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.34.0/how_to/how-to-oracles.md index 2f69902062c7..392dd8b452e7 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.34.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.34.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,38 +141,32 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip @@ -270,4 +272,4 @@ app.use(cors()) Hopefully by the end of this guide, you should be able to: - Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.35.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.35.0/how_to/how-to-oracles.md index 2f69902062c7..392dd8b452e7 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.35.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.35.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,38 +141,32 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip @@ -270,4 +272,4 @@ app.use(cors()) Hopefully by the end of this guide, you should be able to: - Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/how-to-oracles.md index dc49b192384e..08ce6ee54769 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,44 +141,38 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: ## Step 3 - Usage with Nargo -Using the [`nargo` CLI tool](../getting_started/noir_installation.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: +Using the [`nargo` CLI tool](../reference/nargo_commands.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: ```bash nargo test --oracle-resolver http://localhost:5555 @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip @@ -270,4 +272,4 @@ app.use(cors()) Hopefully by the end of this guide, you should be able to: - Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.37.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.37.0/how_to/how-to-oracles.md index dc49b192384e..08ce6ee54769 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.37.0/how_to/how-to-oracles.md +++ b/noir/noir-repo/docs/versioned_docs/version-v0.37.0/how_to/how-to-oracles.md @@ -18,8 +18,6 @@ This guide shows you how to use oracles in your Noir program. For the sake of cl - You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. - You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/code-snippets/how-to-oracles). - ## Rundown This guide has 3 major steps: @@ -99,6 +97,12 @@ fn main(input: [Field; 2]) { assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); } + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} ``` :::info @@ -137,44 +141,38 @@ app.listen(5555); Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: ```js -server.addMethod("resolve_function_call", async (params) => { - if params.function !== "getSqrt" { - throw Error("Unexpected foreign call") - }; - const values = params.inputs[0].Array.map((field) => { - return `${Math.sqrt(parseInt(field, 16))}`; - }); - return { values: [{ Array: values }] }; +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; }); ``` If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: ```js -interface SingleForeignCallParam { - Single: string, -} +export type ForeignCallSingle = string; -interface ArrayForeignCallParam { - Array: string[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; +export type ForeignCallArray = string[]; -interface ForeignCallResult { - values: ForeignCallParam[], -} +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; ``` -::: Multidimensional Arrays +:::info Multidimensional Arrays -If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in json as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. ::: ## Step 3 - Usage with Nargo -Using the [`nargo` CLI tool](../getting_started/noir_installation.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: +Using the [`nargo` CLI tool](../reference/nargo_commands.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: ```bash nargo test --oracle-resolver http://localhost:5555 @@ -233,17 +231,21 @@ const client = new JSONRPCClient((jsonRPCRequest) => { // declaring a function that takes the name of the foreign call (getSqrt) and the inputs const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - input[0].map((i) => i.toString("hex")), - ]); - return { values: oracleReturn }; + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; }; // the rest of your NoirJS code const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); +const { witness } = await noir.execute(input, foreignCallHandler); ``` :::tip @@ -270,4 +272,4 @@ app.use(cors()) Hopefully by the end of this guide, you should be able to: - Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/cspell.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/cspell.json new file mode 100644 index 000000000000..c60b0a597b10 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/cspell.json @@ -0,0 +1,5 @@ +{ + "words": [ + "Cryptdoku" + ] +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-oracle.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-oracle.md new file mode 100644 index 000000000000..821e1f95c04e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-oracle.md @@ -0,0 +1,57 @@ +--- +title: Oracles +description: This guide provides an in-depth understanding of how Oracles work in Noir programming. Learn how to use outside calculations in your programs, constrain oracles, and understand their uses and limitations. +keywords: + - Noir Programming + - Oracles + - JSON-RPC + - Foreign Call Handlers + - Constrained Functions + - Blockchain Programming +sidebar_position: 1 +--- + +If you've seen "The Matrix" you may recall "The Oracle" as Gloria Foster smoking cigarettes and baking cookies. While she appears to "know things", she is actually providing a calculation of a pre-determined future. Noir Oracles are similar, in a way. They don't calculate the future (yet), but they allow you to use outside calculations in your programs. + +![matrix oracle prediction](@site/static/img/memes/matrix_oracle.jpeg) + +A Noir program is usually self-contained. You can pass certain inputs to it, and it will generate a deterministic output for those inputs. But what if you wanted to defer some calculation to an outside process or source? + +Oracles are functions that provide this feature. + +## Use cases + +An example usage for Oracles is proving something on-chain. For example, proving that the ETH-USDC quote was below a certain target at a certain block time. Or even making more complex proofs like proving the ownership of an NFT as an anonymous login method. + +Another interesting use case is to defer expensive calculations to be made outside of the Noir program, and then constraining the result; similar to the use of [unconstrained functions](../noir/concepts//unconstrained.md). + +In short, anything that can be constrained in a Noir program but needs to be fetched from an external source is a great candidate to be used in oracles. + +## Constraining oracles + +Just like in The Matrix, Oracles are powerful. But with great power, comes great responsibility. Just because you're using them in a Noir program doesn't mean they're true. Noir has no superpowers. If you want to prove that Portugal won the Euro Cup 2016, you're still relying on potentially untrusted information. + +To give a concrete example, Alice wants to login to the [NounsDAO](https://nouns.wtf/) forum with her username "noir_nouner" by proving she owns a noun without revealing her ethereum address. Her Noir program could have an oracle call like this: + +```rust +#[oracle(getNoun)] +unconstrained fn get_noun(address: Field) -> Field +``` + +This oracle could naively resolve with the number of Nouns she possesses. However, it is useless as a trusted source, as the oracle could resolve to anything Alice wants. In order to make this oracle call actually useful, Alice would need to constrain the response from the oracle, by proving her address and the noun count belongs to the state tree of the contract. + +In short, **Oracles don't prove anything. Your Noir program does.** + +:::danger + +If you don't constrain the return of your oracle, you could be clearly opening an attack vector on your Noir program. Make double-triple sure that the return of an oracle call is constrained! + +::: + +## How to use Oracles + +On CLI, Nargo resolves oracles by making JSON RPC calls, which means it would require an RPC node to be running. + +In JavaScript, NoirJS accepts and resolves arbitrary call handlers (that is, not limited to JSON) as long as they match the expected types the developer defines. Refer to [Foreign Call Handler](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) to learn more about NoirJS's call handling. + +If you want to build using oracles, follow through to the [oracle guide](../how_to/how-to-oracles.md) for a simple example on how to do that. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-recursion.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-recursion.md new file mode 100644 index 000000000000..df8529ef4e02 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-recursion.md @@ -0,0 +1,176 @@ +--- +title: Recursive proofs +description: Explore the concept of recursive proofs in Zero-Knowledge programming. Understand how recursion works in Noir, a language for writing smart contracts on the EVM blockchain. Learn through practical examples like Alice and Bob's guessing game, Charlie's recursive merkle tree, and Daniel's reusable components. Discover how to use recursive proofs to optimize computational resources and improve efficiency. + +keywords: + [ + "Recursive Proofs", + "Zero-Knowledge Programming", + "Noir", + "EVM Blockchain", + "Smart Contracts", + "Recursion in Noir", + "Alice and Bob Guessing Game", + "Recursive Merkle Tree", + "Reusable Components", + "Optimizing Computational Resources", + "Improving Efficiency", + "Verification Key", + "Aggregation", + "Recursive zkSNARK schemes", + "PLONK", + "Proving and Verification Keys" + ] +sidebar_position: 1 +pagination_next: how_to/how-to-recursion +--- + +In programming, we tend to think of recursion as something calling itself. A classic example would be the calculation of the factorial of a number: + +```js +function factorial(n) { + if (n === 0 || n === 1) { + return 1; + } else { + return n * factorial(n - 1); + } +} +``` + +In this case, while `n` is not `1`, this function will keep calling itself until it hits the base case, bubbling up the result on the call stack: + +```md + Is `n` 1? <--------- + /\ / + / \ n = n -1 + / \ / + Yes No -------- +``` + +In Zero-Knowledge, recursion has some similarities. + +It is not a Noir function calling itself, but a proof being used as an input to another circuit. In short, you verify one proof *inside* another proof, returning the proof that both proofs are valid. + +This means that, given enough computational resources, you can prove the correctness of any arbitrary number of proofs in a single proof. This could be useful to design state channels (for which a common example would be [Bitcoin's Lightning Network](https://en.wikipedia.org/wiki/Lightning_Network)), to save on gas costs by settling one proof on-chain, or simply to make business logic less dependent on a consensus mechanism. + +## Examples + +Let us look at some of these examples + +### Alice and Bob - Guessing game + +Alice and Bob are friends, and they like guessing games. They want to play a guessing game online, but for that, they need a trusted third-party that knows both of their secrets and finishes the game once someone wins. + +So, they use zero-knowledge proofs. Alice tries to guess Bob's number, and Bob will generate a ZK proof stating whether she succeeded or failed. + +This ZK proof can go on a smart contract, revealing the winner and even giving prizes. However, this means every turn needs to be verified on-chain. This incurs some cost and waiting time that may simply make the game too expensive or time-consuming to be worth it. + +As a solution, Alice proposes the following: "what if Bob generates his proof, and instead of sending it on-chain, I verify it *within* my own proof before playing my own turn?". + +She can then generate a proof that she verified his proof, and so on. + +```md + Did you fail? <-------------------------- + / \ / + / \ n = n -1 + / \ / + Yes No / + | | / + | | / + | You win / + | / + | / +Generate proof of that / + + / + my own guess ---------------- +``` + +### Charlie - Recursive merkle tree + +Charlie is a concerned citizen, and wants to be sure his vote in an election is accounted for. He votes with a ZK proof, but he has no way of knowing that his ZK proof was included in the total vote count! + +If the vote collector puts all of the votes into a [Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree), everyone can prove the verification of two proofs within one proof, as such: + +```md + abcd + __________|______________ + | | + ab cd + _____|_____ ______|______ + | | | | + alice bob charlie daniel +``` + +Doing this recursively allows us to arrive on a final proof `abcd` which if true, verifies the correctness of all the votes. + +### Daniel - Reusable components + +Daniel has a big circuit and a big headache. A part of his circuit is a setup phase that finishes with some assertions that need to be made. But that section alone takes most of the proving time, and is largely independent of the rest of the circuit. + +He might find it more efficient to generate a proof for that setup phase separately, and verify that proof recursively in the actual business logic section of his circuit. This will allow for parallelization of both proofs, which results in a considerable speedup. + +## What params do I need + +As you can see in the [recursion reference](noir/standard_library/recursion.mdx), a simple recursive proof requires: + +- The proof to verify +- The Verification Key of the circuit that generated the proof +- A hash of this verification key, as it's needed for some backends +- The public inputs for the proof + +:::info + +Recursive zkSNARK schemes do not necessarily "verify a proof" in the sense that you expect a true or false to be spit out by the verifier. Rather an aggregation object is built over the public inputs. + +So, taking the example of Alice and Bob and their guessing game: + +- Alice makes her guess. Her proof is *not* recursive: it doesn't verify any proof within it! It's just a standard `assert(x != y)` circuit +- Bob verifies Alice's proof and makes his own guess. In this circuit, he doesn't exactly *prove* the verification of Alice's proof. Instead, he *aggregates* his proof to Alice's proof. The actual verification is done when the full proof is verified, for example when using `nargo verify` or through the verifier smart contract. + +We can imagine recursive proofs a [relay race](https://en.wikipedia.org/wiki/Relay_race). The first runner doesn't have to receive the baton from anyone else, as he/she already starts with it. But when his/her turn is over, the next runner needs to receive it, run a bit more, and pass it along. Even though every runner could theoretically verify the baton mid-run (why not? 🏃🔍), only at the end of the race does the referee verify that the whole race is valid. + +::: + +## Some architecture + +As with everything in computer science, there's no one-size-fits all. But there are some patterns that could help understanding and implementing them. To give three examples: + +### Adding some logic to a proof verification + +This would be an approach for something like our guessing game, where proofs are sent back and forth and are verified by each opponent. This circuit would be divided in two sections: + +- A `recursive verification` section, which would be just the call to `std::verify_proof`, and that would be skipped on the first move (since there's no proof to verify) +- A `guessing` section, which is basically the logic part where the actual guessing happens + +In such a situation, and assuming Alice is first, she would skip the first part and try to guess Bob's number. Bob would then verify her proof on the first section of his run, and try to guess Alice's number on the second part, and so on. + +### Aggregating proofs + +In some one-way interaction situations, recursion would allow for aggregation of simple proofs that don't need to be immediately verified on-chain or elsewhere. + +To give a practical example, a barman wouldn't need to verify a "proof-of-age" on-chain every time he serves alcohol to a customer. Instead, the architecture would comprise two circuits: + +- A `main`, non-recursive circuit with some logic +- A `recursive` circuit meant to verify two proofs in one proof + +The customer's proofs would be intermediate, and made on their phones, and the barman could just verify them locally. He would then aggregate them into a final proof sent on-chain (or elsewhere) at the end of the day. + +### Recursively verifying different circuits + +Nothing prevents you from verifying different circuits in a recursive proof, for example: + +- A `circuit1` circuit +- A `circuit2` circuit +- A `recursive` circuit + +In this example, a regulator could verify that taxes were paid for a specific purchase by aggregating both a `payer` circuit (proving that a purchase was made and taxes were paid), and a `receipt` circuit (proving that the payment was received) + +## How fast is it + +At the time of writing, verifying recursive proofs is surprisingly fast. This is because most of the time is spent on generating the verification key that will be used to generate the next proof. So you are able to cache the verification key and reuse it later. + +Currently, Noir JS packages don't expose the functionality of loading proving and verification keys, but that feature exists in the underlying `bb.js` package. + +## How can I try it + +Learn more about using recursion in Nargo and NoirJS in the [how-to guide](../how_to/how-to-recursion.md) and see a full example in [noir-examples](https://github.com/noir-lang/noir-examples). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-writing-noir.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-writing-noir.md new file mode 100644 index 000000000000..3ce4245dc452 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/explainers/explainer-writing-noir.md @@ -0,0 +1,177 @@ +--- +title: Thinking in Circuits +description: Considerations when writing Noir programs +keywords: [Noir, programming, rust] +tags: [Optimization] +sidebar_position: 0 +--- + + +This article intends to set you up with key concepts essential for writing more viable applications that use zero knowledge proofs, namely around efficient circuits. + +## Context - 'Efficient' is subjective + +When writing a web application for a performant computer with high-speed internet connection, writing efficient code sometimes is seen as an afterthought only if needed. Large multiplications running at the innermost of nested loops may not even be on a dev's radar. +When writing firmware for a battery-powered microcontroller, you think of cpu cycles as rations to keep within a product's power budget. + +> Code is written to create applications that perform specific tasks within specific constraints + +And these constraints differ depending on where the compiled code is execute. + +### The Ethereum Virtual Machine (EVM) + +In scenarios where extremely low gas costs are required for an Ethereum application to be viable/competitive, Ethereum smart contract developers get into what is colloquially known as: "*gas golfing*". Finding the lowest execution cost of their compiled code (EVM bytecode) to achieve a specific task. + +The equivalent optimization task when writing zk circuits is affectionately referred to as "*gate golfing*", finding the lowest gate representation of the compiled Noir code. + +### Coding for circuits - a paradigm shift + +In zero knowledge cryptography, code is compiled to "circuits" consisting of arithmetic gates, and gate count is the significant cost. Depending on the proving system this is linearly proportionate to proving time, and so from a product point this should be kept as low as possible. + +Whilst writing efficient code for web apps and Solidity has a few key differences, writing efficient circuits have a different set of considerations. It is a bit of a paradigm shift, like writing code for GPUs for the first time... + +For example, drawing a circle at (0, 0) of radius `r`: +- For a single CPU thread, +``` +for theta in 0..2*pi { + let x = r * cos(theta); + let y = r * sin(theta); + draw(x, y); +} // note: would do 0 - pi/2 and draw +ve/-ve x and y. +``` + +- For GPUs (simultaneous parallel calls with x, y across image), +``` +if (x^2 + y^2 = r^2) { + draw(x, y); +} +``` + +([Related](https://www.youtube.com/watch?v=-P28LKWTzrI)) + +Whilst this CPU -> GPU does not translate to circuits exactly, it is intended to exemplify the difference in intuition when coding for different machine capabilities/constraints. + +### Context Takeaway + +For those coming from a primarily web app background, this article will explain what you need to consider when writing circuits. Furthermore, for those experienced writing efficient machine code, prepare to shift what you think is efficient 😬 + +## Translating from Rust + +For some applications using Noir, existing code might be a convenient starting point to then proceed to optimize the gate count of. + +:::note +Many valuable functions and algorithms have been written in more established languages (C/C++), and converted to modern ones (like Rust). +::: + +Fortunately for Noir developers, when needing a particular function a Rust implementation can be readily compiled into Noir with some key changes. While the compiler does a decent amount of optimizations, it won't be able to change code that has been optimized for clock-cycles into code optimized for arithmetic gates. + +A few things to do when converting Rust code to Noir: +- `println!` is not a macro, use `println` function (same for `assert_eq`) +- No early `return` in function. Use constrain via assertion instead +- No passing by reference. Remove `&` operator to pass by value (copy) +- No boolean operators (`&&`, `||`). Use bitwise operators (`&`, `|`) with boolean values +- No type `usize`. Use types `u8`, `u32`, `u64`, ... +- `main` return must be public, `pub` +- No `const`, use `global` +- Noir's LSP is your friend, so error message should be informative enough to resolve syntax issues. + +## Writing efficient Noir for performant products + +The following points help refine our understanding over time. + +:::note +A Noir program makes a statement that can be verified. +::: + +It compiles to a structure that represents the calculation, and can assert results within the calculation at any stage (via the `constrain` keyword). + +A Noir program compiles to an Abstract Circuit Intermediate Representation which is: + - Conceptually a tree structure + - Leaves (inputs) are the `Field` type + - Nodes contain arithmetic operations to combine them (gates) + - The root is the final result (return value) + +:::tip +The command `nargo info` shows the programs circuit size, and is useful to compare the value of changes made. +You can dig deeper and use the `--print-acir` param to take a closer look at individual ACIR opcodes, and the proving backend to see its gate count (eg for barretenberg, `bb gates -b ./target/program.json`). +::: + +### Use the `Field` type + +Since the native type of values in circuits are `Field`s, using them for variables in Noir means less gates converting them under the hood. +Some things to be mindful of when using a Field type for a regular integer value: +- A variable of type `Field` can be cast `as` an integer type (eg `u8`, `u64`) + - Note: this retains only the bits of the integer type. Eg a Field value of 260 as a `u8` becomes 4 +- For Field types arithmetic operations meaningfully overflow/underflow, yet for integer types they are checked according to their size +- Comparisons and bitwise operations do not exist for `Field`s, cast to an appropriately sized integer type when you need to + +:::tip +Where possible, use `Field` type for values. Using smaller value types, and bit-packing strategies, will result in MORE gates +::: + + +### Use Arithmetic over non-arithmetic operations + +Since circuits are made of arithmetic gates, the cost of arithmetic operations tends to be one gate. Whereas for procedural code, they represent several clock cycles. + +Inversely, non-arithmetic operators are achieved with multiple gates, vs 1 clock cycle for procedural code. + +| (cost\op) | arithmetic
(`*`, `+`) | bit-wise ops
(eg `<`, `\|`, `>>`) | +| - | - | - | +| **cycles** | 10+ | 1 | +| **gates** | 1 | 10+ | + +Bit-wise operations (e.g. bit shifts `<<` and `>>`), albeit commonly used in general programming and especially for clock cycle optimizations, are on the contrary expensive in gates when performed within circuits. + +Translate away from bit shifts when writing constrained functions for the best performance. + +On the flip side, feel free to use bit shifts in unconstrained functions and tests if necessary, as they are executed outside of circuits and does not induce performance hits. + +### Use static over dynamic values + +Another general theme that manifests in different ways is that static reads are represented with less gates than dynamic ones. + +Reading from read-only memory (ROM) adds less gates than random-access memory (RAM), 2 vs ~3.25 due to the additional bounds checks. Arrays of fixed length (albeit used at a lower capacity), will generate less gates than dynamic storage. + +Related to this, if an index used to access an array is not known at compile time (ie unknown until run time), then ROM will be converted to RAM, expanding the gate count. + +:::tip +Use arrays and indices that are known at compile time where possible. +Using `assert_constant(i);` before an index, `i`, is used in an array will give a compile error if `i` is NOT known at compile time. +::: + +### Leverage unconstrained execution + +Constrained verification can leverage unconstrained execution, this is especially useful for operations that are represented by many gates. +Use an [unconstrained function](../noir/concepts/unconstrained.md) to perform gate-heavy calculations, then verify and constrain the result. + +Eg division generates more gates than multiplication, so calculating the quotient in an unconstrained function then constraining the product for the quotient and divisor (+ any remainder) equals the dividend will be more efficient. + +Use ` if is_unconstrained() { /`, to conditionally execute code if being called in an unconstrained vs constrained way. + +## Advanced + +Unless you're well into the depth of gate optimization, this advanced section can be ignored. + +### Combine arithmetic operations + +A Noir program can be honed further by combining arithmetic operators in a way that makes the most of each constraint of the backend proving system. This is in scenarios where the backend might not be doing this perfectly. + +Eg Barretenberg backend (current default for Noir) is a width-4 PLONKish constraint system +$ w_1*w_2*q_m + w_1*q_1 + w_2*q_2 + w_3*q_3 + w_4*q_4 + q_c = 0 $ + +Here we see there is one occurrence of witness 1 and 2 ($w_1$, $w_2$) being multiplied together, with addition to witnesses 1-4 ($w_1$ .. $w_4$) multiplied by 4 corresponding circuit constants ($q_1$ .. $q_4$) (plus a final circuit constant, $q_c$). + +Use `nargo info --print-acir`, to inspect the ACIR opcodes (and the proving system for gates), and it may present opportunities to amend the order of operations and reduce the number of constraints. + +#### Variable as witness vs expression + +If you've come this far and really know what you're doing at the equation level, a temporary lever (that will become unnecessary/useless over time) is: `std::as_witness`. This informs the compiler to save a variable as a witness not an expression. + +The compiler will mostly be correct and optimal, but this may help some near term edge cases that are yet to optimize. +Note: When used incorrectly it will create **less** efficient circuits (higher gate count). + +## References +- Guillaume's ["`Cryptdoku`" talk](https://www.youtube.com/watch?v=MrQyzuogxgg) (Jun'23) +- Tips from Tom, Jake and Zac. +- [Idiomatic Noir](https://www.vlayer.xyz/blog/idiomatic-noir-part-1-collections) blog post diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/noir_installation.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/noir_installation.md new file mode 100644 index 000000000000..a5c7e6492780 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/noir_installation.md @@ -0,0 +1,106 @@ +--- +title: Standalone Noir Installation +description: There are different ways to install Nargo, the one-stop shop and command-line tool for developing Noir programs. This guide explains how to specify which version to install when using noirup, and using WSL for windows. +keywords: [ + Installation + Nargo + Noirup + Binaries + Compiling from Source + WSL for Windows + macOS + Linux + Nix + Direnv + Uninstalling Nargo + ] +sidebar_position: 2 +--- + +Noirup is the endorsed method for installing Nargo, streamlining the process of fetching binaries or compiling from source. It supports a range of options to cater to your specific needs, from nightly builds and specific versions to compiling from various sources. + +### Installing Noirup + +First, ensure you have `noirup` installed: + +```sh +curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +``` + +### Fetching Binaries + +With `noirup`, you can easily switch between different Nargo versions, including nightly builds: + +- **Nightly Version**: Install the latest nightly build. + + ```sh + noirup --version nightly + ``` + +- **Specific Version**: Install a specific version of Nargo. + + ```sh + noirup --version + ``` + +### Compiling from Source + +`noirup` also enables compiling Nargo from various sources: + +- **From a Specific Branch**: Install from the latest commit on a branch. + + ```sh + noirup --branch + ``` + +- **From a Fork**: Install from the main branch of a fork. + + ```sh + noirup --repo + ``` + +- **From a Specific Branch in a Fork**: Install from a specific branch in a fork. + + ```sh + noirup --repo --branch + ``` + +- **From a Specific Pull Request**: Install from a specific PR. + + ```sh + noirup --pr + ``` + +- **From a Specific Commit**: Install from a specific commit. + + ```sh + noirup -C + ``` + +- **From Local Source**: Compile and install from a local directory. + + ```sh + noirup --path ./path/to/local/source + ``` + +## Installation on Windows + +The default backend for Noir (Barretenberg) doesn't provide Windows binaries at this time. For that reason, Noir cannot be installed natively. However, it is available by using Windows Subsystem for Linux (WSL). + +Step 1: Follow the instructions [here](https://learn.microsoft.com/en-us/windows/wsl/install) to install and run WSL. + +step 2: Follow the [Noirup instructions](#installing-noirup). + +## Setting up shell completions + +Once `nargo` is installed, you can [set up shell completions for it](setting_up_shell_completions). + +## Uninstalling Nargo + +If you installed Nargo with `noirup`, you can uninstall Nargo by removing the files in `~/.nargo`, `~/nargo`, and `~/noir_cache`. This ensures that all installed binaries, configurations, and cache related to Nargo are fully removed from your system. + +```bash +rm -r ~/.nargo +rm -r ~/nargo +rm -r ~/noir_cache +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/project_breakdown.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/project_breakdown.md new file mode 100644 index 000000000000..e442e377040f --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/project_breakdown.md @@ -0,0 +1,159 @@ +--- +title: Project Breakdown +description: + Learn about the anatomy of a Nargo project, including the purpose of the Prover TOML + file, and how to prove and verify your program. +keywords: + [Nargo, Nargo project, Prover.toml, proof verification, private asset transfer] +sidebar_position: 1 +--- + +This section breaks down our hello world program from the previous section. + +## Anatomy of a Nargo Project + +Upon creating a new project with `nargo new` and building the in/output files with `nargo check` +commands, you would get a minimal Nargo project of the following structure: + + - src + - Prover.toml + - Nargo.toml + +The source directory _src_ holds the source code for your Noir program. By default only a _main.nr_ +file will be generated within it. + +### Prover.toml + +_Prover.toml_ is used for specifying the input values for executing and proving the program. You can specify `toml` files with different names by using the `--prover-name` or `-p` flags, see the [Prover](#provertoml) section below. Optionally you may specify expected output values for prove-time checking as well. + +### Nargo.toml + +_Nargo.toml_ contains the environmental options of your project. It contains a "package" section and a "dependencies" section. + +Example Nargo.toml: + +```toml +[package] +name = "noir_starter" +type = "bin" +authors = ["Alice"] +compiler_version = "0.9.0" +description = "Getting started with Noir" +entry = "circuit/main.nr" +license = "MIT" + +[dependencies] +ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} +``` + +Nargo.toml for a [workspace](../noir/modules_packages_crates/workspaces.md) will look a bit different. For example: + +```toml +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" +``` + +#### Package section + +The package section defines a number of fields including: + +- `name` (**required**) - the name of the package +- `type` (**required**) - can be "bin", "lib", or "contract" to specify whether its a binary, library or Aztec contract +- `authors` (optional) - authors of the project +- `compiler_version` - specifies the version of the compiler to use. This is enforced by the compiler and follow's [Rust's versioning](https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field), so a `compiler_version = 0.18.0` will enforce Nargo version 0.18.0, `compiler_version = ^0.18.0` will enforce anything above 0.18.0 but below 0.19.0, etc. For more information, see how [Rust handles these operators](https://docs.rs/semver/latest/semver/enum.Op.html) +- `description` (optional) +- `entry` (optional) - a relative filepath to use as the entry point into your package (overrides the default of `src/lib.nr` or `src/main.nr`) +- `backend` (optional) +- `license` (optional) +- `expression_width` (optional) - Sets the default backend expression width. This field will override the default backend expression width specified by the Noir compiler (currently set to width 4). + +#### Dependencies section + +This is where you will specify any dependencies for your project. See the [Dependencies page](../noir/modules_packages_crates/dependencies.md) for more info. + +`./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or +verifier contract respectively. + +### main.nr + +The _main.nr_ file contains a `main` method, this method is the entry point into your Noir program. + +In our sample program, _main.nr_ looks like this: + +```rust +fn main(x : Field, y : Field) { + assert(x != y); +} +``` + +The parameters `x` and `y` can be seen as the API for the program and must be supplied by the prover. Since neither `x` nor `y` is marked as public, the verifier does not supply any inputs, when verifying the proof. + +The prover supplies the values for `x` and `y` in the _Prover.toml_ file. + +As for the program body, `assert` ensures that the condition to be satisfied (e.g. `x != y`) is constrained by the proof of the execution of said program (i.e. if the condition was not met, the verifier would reject the proof as an invalid proof). + +### Prover.toml + +The _Prover.toml_ file is a file which the prover uses to supply the inputs to the Noir program (both private and public). + +In our hello world program the _Prover.toml_ file looks like this: + +```toml +x = "1" +y = "2" +``` + +When the command `nargo execute` is executed, nargo will execute the Noir program using the inputs specified in `Prover.toml`, aborting if it finds that these do not satisfy the constraints defined by `main`. In this example, `x` and `y` must satisfy the inequality constraint `assert(x != y)`. + +If an output name is specified such as `nargo execute foo`, the witness generated by this execution will be written to `./target/foo.gz`. This can then be used to generate a proof of the execution. + +#### Arrays of Structs + +The following code shows how to pass an array of structs to a Noir program to generate a proof. + +```rust +// main.nr +struct Foo { + bar: Field, + baz: Field, +} + +fn main(foos: [Foo; 3]) -> pub Field { + foos[2].bar + foos[2].baz +} +``` + +Prover.toml: + +```toml +[[foos]] # foos[0] +bar = 0 +baz = 0 + +[[foos]] # foos[1] +bar = 0 +baz = 0 + +[[foos]] # foos[2] +bar = 1 +baz = 2 +``` + +#### Custom toml files + +You can specify a `toml` file with a different name to use for execution by using the `--prover-name` or `-p` flags. + +This command looks for proof inputs in the default **Prover.toml** and generates the witness and saves it at `./target/foo.gz`: + +```bash +nargo execute foo +``` + +This command looks for proof inputs in the custom **OtherProver.toml** and generates the witness and saves it at `./target/bar.gz`: + +```bash +nargo execute -p OtherProver bar +``` + +Now that you understand the concepts, you'll probably want some editor feedback while you are writing more complex code. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/quick_start.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/quick_start.md new file mode 100644 index 000000000000..c693624eb82e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/quick_start.md @@ -0,0 +1,126 @@ +--- +title: Quick Start +tags: [] +sidebar_position: 0 +--- + +## Installation + +### Noir + +The easiest way to develop with Noir is using Nargo the CLI tool. It provides you the ability to start new projects, compile, execute and test Noir programs from the terminal. + +You can use `noirup` the installation script to quickly install and update Nargo: + +```bash +curl -L noirup.dev | bash +noirup +``` + +Once installed, you can [set up shell completions for the `nargo` command](setting_up_shell_completions). + +### Proving backend + +After installing Noir, we install a proving backend to work with our Noir programs. + +Proving backends provide you the abilities to generate proofs, verify proofs, generate smart contracts and more for your Noir programs. + +Different proving backends provide different tools for working with Noir programs, here we will use the [Barretenberg proving backend](https://github.com/AztecProtocol/aztec-packages/tree/master/barretenberg) developed by Aztec Labs as an example. + +You can use the `bbup` installation script to quickly install and update BB, Barretenberg's CLI tool: + +You can find the full list of proving backends compatible with Noir in Awesome Noir. + +```bash +curl -L bbup.dev | bash +bbup +``` + +For the full list of proving backends compatible with Noir, visit [Awesome Noir](https://github.com/noir-lang/awesome-noir/?tab=readme-ov-file#proving-backends). + +## Nargo + +Nargo provides the ability to initiate and execute Noir projects. Let's initialize the traditional `hello_world`: + +```sh +nargo new hello_world +``` + +Two files will be created. + +- `src/main.nr` contains a simple boilerplate circuit +- `Nargo.toml` contains environmental options, such as name, author, dependencies, and others. + +Glancing at _main.nr_ , we can see that inputs in Noir are private by default, but can be labeled public using the keyword `pub`. This means that we will _assert_ that we know a value `x` which is different from `y` without revealing `x`: + +```rust +fn main(x : Field, y : pub Field) { + assert(x != y); +} +``` + +To learn more about private and public values, check the [Data Types](../noir/concepts/data_types/index.md) section. + +### Compiling and executing + +We can now use `nargo` to generate a _Prover.toml_ file, where our input values will be specified: + +```sh +cd hello_world +nargo check + +Let's feed some valid values into this file: + +```toml +x = "1" +y = "2" +``` + +We're now ready to compile and execute our Noir program. By default the `nargo execute` command will do both, and generate the `witness` that we need to feed to our proving backend: + +```sh +nargo execute +``` + +The witness corresponding to this execution will then be written to the file _./target/witness-name.gz_. + +The command also automatically compiles your Noir program if it was not already / was edited, which you may notice the compiled artifacts being written to the file _./target/hello_world.json_. + +With circuit compiled and witness generated, we're ready to prove. + +## Proving backend + +Different proving backends may provide different tools and commands to work with Noir programs. Here Barretenberg's `bb` CLI tool is used as an example: + +```sh +bb prove -b ./target/hello_world.json -w ./target/hello_world.gz -o ./target/proof +``` + +:::tip + +Naming can be confusing, specially as you pass them to the `bb` commands. If unsure, it won't hurt to delete the target folder and start anew to make sure you're using the most recent versions of the compiled circuit and witness. + +::: + +The proof is now generated in the `target` folder. To verify it we first need to compute the verification key from the compiled circuit, and use it to verify: + +```sh +bb write_vk -b ./target/hello_world.json -o ./target/vk +bb verify -k ./target/vk -p ./target/proof +``` + +:::info + +Notice that in order to verify a proof, the verifier knows nothing but the circuit, which is compiled and used to generate the verification key. This is obviously quite important: private inputs remain private. + +As for the public inputs, you may have noticed they haven't been specified. This behavior varies with each particular backend, but barretenberg typically attaches them to the proof. You can see them by parsing and splitting it. For example for if your public inputs are 32 bytes: + +```bash +head -c 32 ./target/proof | od -An -v -t x1 | tr -d $' \n' +``` + +::: + +Congratulations, you have now created and verified a proof for your very first Noir program! + +In the [next section](./project_breakdown.md), we will go into more detail on each step performed. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/setting_up_shell_completions.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/setting_up_shell_completions.md new file mode 100644 index 000000000000..0447321cbab0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/getting_started/setting_up_shell_completions.md @@ -0,0 +1,87 @@ +--- +title: Setting up shell completions +tags: [] +sidebar_position: 3 +--- + +The `nargo` binary provides a command to generate shell completions: + +```bash +nargo generate-completion-script [shell] +``` + +where `shell` must be one of `bash`, `elvish`, `fish`, `powershell`, and `zsh`. + +Below we explain how to install them in some popular shells. + +## Installing Zsh Completions + +If you have `oh-my-zsh` installed, you might already have a directory of automatically loading completion scripts — `.oh-my-zsh/completions`. +If not, first create it: + +```bash +mkdir -p ~/.oh-my-zsh/completions` +``` + +Then copy the completion script to that directory: + +```bash +nargo generate-completion-script zsh > ~/.oh-my-zsh/completions/_nargo +``` + +Without `oh-my-zsh`, you’ll need to add a path for completion scripts to your function path, and turn on completion script auto-loading. +First, add these lines to `~/.zshrc`: + +```bash +fpath=(~/.zsh/completions $fpath) +autoload -U compinit +compinit +``` + +Next, create a directory at `~/.zsh/completions`: + +```bash +mkdir -p ~/.zsh/completions +``` + +Then copy the completion script to that directory: + +```bash +nargo generate-completion-script zsh > ~/.zsh/completions/_nargo +``` + +## Installing Bash Completions + +If you have [bash-completion](https://github.com/scop/bash-completion) installed, you can just copy the completion script to the `/usr/local/etc/bash_completion.d` directory: + +```bash +nargo generate-completion-script bash > /usr/local/etc/bash_completion.d/nargo +``` + +Without `bash-completion`, you’ll need to source the completion script directly. +First create a directory such as `~/.bash_completions/`: + +```bash +mkdir ~/.bash_completions/ +``` + +Copy the completion script to that directory: + +```bash +nargo generate-completion-script bash > ~/.bash_completions/nargo.bash +``` + +Then add the following line to `~/.bash_profile` or `~/.bashrc`: + + +```bash +source ~/.bash_completions/nargo.bash +``` + +## Installing Fish Completions + +Copy the completion script to any path listed in the environment variable `$fish_completion_path`. For example, a typical location is `~/.config/fish/completions/nargo.fish`: + +```bash +nargo generate-completion-script fish > ~/.config/fish/completions/nargo.fish +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/_category_.json new file mode 100644 index 000000000000..23b560f610b8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/_category_.json new file mode 100644 index 000000000000..cc2cbb1c2533 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Debugging", + "position": 5, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_the_repl.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_the_repl.md new file mode 100644 index 000000000000..09e5bae68ad7 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_the_repl.md @@ -0,0 +1,164 @@ +--- +title: Using the REPL Debugger +description: + Step by step guide on how to debug your Noir circuits with the REPL Debugger. +keywords: + [ + Nargo, + Noir CLI, + Noir Debugger, + REPL, + ] +sidebar_position: 1 +--- + +#### Pre-requisites + +In order to use the REPL debugger, first you need to install recent enough versions of Nargo and vscode-noir. + +## Debugging a simple circuit + +Let's debug a simple circuit: + +```rust +fn main(x : Field, y : pub Field) { + assert(x != y); +} +``` + +To start the REPL debugger, using a terminal, go to a Noir circuit's home directory. Then: + +`$ nargo debug` + +You should be seeing this in your terminal: + +``` +[main] Starting debugger +At ~/noir-examples/recursion/circuits/main/src/main.nr:1:9 + 1 -> fn main(x : Field, y : pub Field) { + 2 assert(x != y); + 3 } +> +``` + +The debugger displays the current Noir code location, and it is now waiting for us to drive it. + +Let's first take a look at the available commands. For that we'll use the `help` command. + +``` +> help +Available commands: + + opcodes display ACIR opcodes + into step into to the next opcode + next step until a new source location is reached + out step until a new source location is reached + and the current stack frame is finished + break LOCATION:OpcodeLocation add a breakpoint at an opcode location + over step until a new source location is reached + without diving into function calls + restart restart the debugging session + delete LOCATION:OpcodeLocation delete breakpoint at an opcode location + witness show witness map + witness index:u32 display a single witness from the witness map + witness index:u32 value:String update a witness with the given value + memset index:usize value:String update a memory cell with the given + value + continue continue execution until the end of the + program + vars show variable values available at this point + in execution + stacktrace display the current stack trace + memory show memory (valid when executing unconstrained code) + step step to the next ACIR opcode + +Other commands: + + help Show this help message + quit Quit repl + +``` + +Some commands operate only for unconstrained functions, such as `memory` and `memset`. If you try to use them while execution is paused at an ACIR opcode, the debugger will simply inform you that you are not executing unconstrained code: + +``` +> memory +Unconstrained VM memory not available +> +``` + +Before continuing, we can take a look at the initial witness map: + +``` +> witness +_0 = 1 +_1 = 2 +> +``` + +Cool, since `x==1`, `y==2`, and we want to check that `x != y`, our circuit should succeed. At this point we could intervene and use the witness setter command to change one of the witnesses. Let's set `y=3`, then back to 2, so we don't affect the expected result: + +``` +> witness +_0 = 1 +_1 = 2 +> witness 1 3 +_1 = 3 +> witness +_0 = 1 +_1 = 3 +> witness 1 2 +_1 = 2 +> witness +_0 = 1 +_1 = 2 +> +``` + +Now we can inspect the current state of local variables. For that we use the `vars` command. + +``` +> vars +> +``` + +We currently have no vars in context, since we are at the entry point of the program. Let's use `next` to execute until the next point in the program. + +``` +> vars +> next +At ~/noir-examples/recursion/circuits/main/src/main.nr:1:20 + 1 -> fn main(x : Field, y : pub Field) { + 2 assert(x != y); + 3 } +> vars +x:Field = 0x01 +``` + +As a result of stepping, the variable `x`, whose initial value comes from the witness map, is now in context and returned by `vars`. + +``` +> next + 1 fn main(x : Field, y : pub Field) { + 2 -> assert(x != y); + 3 } +> vars +y:Field = 0x02 +x:Field = 0x01 +``` + +Stepping again we can finally see both variables and their values. And now we can see that the next assertion should succeed. + +Let's continue to the end: + +``` +> continue +(Continuing execution...) +Finished execution +> q +[main] Circuit witness successfully solved +``` + +Upon quitting the debugger after a solved circuit, the resulting circuit witness gets saved, equivalent to what would happen if we had run the same circuit with `nargo execute`. + +We just went through the basics of debugging using Noir REPL debugger. For a comprehensive reference, check out [the reference page](../../reference/debugger/debugger_repl.md). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_vs_code.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_vs_code.md new file mode 100644 index 000000000000..a5858c1a5eb5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/debugger/debugging_with_vs_code.md @@ -0,0 +1,68 @@ +--- +title: Using the VS Code Debugger +description: + Step by step guide on how to debug your Noir circuits with the VS Code Debugger configuration and features. +keywords: + [ + Nargo, + Noir CLI, + Noir Debugger, + VS Code, + IDE, + ] +sidebar_position: 0 +--- + +This guide will show you how to use VS Code with the vscode-noir extension to debug a Noir project. + +#### Pre-requisites + +- Nargo +- vscode-noir +- A Noir project with a `Nargo.toml`, `Prover.toml` and at least one Noir (`.nr`) containing an entry point function (typically `main`). + +## Running the debugger + +The easiest way to start debugging is to open the file you want to debug, and press `F5`. This will cause the debugger to launch, using your `Prover.toml` file as input. + +You should see something like this: + +![Debugger launched](@site/static/img/debugger/1-started.png) + +Let's inspect the state of the program. For that, we open VS Code's _Debug pane_. Look for this icon: + +![Debug pane icon](@site/static/img/debugger/2-icon.png) + +You will now see two categories of variables: Locals and Witness Map. + +![Debug pane expanded](@site/static/img/debugger/3-debug-pane.png) + +1. **Locals**: variables of your program. At this point in execution this section is empty, but as we step through the code it will get populated by `x`, `result`, `digest`, etc. + +2. **Witness map**: these are initially populated from your project's `Prover.toml` file. In this example, they will be used to populate `x` and `result` at the beginning of the `main` function. + +Most of the time you will probably be focusing mostly on locals, as they represent the high level state of your program. + +You might be interested in inspecting the witness map in case you are trying to solve a really low level issue in the compiler or runtime itself, so this concerns mostly advanced or niche users. + +Let's step through the program, by using the debugger buttons or their corresponding keyboard shortcuts. + +![Debugger buttons](@site/static/img/debugger/4-debugger-buttons.png) + +Now we can see in the variables pane that there's values for `digest`, `result` and `x`. + +![Inspecting locals](@site/static/img/debugger/5-assert.png) + +We can also inspect the values of variables by directly hovering on them on the code. + +![Hover locals](@site/static/img/debugger/6-hover.png) + +Let's set a break point at the `keccak256` function, so we can continue execution up to the point when it's first invoked without having to go one step at a time. + +We just need to click the to the right of the line number 18. Once the breakpoint appears, we can click the `continue` button or use its corresponding keyboard shortcut (`F5` by default). + +![Breakpoint](@site/static/img/debugger/7-break.png) + +Now we are debugging the `keccak256` function, notice the _Call Stack pane_ at the lower right. This lets us inspect the current call stack of our process. + +That covers most of the current debugger functionalities. Check out [the reference](../../reference/debugger/debugger_vscode.md) for more details on how to configure the debugger. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-oracles.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-oracles.md new file mode 100644 index 000000000000..08ce6ee54769 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-oracles.md @@ -0,0 +1,275 @@ +--- +title: How to use Oracles +description: Learn how to use oracles in your Noir program with examples in both Nargo and NoirJS. This guide also covers writing a JSON RPC server and providing custom foreign call handlers for NoirJS. +keywords: + - Noir Programming + - Oracles + - Nargo + - NoirJS + - JSON RPC Server + - Foreign Call Handlers +sidebar_position: 1 +--- + +This guide shows you how to use oracles in your Noir program. For the sake of clarity, it assumes that: + +- You have read the [explainer on Oracles](../explainers/explainer-oracle.md) and are comfortable with the concept. +- You have a Noir program to add oracles to. You can create one using the [vite-hardhat starter](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) as a boilerplate. +- You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. +- You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). + +## Rundown + +This guide has 3 major steps: + +1. How to modify our Noir program to make use of oracle calls as unconstrained functions +2. How to write a JSON RPC Server to resolve these oracle calls with Nargo +3. How to use them in Nargo and how to provide a custom resolver in NoirJS + +## Step 1 - Modify your Noir program + +An oracle is defined in a Noir program by defining two methods: + +- An unconstrained method - This tells the compiler that it is executing an [unconstrained functions](../noir/concepts//unconstrained.md). +- A decorated oracle method - This tells the compiler that this method is an RPC call. + +An example of an oracle that returns a `Field` would be: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(number: Field) -> Field { } + +unconstrained fn get_sqrt(number: Field) -> Field { + sqrt(number) +} +``` + +In this example, we're wrapping our oracle function in an unconstrained method, and decorating it with `oracle(getSqrt)`. We can then call the unconstrained function as we would call any other function: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); +} +``` + +In the next section, we will make this `getSqrt` (defined on the `sqrt` decorator) be a method of the RPC server Noir will use. + +:::danger + +As explained in the [Oracle Explainer](../explainers/explainer-oracle.md), this `main` function is unsafe unless you constrain its return value. For example: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); + assert(sqrt.pow_32(2) as u64 == input as u64); // <---- constrain the return of an oracle! +} +``` + +::: + +:::info + +Currently, oracles only work with single params or array params. For example: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt([Field; 2]) -> [Field; 2] { } +``` + +::: + +## Step 2 - Write an RPC server + +Brillig will call *one* RPC server. Most likely you will have to write your own, and you can do it in whatever language you prefer. In this guide, we will do it in Javascript. + +Let's use the above example of an oracle that consumes an array with two `Field` and returns their square roots: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(input: [Field; 2]) -> [Field; 2] { } + +unconstrained fn get_sqrt(input: [Field; 2]) -> [Field; 2] { + sqrt(input) +} + +fn main(input: [Field; 2]) { + let sqrt = get_sqrt(input); + assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); + assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); +} + +#[test] +fn test() { + let input = [4, 16]; + main(input); +} +``` + +:::info + +Why square root? + +In general, computing square roots is computationally more expensive than multiplications, which takes a toll when speaking about ZK applications. In this case, instead of calculating the square root in Noir, we are using our oracle to offload that computation to be made in plain. In our circuit we can simply multiply the two values. + +::: + +Now, we should write the correspondent RPC server, starting with the [default JSON-RPC 2.0 boilerplate](https://www.npmjs.com/package/json-rpc-2.0#example): + +```js +import { JSONRPCServer } from "json-rpc-2.0"; +import express from "express"; +import bodyParser from "body-parser"; + +const app = express(); +app.use(bodyParser.json()); + +const server = new JSONRPCServer(); +app.post("/", (req, res) => { + const jsonRPCRequest = req.body; + server.receive(jsonRPCRequest).then((jsonRPCResponse) => { + if (jsonRPCResponse) { + res.json(jsonRPCResponse); + } else { + res.sendStatus(204); + } + }); +}); + +app.listen(5555); +``` + +Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: + +```js +server.addMethod("resolve_foreign_call", async (params) => { + if (params[0].function !== "getSqrt") { + throw Error("Unexpected foreign call") + }; + const values = params[0].inputs[0].map((field) => { + return `${Math.sqrt(parseInt(field, 16))}`; + }); + return { values: [values] }; +}); +``` + +If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: + +```js +export type ForeignCallSingle = string; + +export type ForeignCallArray = string[]; + +export type ForeignCallResult = { + values: (ForeignCallSingle | ForeignCallArray)[]; +}; +``` + +:::info Multidimensional Arrays + +If the Oracle function is returning an array containing other arrays, such as `[['1','2],['3','4']]`, you need to provide the values in JSON as flattened values. In the previous example, it would be `['1', '2', '3', '4']`. In the Noir program, the Oracle signature can use a nested type, the flattened values will be automatically converted to the nested type. + +::: + +## Step 3 - Usage with Nargo + +Using the [`nargo` CLI tool](../reference/nargo_commands.md), you can use oracles in the `nargo test` and `nargo execute` commands by passing a value to `--oracle-resolver`. For example: + +```bash +nargo test --oracle-resolver http://localhost:5555 +``` + +This tells `nargo` to use your RPC Server URL whenever it finds an oracle decorator. + +## Step 4 - Usage with NoirJS + +In a JS environment, an RPC server is not strictly necessary, as you may want to resolve your oracles without needing any JSON call at all. NoirJS simply expects that you pass a callback function when you generate proofs, and that callback function can be anything. + +For example, if your Noir program expects the host machine to provide CPU pseudo-randomness, you could simply pass it as the `foreignCallHandler`. You don't strictly need to create an RPC server to serve pseudo-randomness, as you may as well get it directly in your app: + +```js +const foreignCallHandler = (name, inputs) => crypto.randomBytes(16) // etc + +await noir.execute(inputs, foreignCallHandler) +``` + +As one can see, in NoirJS, the [`foreignCallHandler`](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) function simply means "a callback function that returns a value of type [`ForeignCallOutput`](../reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md). It doesn't have to be an RPC call like in the case for Nargo. + +:::tip + +Does this mean you don't have to write an RPC server like in [Step #2](#step-2---write-an-rpc-server)? + +You don't technically have to, but then how would you run `nargo test`? To use both `Nargo` and `NoirJS` in your development flow, you will have to write a JSON RPC server. + +::: + +In this case, let's make `foreignCallHandler` call the JSON RPC Server we created in [Step #2](#step-2---write-an-rpc-server), by making it a JSON RPC Client. + +For example, using the same `getSqrt` program in [Step #1](#step-1---modify-your-noir-program) (comments in the code): + +```js +import { JSONRPCClient } from "json-rpc-2.0"; + +// declaring the JSONRPCClient +const client = new JSONRPCClient((jsonRPCRequest) => { +// hitting the same JSON RPC Server we coded above + return fetch("http://localhost:5555", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify(jsonRPCRequest), + }).then((response) => { + if (response.status === 200) { + return response + .json() + .then((jsonRPCResponse) => client.receive(jsonRPCResponse)); + } else if (jsonRPCRequest.id !== undefined) { + return Promise.reject(new Error(response.statusText)); + } + }); +}); + +// declaring a function that takes the name of the foreign call (getSqrt) and the inputs +const foreignCallHandler = async (name, input) => { + const inputs = input[0].map((i) => i.toString("hex")) + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request("resolve_foreign_call", [ + { + function: name, + inputs: [inputs] + }, + ]); + return [oracleReturn.values[0]]; +}; + +// the rest of your NoirJS code +const input = { input: [4, 16] }; +const { witness } = await noir.execute(input, foreignCallHandler); +``` + +:::tip + +If you're in a NoirJS environment running your RPC server together with a frontend app, you'll probably hit a familiar problem in full-stack development: requests being blocked by [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policy. For development only, you can simply install and use the [`cors` npm package](https://www.npmjs.com/package/cors) to get around the problem: + +```bash +yarn add cors +``` + +and use it as a middleware: + +```js +import cors from "cors"; + +const app = express(); +app.use(cors()) +``` + +::: + +## Conclusion + +Hopefully by the end of this guide, you should be able to: + +- Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. +- Provide custom foreign call handlers for NoirJS. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-recursion.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-recursion.md new file mode 100644 index 000000000000..fac79a9cf49c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-recursion.md @@ -0,0 +1,172 @@ +--- +title: How to use recursion on NoirJS +description: Learn how to implement recursion with NoirJS, a powerful tool for creating smart contracts on the EVM blockchain. This guide assumes familiarity with NoirJS, solidity verifiers, and the Barretenberg proving backend. Discover how to generate both final and intermediate proofs using `noir_js` and `bb.js`. +keywords: + [ + "NoirJS", + "EVM blockchain", + "smart contracts", + "recursion", + "solidity verifiers", + "Barretenberg backend", + "noir_js", + "intermediate proofs", + "final proofs", + "nargo compile", + "json import", + "recursive circuit", + "recursive app" + ] +sidebar_position: 1 +--- + +This guide shows you how to use recursive proofs in your NoirJS app. For the sake of clarity, it is assumed that: + +- You already have a NoirJS app. If you don't, please visit the [NoirJS tutorial](../tutorials/noirjs_app.md) and the [reference](../reference/NoirJS/noir_js/index.md). +- You are familiar with what are recursive proofs and you have read the [recursion explainer](../explainers/explainer-recursion.md) +- You already built a recursive circuit following [the reference](../noir/standard_library/recursion.mdx), and understand how it works. + +It is also assumed that you're not using `noir_wasm` for compilation, and instead you've used [`nargo compile`](../reference/nargo_commands.md) to generate the `json` you're now importing into your project. However, the guide should work just the same if you're using `noir_wasm`. + +:::info + +As you've read in the [explainer](../explainers/explainer-recursion.md), a recursive proof is an intermediate proof. This means that it doesn't necessarily generate the final step that makes it verifiable in a smart contract. However, it is easy to verify within another circuit. + +::: + +In a standard recursive app, you're also dealing with at least two circuits. For the purpose of this guide, we will assume the following: + +- `main`: a circuit of type `assert(x != y)`, where `main` is marked with a `#[recursive]` attribute. This attribute states that the backend should generate proofs that are friendly for verification within another circuit. +- `recursive`: a circuit that verifies `main` + +For a full example of how recursive proofs work, please refer to the [noir-examples](https://github.com/noir-lang/noir-examples) repository. We will *not* be using it as a reference for this guide. + +## Step 1: Setup + +In a common NoirJS app, you need to instantiate a backend with something like `const backend = new Backend(circuit)`. Then you feed it to the `noir_js` interface. + +For recursion, this doesn't happen, and the only need for `noir_js` is only to `execute` a circuit and get its witness and return value. Everything else is not interfaced, so it needs to happen on the `backend` object. + +It is also recommended that you instantiate the backend with as many threads as possible, to allow for maximum concurrency: + +```js +const backend = new Backend(circuit, { threads: 8 }) +``` + +:::tip +You can use the [`os.cpus()`](https://nodejs.org/api/os.html#oscpus) object in `nodejs` or [`navigator.hardwareConcurrency`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency) on the browser to make the most out of those glorious cpu cores +::: + +## Step 2: Generating the witness and the proof for `main` + +After instantiating the backend, you should also instantiate `noir_js`. We will use it to execute the circuit and get the witness. + +```js +const noir = new Noir(circuit) +const { witness } = noir.execute(input) +``` + +With this witness, you are now able to generate the intermediate proof for the main circuit: + +```js +const { proof, publicInputs } = await backend.generateProof(witness) +``` + +:::warning + +Always keep in mind what is actually happening on your development process, otherwise you'll quickly become confused about what circuit we are actually running and why! + +In this case, you can imagine that Alice (running the `main` circuit) is proving something to Bob (running the `recursive` circuit), and Bob is verifying her proof within his proof. + +With this in mind, it becomes clear that our intermediate proof is the one *meant to be verified within another circuit*, so it must be Alice's. Actually, the only final proof in this theoretical scenario would be the last one, sent on-chain. + +::: + +## Step 3 - Verification and proof artifacts + +Optionally, you are able to verify the intermediate proof: + +```js +const verified = await backend.verifyProof({ proof, publicInputs }) +``` + +This can be useful to make sure our intermediate proof was correctly generated. But the real goal is to do it within another circuit. For that, we need to generate recursive proof artifacts that will be passed to the circuit that is verifying the proof we just generated. Instead of passing the proof and verification key as a byte array, we pass them as fields which makes it cheaper to verify in a circuit: + +```js +const { proofAsFields, vkAsFields, vkHash } = await backend.generateRecursiveProofArtifacts( { publicInputs, proof }, publicInputsCount) +``` + +This call takes the public inputs and the proof, but also the public inputs count. While this is easily retrievable by simply counting the `publicInputs` length, the backend interface doesn't currently abstract it away. + +:::info + +The `proofAsFields` has a constant size `[Field; 93]` and verification keys in Barretenberg are always `[Field; 114]`. + +::: + +:::warning + +One common mistake is to forget *who* makes this call. + +In a situation where Alice is generating the `main` proof, if she generates the proof artifacts and sends them to Bob, which gladly takes them as true, this would mean Alice could prove anything! + +Instead, Bob needs to make sure *he* extracts the proof artifacts, using his own instance of the `main` circuit backend. This way, Alice has to provide a valid proof for the correct `main` circuit. + +::: + +## Step 4 - Recursive proof generation + +With the artifacts, generating a recursive proof is no different from a normal proof. You simply use the `backend` (with the recursive circuit) to generate it: + +```js +const recursiveInputs = { + verification_key: vkAsFields, // array of length 114 + proof: proofAsFields, // array of length 93 + size of public inputs + publicInputs: [mainInput.y], // using the example above, where `y` is the only public input + key_hash: vkHash, +} + +const { witness, returnValue } = noir.execute(recursiveInputs) // we're executing the recursive circuit now! +const { proof, publicInputs } = backend.generateProof(witness) +const verified = backend.verifyProof({ proof, publicInputs }) +``` + +You can obviously chain this proof into another proof. In fact, if you're using recursive proofs, you're probably interested of using them this way! + +:::tip + +Managing circuits and "who does what" can be confusing. To make sure your naming is consistent, you can keep them in an object. For example: + +```js +const circuits = { + main: mainJSON, + recursive: recursiveJSON +} +const backends = { + main: new BarretenbergBackend(circuits.main), + recursive: new BarretenbergBackend(circuits.recursive) +} +const noir_programs = { + main: new Noir(circuits.main), + recursive: new Noir(circuits.recursive) +} +``` + +This allows you to neatly call exactly the method you want without conflicting names: + +```js +// Alice runs this 👇 +const { witness: mainWitness } = await noir_programs.main.execute(input) +const proof = await backends.main.generateProof(mainWitness) + +// Bob runs this 👇 +const verified = await backends.main.verifyProof(proof) +const { proofAsFields, vkAsFields, vkHash } = await backends.main.generateRecursiveProofArtifacts( + proof, + numPublicInputs, +); +const { witness: recursiveWitness } = await noir_programs.recursive.execute(recursiveInputs) +const recursiveProof = await backends.recursive.generateProof(recursiveWitness); +``` + +::: diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-solidity-verifier.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-solidity-verifier.md new file mode 100644 index 000000000000..2cc0f8e57ce6 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/how-to-solidity-verifier.md @@ -0,0 +1,259 @@ +--- +title: Generate a Solidity Verifier +description: + Learn how to run the verifier as a smart contract on the blockchain. Compile a Solidity verifier + contract for your Noir program and deploy it on any EVM blockchain acting as a verifier smart + contract. Read more to find out +keywords: + [ + solidity verifier, + smart contract, + blockchain, + compiler, + plonk_vk.sol, + EVM blockchain, + verifying Noir programs, + proving backend, + Barretenberg, + ] +sidebar_position: 0 +pagination_next: tutorials/noirjs_app +--- + +Noir has the ability to generate a verifier contract in Solidity, which can be deployed in many EVM-compatible blockchains such as Ethereum. + +This allows for a powerful feature set, as one can make use of the conciseness and the privacy provided by Noir in an immutable ledger. Applications can range from simple P2P guessing games, to complex private DeFi interactions. + +This guide shows you how to generate a Solidity Verifier and deploy it on the [Remix IDE](https://remix.ethereum.org/). It is assumed that: + +- You are comfortable with the Solidity programming language and understand how contracts are deployed on the Ethereum network +- You have Noir installed and you have a Noir program. If you don't, [get started](../getting_started/quick_start.md) with Nargo and the example Hello Noir circuit +- You are comfortable navigating RemixIDE. If you aren't or you need a refresher, you can find some video tutorials [here](https://www.youtube.com/channel/UCjTUPyFEr2xDGN6Cg8nKDaA) that could help you. + +## Rundown + +Generating a Solidity Verifier contract is actually a one-command process. However, compiling it and deploying it can have some caveats. Here's the rundown of this guide: + +1. How to generate a solidity smart contract +2. How to compile the smart contract in the RemixIDE +3. How to deploy it to a testnet + +## Step 1 - Generate a contract + +This is by far the most straightforward step. Just run: + +```sh +nargo compile +``` + +This will compile your source code into a Noir build artifact to be stored in the `./target` directory, you can then generate the smart contract using the commands: + +```sh +# Here we pass the path to the newly generated Noir artifact. +bb write_vk -b ./target/.json +bb contract +``` + +replacing `` with the name of your Noir project. A new `contract` folder would then be generated in your project directory, containing the Solidity +file `contract.sol`. It can be deployed to any EVM blockchain acting as a verifier smart contract. + +You can find more information about `bb` and the default Noir proving backend on [this page](../getting_started/quick_start.md#proving-backend). + +:::info + +It is possible to generate verifier contracts of Noir programs for other smart contract platforms as long as the proving backend supplies an implementation. + +Barretenberg, the default proving backend for Nargo, supports generation of verifier contracts, for the time being these are only in Solidity. +::: + +## Step 2 - Compiling + +We will mostly skip the details of RemixIDE, as the UI can change from version to version. For now, we can just open +
Remix and create a blank workspace. + +![Create Workspace](@site/static/img/how-tos/solidity_verifier_1.png) + +We will create a new file to contain the contract Nargo generated, and copy-paste its content. + +:::warning + +You'll likely see a warning advising you to not trust pasted code. While it is an important warning, it is irrelevant in the context of this guide and can be ignored. We will not be deploying anywhere near a mainnet. + +::: + +To compile our the verifier, we can navigate to the compilation tab: + +![Compilation Tab](@site/static/img/how-tos/solidity_verifier_2.png) + +Remix should automatically match a suitable compiler version. However, hitting the "Compile" button will most likely generate a "Stack too deep" error: + +![Stack too deep](@site/static/img/how-tos/solidity_verifier_3.png) + +This is due to the verify function needing to put many variables on the stack, but enabling the optimizer resolves the issue. To do this, let's open the "Advanced Configurations" tab and enable optimization. The default 200 runs will suffice. + +:::info + +This time we will see a warning about an unused function parameter. This is expected, as the `verify` function doesn't use the `_proof` parameter inside a solidity block, it is loaded from calldata and used in assembly. + +::: + +![Compilation success](@site/static/img/how-tos/solidity_verifier_4.png) + +## Step 3 - Deploying + +At this point we should have a compiled contract ready to deploy. If we navigate to the deploy section in Remix, we will see many different environments we can deploy to. The steps to deploy on each environment would be out-of-scope for this guide, so we will just use the default Remix VM. + +Looking closely, we will notice that our "Solidity Verifier" is actually three contracts working together: + +- An `UltraVerificationKey` library which simply stores the verification key for our circuit. +- An abstract contract `BaseUltraVerifier` containing most of the verifying logic. +- A main `UltraVerifier` contract that inherits from the Base and uses the Key contract. + +Remix will take care of the dependencies for us so we can simply deploy the UltraVerifier contract by selecting it and hitting "deploy": + +![Deploying UltraVerifier](@site/static/img/how-tos/solidity_verifier_5.png) + +A contract will show up in the "Deployed Contracts" section, where we can retrieve the Verification Key Hash. This is particularly useful for double-checking that the deployer contract is the correct one. + +:::note + +Why "UltraVerifier"? + +To be precise, the Noir compiler (`nargo`) doesn't generate the verifier contract directly. It compiles the Noir code into an intermediate language (ACIR), which is then executed by the backend. So it is the backend that returns the verifier smart contract, not Noir. + +In this case, the Barretenberg Backend uses the UltraPlonk proving system, hence the "UltraVerifier" name. + +::: + +## Step 4 - Verifying + +To verify a proof using the Solidity verifier contract, we call the `verify` function in this extended contract: + +```solidity +function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool) +``` + +When using the default example in the [Hello Noir](../getting_started/quick_start.md) guide, the easiest way to confirm that the verifier contract is doing its job is by calling the `verify` function via remix with the required parameters. Note that the public inputs must be passed in separately to the rest of the proof so we must split the proof as returned from `bb`. + +First generate a proof with `bb` at the location `./proof` using the steps in [get started](../getting_started/quick_start.md), this proof is in a binary format but we want to convert it into a hex string to pass into Remix, this can be done with the + +```bash +# This value must be changed to match the number of public inputs (including return values!) in your program. +NUM_PUBLIC_INPUTS=1 +PUBLIC_INPUT_BYTES=32*NUM_PUBLIC_INPUTS +HEX_PUBLIC_INPUTS=$(head -c $PUBLIC_INPUT_BYTES ./proof | od -An -v -t x1 | tr -d $' \n') +HEX_PROOF=$(tail -c +$(($PUBLIC_INPUT_BYTES + 1)) ./proof | od -An -v -t x1 | tr -d $' \n') + +echo "Public inputs:" +echo $HEX_PUBLIC_INPUTS + +echo "Proof:" +echo "0x$HEX_PROOF" +``` + +Remix expects that the public inputs will be split into an array of `bytes32` values so `HEX_PUBLIC_INPUTS` needs to be split up into 32 byte chunks which are prefixed with `0x` accordingly. + +A programmatic example of how the `verify` function is called can be seen in the example zk voting application [here](https://github.com/noir-lang/noir-examples/blob/33e598c257e2402ea3a6b68dd4c5ad492bce1b0a/foundry-voting/src/zkVote.sol#L35): + +```solidity +function castVote(bytes calldata proof, uint proposalId, uint vote, bytes32 nullifierHash) public returns (bool) { + // ... + bytes32[] memory publicInputs = new bytes32[](4); + publicInputs[0] = merkleRoot; + publicInputs[1] = bytes32(proposalId); + publicInputs[2] = bytes32(vote); + publicInputs[3] = nullifierHash; + require(verifier.verify(proof, publicInputs), "Invalid proof"); +``` + +:::info[Return Values] + +A circuit doesn't have the concept of a return value. Return values are just syntactic sugar in Noir. + +Under the hood, the return value is passed as an input to the circuit and is checked at the end of the circuit program. + +For example, if you have Noir program like this: + +```rust +fn main( + // Public inputs + pubkey_x: pub Field, + pubkey_y: pub Field, + // Private inputs + priv_key: Field, +) -> pub Field +``` + +the `verify` function will expect the public inputs array (second function parameter) to be of length 3, the two inputs and the return value. + +Passing only two inputs will result in an error such as `PUBLIC_INPUT_COUNT_INVALID(3, 2)`. + +In this case, the inputs parameter to `verify` would be an array ordered as `[pubkey_x, pubkey_y, return`. + +::: + +:::tip[Structs] + +You can pass structs to the verifier contract. They will be flattened so that the array of inputs is 1-dimensional array. + +For example, consider the following program: + +```rust +struct Type1 { + val1: Field, + val2: Field, +} + +struct Nested { + t1: Type1, + is_true: bool, +} + +fn main(x: pub Field, nested: pub Nested, y: pub Field) { + //... +} +``` + +The order of these inputs would be flattened to: `[x, nested.t1.val1, nested.t1.val2, nested.is_true, y]` + +::: + +The other function you can call is our entrypoint `verify` function, as defined above. + +:::tip + +It's worth noticing that the `verify` function is actually a `view` function. A `view` function does not alter the blockchain state, so it doesn't need to be distributed (i.e. it will run only on the executing node), and therefore doesn't cost any gas. + +This can be particularly useful in some situations. If Alice generated a proof and wants Bob to verify its correctness, Bob doesn't need to run Nargo, NoirJS, or any Noir specific infrastructure. He can simply make a call to the blockchain with the proof and verify it is correct without paying any gas. + +It would be incorrect to say that a Noir proof verification costs any gas at all. However, most of the time the result of `verify` is used to modify state (for example, to update a balance, a game state, etc). In that case the whole network needs to execute it, which does incur gas costs (calldata and execution, but not storage). + +::: + +## A Note on EVM chains + +Noir proof verification requires the ecMul, ecAdd and ecPairing precompiles. Not all EVM chains support EC Pairings, notably some of the ZK-EVMs. This means that you won't be able to use the verifier contract in all of them. You can find an incomplete list of which EVM chains support these precompiles [here](https://www.evmdiff.com/features?feature=precompiles). + +For example, chains like `zkSync ERA` and `Polygon zkEVM` do not currently support these precompiles, so proof verification via Solidity verifier contracts won't work. Here's a quick list of EVM chains that have been tested and are known to work: + +- Optimism +- Arbitrum +- Polygon PoS +- Scroll +- Celo +- BSC +- Blast L2 +- Avalanche C-Chain +- Mode +- Linea +- Moonbeam + +If you test any other chains, please open a PR on this page to update the list. See [this doc](https://github.com/noir-lang/noir-starter/tree/main/with-foundry#testing-on-chain) for more info about testing verifier contracts on different EVM chains. + +## What's next + +Now that you know how to call a Noir Solidity Verifier on a smart contract using Remix, you should be comfortable with using it with some programmatic frameworks, such as [hardhat](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) and [foundry](https://github.com/noir-lang/noir-starter/tree/main/with-foundry). + +You can find other tools, examples, boilerplates and libraries in the [awesome-noir](https://github.com/noir-lang/awesome-noir) repository. + +You should also be ready to write and deploy your first NoirJS app and start generating proofs on websites, phones, and NodeJS environments! Head on to the [NoirJS tutorial](../tutorials/noirjs_app.md) to learn how to do that. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/merkle-proof.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/merkle-proof.mdx new file mode 100644 index 000000000000..0a128adb2de6 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/merkle-proof.mdx @@ -0,0 +1,48 @@ +--- +title: Prove Merkle Tree Membership +description: + Learn how to use merkle membership proof in Noir to prove that a given leaf is a member of a + merkle tree with a specified root, at a given index. +keywords: + [merkle proof, merkle membership proof, Noir, rust, hash function, Pedersen, sha256, merkle tree] +sidebar_position: 4 +--- + +Let's walk through an example of a merkle membership proof in Noir that proves that a given leaf is +in a merkle tree. + +```rust + +fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) { + let leaf = std::hash::hash_to_field(message.as_slice()); + let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); + assert(merkle_root == root); +} + +``` + +The message is hashed using `hash_to_field`. The specific hash function that is being used is chosen +by the backend. The only requirement is that this hash function can heuristically be used as a +random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen_hash` +instead. + +```rust +let leaf = std::hash::hash_to_field(message.as_slice()); +``` + +The leaf is then passed to a compute_merkle_root function with the root, index and hashpath. The returned root can then be asserted to be the same as the provided root. + +```rust +let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); +assert (merkle_root == root); +``` + +> **Note:** It is possible to re-implement the merkle tree implementation without standard library. +> However, for most usecases, it is enough. In general, the standard library will always opt to be +> as conservative as possible, while striking a balance with efficiency. + +An example, the merkle membership proof, only requires a hash function that has collision +resistance, hence a hash function like Pedersen is allowed, which in most cases is more efficient +than the even more conservative sha256. + +[View an example on the starter repo](https://github.com/noir-lang/noir-examples/blob/3ea09545cabfa464124ec2f3ea8e60c608abe6df/stealthdrop/circuits/src/main.nr#L20) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/using-devcontainers.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/using-devcontainers.mdx new file mode 100644 index 000000000000..727ec6ca6672 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/how_to/using-devcontainers.mdx @@ -0,0 +1,110 @@ +--- +title: Developer Containers and Codespaces +description: "Learn how to set up a devcontainer in your GitHub repository for a seamless coding experience with Codespaces. Follow our easy 8-step guide to create your own Noir environment without installing Nargo locally." +keywords: ["Devcontainer", "Codespaces", "GitHub", "Noir Environment", "Docker Image", "Development Environment", "Remote Coding", "GitHub Codespaces", "Noir Programming", "Nargo", "VSCode Extensions", "Noirup"] +sidebar_position: 1 +--- + +Adding a developer container configuration file to your Noir project is one of the easiest way to unlock coding in browser. + +## What's a devcontainer after all? + +A [Developer Container](https://containers.dev/) (devcontainer for short) is a Docker image that comes preloaded with tools, extensions, and other tools you need to quickly get started or continue a project, without having to install Nargo locally. Think of it as a development environment in a box. + +There are many advantages to this: + +- It's platform and architecture agnostic +- You don't need to have an IDE installed, or Nargo, or use a terminal at all +- It's safer for using on a public machine or public network + +One of the best ways of using devcontainers is... not using your machine at all, for maximum control, performance, and ease of use. +Enter Codespaces. + +## Codespaces + +If a devcontainer is just a Docker image, then what stops you from provisioning a `p3dn.24xlarge` AWS EC2 instance with 92 vCPUs and 768 GiB RAM and using it to prove your 10-gate SNARK proof? + +Nothing! Except perhaps the 30-40$ per hour it will cost you. + +The problem is that provisioning takes time, and I bet you don't want to see the AWS console every time you want to code something real quick. + +Fortunately, there's an easy and free way to get a decent remote machine ready and loaded in less than 2 minutes: Codespaces. [Codespaces is a Github feature](https://github.com/features/codespaces) that allows you to code in a remote machine by using devcontainers, and it's pretty cool: + +- You can start coding Noir in less than a minute +- It uses the resources of a remote machine, so you can code on your grandma's phone if needed be +- It makes it easy to share work with your frens +- It's fully reusable, you can stop and restart whenever you need to + +:::info + +Don't take out your wallet just yet. Free GitHub accounts get about [15-60 hours of coding](https://github.com/features/codespaces) for free per month, depending on the size of your provisioned machine. + +::: + +## Tell me it's _actually_ easy + +It is! + +Github comes with a default codespace and you can use it to code your own devcontainer. That's exactly what we will be doing in this guide. + + + +8 simple steps: + +#### 1. Create a new repository on GitHub. + +#### 2. Click "Start coding with Codespaces". This will use the default image. + +#### 3. Create a folder called `.devcontainer` in the root of your repository. + +#### 4. Create a Dockerfile in that folder, and paste the following code: + +```docker +FROM --platform=linux/amd64 node:lts-bookworm-slim +SHELL ["/bin/bash", "-c"] +RUN apt update && apt install -y curl bash git tar gzip libc++-dev +RUN curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +ENV PATH="/root/.nargo/bin:$PATH" +RUN noirup +ENTRYPOINT ["nargo"] +``` +#### 5. Create a file called `devcontainer.json` in the same folder, and paste the following code: + +```json +{ + "name": "Noir on Codespaces", + "build": { + "context": ".", + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": ["noir-lang.vscode-noir"] + } + } +} +``` +#### 6. Commit and push your changes + +This will pull the new image and build it, so it could take a minute or so + +#### 8. Done! +Just wait for the build to finish, and there's your easy Noir environment. + + +Refer to [noir-starter](https://github.com/noir-lang/noir-starter/) as an example of how devcontainers can be used together with codespaces. + + + +## How do I use it? + +Using the codespace is obviously much easier than setting it up. +Just navigate to your repository and click "Code" -> "Open with Codespaces". It should take a few seconds to load, and you're ready to go. + +:::info + +If you really like the experience, you can add a badge to your readme, links to existing codespaces, and more. +Check out the [official docs](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/setting-up-your-repository/facilitating-quick-creation-and-resumption-of-codespaces) for more info. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/index.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/index.mdx new file mode 100644 index 000000000000..a6bd306f91da --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/index.mdx @@ -0,0 +1,67 @@ +--- +title: Noir Lang +hide_title: true +description: + Learn about the public alpha release of Noir, a domain specific language heavily influenced by Rust that compiles to + an intermediate language which can be compiled to an arithmetic circuit or a rank-1 constraint system. +keywords: + [Noir, + Domain Specific Language, + Rust, + Intermediate Language, + Arithmetic Circuit, + Rank-1 Constraint System, + Ethereum Developers, + Protocol Developers, + Blockchain Developers, + Proving System, + Smart Contract Language] +sidebar_position: 0 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Noir Logo + +Noir is an open-source Domain-Specific Language for safe and seamless construction of privacy-preserving Zero-Knowledge programs, requiring no previous knowledge on the underlying mathematics or cryptography. + +ZK programs are programs that can generate short proofs of statements without revealing all inputs to the statements. You can read more about Zero-Knowledge Proofs [here](https://dev.to/spalladino/a-beginners-intro-to-coding-zero-knowledge-proofs-c56). + +## What's new about Noir? + +Noir works differently from most ZK languages by taking a two-pronged path. First, it compiles the program to an adaptable intermediate language known as ACIR. From there, depending on a given project's needs, ACIR can be further compiled into an arithmetic circuit for integration with the proving backend. + +:::info + +Noir is backend agnostic, which means it makes no assumptions on which proving backend powers the ZK proof. Being the language that powers [Aztec Contracts](https://docs.aztec.network/developers/contracts/main), it defaults to Aztec's Barretenberg proving backend. + +However, the ACIR output can be transformed to be compatible with other PLONK-based backends, or into a [rank-1 constraint system](https://www.rareskills.io/post/rank-1-constraint-system) suitable for backends such as Arkwork's Marlin. + +::: + +## Who is Noir for? + +Noir can be used both in complex cloud-based backends and in user's smartphones, requiring no knowledge on the underlying math or cryptography. From authorization systems that keep a password in the user's device, to complex on-chain verification of recursive proofs, Noir is designed to abstract away complexity without any significant overhead. Here are some examples of situations where Noir can be used: + + + + Noir Logo + + Aztec Contracts leverage Noir to allow for the storage and execution of private information. Writing an Aztec Contract is as easy as writing Noir, and Aztec developers can easily interact with the network storage and execution through the [Aztec.nr](https://docs.aztec.network/developers/contracts/main) library. + + + Soliditry Verifier Example + Noir can auto-generate Solidity verifier contracts that verify Noir proofs. This allows for non-interactive verification of proofs containing private information in an immutable system. This feature powers a multitude of use-case scenarios, from P2P chess tournaments, to [Aztec Layer-2 Blockchain](https://docs.aztec.network/) + + + Aztec Labs developed NoirJS, an easy interface to generate and verify Noir proofs in a Javascript environment. This allows for Noir to be used in webpages, mobile apps, games, and any other environment supporting JS execution in a standalone manner. + + + + +## Libraries + +Noir is meant to be easy to extend by simply importing Noir libraries just like in Rust. +The [awesome-noir repo](https://github.com/noir-lang/awesome-noir#libraries) is a collection of libraries developed by the Noir community. +Writing a new library is easy and makes code be composable and easy to reuse. See the section on [dependencies](noir/modules_packages_crates/dependencies.md) for more information. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/migration_notes.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/migration_notes.md new file mode 100644 index 000000000000..6bd740024e5b --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/migration_notes.md @@ -0,0 +1,105 @@ +--- +title: Migration notes +description: Read about migration notes from previous versions, which could solve problems while updating +keywords: [Noir, notes, migration, updating, upgrading] +--- + +Noir is in full-speed development. Things break fast, wild, and often. This page attempts to leave some notes on errors you might encounter when upgrading and how to resolve them until proper patches are built. + +### `backend encountered an error: libc++.so.1` + +Depending on your OS, you may encounter the following error when running `nargo prove` for the first time: + +```text +The backend encountered an error: "/home/codespace/.nargo/backends/acvm-backend-barretenberg/backend_binary: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory\n" +``` + +Install the `libc++-dev` library with: + +```bash +sudo apt install libc++-dev +``` + +## ≥0.19 + +### Enforcing `compiler_version` + +From this version on, the compiler will check for the `compiler_version` field in `Nargo.toml`, and will error if it doesn't match the current Nargo version in use. + +To update, please make sure this field in `Nargo.toml` matches the output of `nargo --version`. + +## ≥0.14 + +The index of the [for loops](noir/concepts/control_flow.md#loops) is now of type `u64` instead of `Field`. An example refactor would be: + +```rust +for i in 0..10 { + let i = i as Field; +} +``` + +## ≥v0.11.0 and Nargo backend + +From this version onwards, Nargo starts managing backends through the `nargo backend` command. Upgrading to the versions per usual steps might lead to: + +### `backend encountered an error` + +This is likely due to the existing locally installed version of proving backend (e.g. barretenberg) is incompatible with the version of Nargo in use. + +To fix the issue: + +1. Uninstall the existing backend + +```bash +nargo backend uninstall acvm-backend-barretenberg +``` + +You may replace _acvm-backend-barretenberg_ with the name of your backend listed in `nargo backend ls` or in ~/.nargo/backends. + +2. Reinstall a compatible version of the proving backend. + +If you are using the default barretenberg backend, simply run: + +``` +nargo prove +``` + +with your Noir program. + +This will trigger the download and installation of the latest version of barretenberg compatible with your Nargo in use. + +### `backend encountered an error: illegal instruction` + +On certain Intel-based systems, an `illegal instruction` error may arise due to incompatibility of barretenberg with certain CPU instructions. + +To fix the issue: + +1. Uninstall the existing backend + +```bash +nargo backend uninstall acvm-backend-barretenberg +``` + +You may replace _acvm-backend-barretenberg_ with the name of your backend listed in `nargo backend ls` or in ~/.nargo/backends. + +2. Reinstall a compatible version of the proving backend. + +If you are using the default barretenberg backend, simply run: + +``` +nargo backend install acvm-backend-barretenberg https://github.com/noir-lang/barretenberg-js-binary/raw/master/run-bb.tar.gz +``` + +This downloads and installs a specific bb.js based version of barretenberg binary from GitHub. + +The gzipped file is running [this bash script](https://github.com/noir-lang/barretenberg-js-binary/blob/master/run-bb-js.sh), where we need to gzip it as the Nargo currently expect the backend to be zipped up. + +Then run: + +``` +DESIRED_BINARY_VERSION=0.8.1 nargo info +``` + +This overrides the bb native binary with a bb.js node application instead, which should be compatible with most if not all hardware. This does come with the drawback of being generally slower than native binary. + +0.8.1 indicates bb.js version 0.8.1, so if you change that it will update to a different version or the default version in the script if none was supplied. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/_category_.json new file mode 100644 index 000000000000..7da08f8a8c5d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Concepts", + "position": 0, + "collapsible": true, + "collapsed": true +} \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/assert.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/assert.md new file mode 100644 index 000000000000..2132de42072d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/assert.md @@ -0,0 +1,78 @@ +--- +title: Assert Function +description: + Learn about the `assert` and `static_assert` functions in Noir, which can be used to explicitly + constrain the predicate or comparison expression that follows to be true, and what happens if + the expression is false at runtime or compile-time, respectively. +keywords: [Noir programming language, assert statement, predicate expression, comparison expression] +sidebar_position: 4 +--- + +Noir includes a special `assert` function which will explicitly constrain the predicate/comparison +expression that follows to be true. If this expression is false at runtime, the program will fail to +be proven. Example: + +```rust +fn main(x : Field, y : Field) { + assert(x == y); +} +``` + +> Assertions only work for predicate operations, such as `==`. If there's any ambiguity on the operation, the program will fail to compile. For example, it is unclear if `assert(x + y)` would check for `x + y == 0` or simply would return `true`. + +You can optionally provide a message to be logged when the assertion fails: + +```rust +assert(x == y, "x and y are not equal"); +``` + +Aside string literals, the optional message can be a format string or any other type supported as input for Noir's [print](../standard_library/logging.md) functions. This feature lets you incorporate runtime variables into your failed assertion logs: + +```rust +assert(x == y, f"Expected x == y, but got {x} == {y}"); +``` + +Using a variable as an assertion message directly: + +```rust +struct myStruct { + myField: Field +} + +let s = myStruct { myField: y }; +assert(s.myField == x, s); +``` + +There is also a special `static_assert` function that behaves like `assert`, +but that runs at compile-time. + +```rust +fn main(xs: [Field; 3]) { + let x = 2 + 2; + let y = 4; + static_assert(x == y, "expected 2 + 2 to equal 4"); + + // This passes since the length of `xs` is known at compile-time + static_assert(xs.len() == 3, "expected the input to have 3 elements"); +} +``` + +This function fails when passed a dynamic (run-time) argument: + +```rust +fn main(x : Field, y : Field) { + // this fails because `x` is not known at compile-time + static_assert(x == 2, "expected x to be known at compile-time and equal to 2"); + + let mut example_slice = &[]; + if y == 4 { + example_slice = example_slice.push_back(0); + } + + // This fails because the length of `example_slice` is not known at + // compile-time + let error_message = "expected an empty slice, known at compile-time"; + static_assert(example_slice.len() == 0, error_message); +} +``` + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comments.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comments.md new file mode 100644 index 000000000000..b51a85f5c949 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comments.md @@ -0,0 +1,33 @@ +--- +title: Comments +description: + Learn how to write comments in Noir programming language. A comment is a line of code that is + ignored by the compiler, but it can be read by programmers. Single-line and multi-line comments + are supported in Noir. +keywords: [Noir programming language, comments, single-line comments, multi-line comments] +sidebar_position: 10 +--- + +A comment is a line in your codebase which the compiler ignores, however it can be read by +programmers. + +Here is a single line comment: + +```rust +// This is a comment and is ignored +``` + +`//` is used to tell the compiler to ignore the rest of the line. + +Noir also supports multi-line block comments. Start a block comment with `/*` and end the block with `*/`. + +Noir does not natively support doc comments. You may be able to use [Rust doc comments](https://doc.rust-lang.org/reference/comments.html) in your code to leverage some Rust documentation build tools with Noir code. + +```rust +/* + This is a block comment describing a complex function. +*/ +fn main(x : Field, y : pub Field) { + assert(x != y); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comptime.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comptime.md new file mode 100644 index 000000000000..2ceb030c7e19 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/comptime.md @@ -0,0 +1,445 @@ +--- +title: Compile-time Code & Metaprogramming +description: Learn how to use metaprogramming in Noir to create macros or derive your own traits +keywords: [Noir, comptime, compile-time, metaprogramming, macros, quote, unquote] +sidebar_position: 15 +--- + +## Overview + +Metaprogramming in Noir is comprised of three parts: +1. `comptime` code +2. Quoting and unquoting +3. The metaprogramming API in `std::meta` + +Each of these are explained in more detail in the next sections but the wide picture is that +`comptime` allows us to write code which runs at compile-time. In this `comptime` code we +can quote and unquote snippets of the program, manipulate them, and insert them in other +parts of the program. Comptime functions which do this are said to be macros. Additionally, +there's a compile-time API of built-in types and functions provided by the compiler which allows +for greater analysis and modification of programs. + +--- + +## Comptime + +`comptime` is a new keyword in Noir which marks an item as executing or existing at compile-time. It can be used in several ways: + +- `comptime fn` to define functions which execute exclusively during compile-time. +- `comptime global` to define a global variable which is evaluated at compile-time. + - Unlike runtime globals, `comptime global`s can be mutable. +- `comptime { ... }` to execute a block of statements during compile-time. +- `comptime let` to define a variable whose value is evaluated at compile-time. +- `comptime for` to run a for loop at compile-time. Syntax sugar for `comptime { for .. }`. + +### Scoping + +Note that while in a `comptime` context, any runtime variables _local to the current function_ are never visible. + +### Evaluating + +Evaluation rules of `comptime` follows the normal unconstrained evaluation rules for other Noir code. There are a few things to note though: + +- Certain built-in functions may not be available, although more may be added over time. +- Evaluation order of global items is currently unspecified. For example, given the following two functions we can't guarantee +which `println` will execute first. The ordering of the two printouts will be arbitrary, but should be stable across multiple compilations with the same `nargo` version as long as the program is also unchanged. + +```rust +fn one() { + comptime { println("one"); } +} + +fn two() { + comptime { println("two"); } +} +``` + +- Since evaluation order is unspecified, care should be taken when using mutable globals so that they do not rely on a particular ordering. +For example, using globals to generate unique ids should be fine but relying on certain ids always being produced (especially after edits to the program) should be avoided. +- Although most ordering of globals is unspecified, two are: + - Dependencies of a crate will always be evaluated before the dependent crate. + - Any annotations on a function will be run before the function itself is resolved. This is to allow the annotation to modify the function if necessary. Note that if the + function itself was called at compile-time previously, it will already be resolved and cannot be modified. To prevent accidentally calling functions you wish to modify + at compile-time, it may be helpful to sort your `comptime` annotation functions into a different crate along with any dependencies they require. + +### Lowering + +When a `comptime` value is used in runtime code it must be lowered into a runtime value. This means replacing the expression with the literal that it evaluated to. For example, the code: + +```rust +struct Foo { array: [Field; 2], len: u32 } + +fn main() { + println(comptime { + let mut foo = std::mem::zeroed::(); + foo.array[0] = 4; + foo.len = 1; + foo + }); +} +``` + +will be converted to the following after `comptime` expressions are evaluated: + +```rust +struct Foo { array: [Field; 2], len: u32 } + +fn main() { + println(Foo { array: [4, 0], len: 1 }); +} +``` + +Not all types of values can be lowered. For example, `Type`s and `TypeDefinition`s (among other types) cannot be lowered at all. + +```rust +fn main() { + // There's nothing we could inline here to create a Type value at runtime + // let _ = get_type!(); +} + +comptime fn get_type() -> Type { ... } +``` + +--- + +## (Quasi) Quote + +Macros in Noir are `comptime` functions which return code as a value which is inserted into the call site when it is lowered there. +A code value in this case is of type `Quoted` and can be created by a `quote { ... }` expression. +More specifically, the code value `quote` creates is a token stream - a representation of source code as a series of words, numbers, string literals, or operators. +For example, the expression `quote { Hi "there reader"! }` would quote three tokens: the word "hi", the string "there reader", and an exclamation mark. +You'll note that snippets that would otherwise be invalid syntax can still be quoted. + +When a `Quoted` value is used in runtime code, it is lowered into a `quote { ... }` expression. Since this expression is only valid +in compile-time code however, we'd get an error if we tried this. Instead, we can use macro insertion to insert each token into the +program at that point, and parse it as an expression. To do this, we have to add a `!` after the function name returning the `Quoted` value. +If the value was created locally and there is no function returning it, `std::meta::unquote!(_)` can be used instead. +Calling such a function at compile-time without `!` will just return the `Quoted` value to be further manipulated. For example: + +```rust title="quote-example" showLineNumbers +comptime fn quote_one() -> Quoted { + quote { 1 } + } + + #[test] + fn returning_versus_macro_insertion() { + comptime { + // let _a: Quoted = quote { 1 }; + let _a: Quoted = quote_one(); + + // let _b: Field = 1; + let _b: Field = quote_one!(); + + // Since integers default to fields, if we + // want a different type we have to explicitly cast + // let _c: i32 = 1 as i32; + let _c: i32 = quote_one!() as i32; + } + } +``` +> Source code: noir_stdlib/src/meta/mod.nr#L120-L140 + + +For those familiar with quoting from other languages (primarily lisps), Noir's `quote` is actually a _quasiquote_. +This means we can escape the quoting by using the unquote operator to splice values in the middle of quoted code. + +## Unquote + +The unquote operator `$` is usable within a `quote` expression. +It takes a variable as an argument, evaluates the variable, and splices the resulting value into the quoted token stream at that point. For example, + +```rust +comptime { + let x = 1 + 2; + let y = quote { $x + 4 }; +} +``` + +The value of `y` above will be the token stream containing `3`, `+`, and `4`. We can also use this to combine `Quoted` values into larger token streams: + +```rust +comptime { + let x = quote { 1 + 2 }; + let y = quote { $x + 4 }; +} +``` + +The value of `y` above is now the token stream containing five tokens: `1 + 2 + 4`. + +Note that to unquote something, a variable name _must_ follow the `$` operator in a token stream. +If it is an expression (even a parenthesized one), it will do nothing. Most likely a parse error will be given when the macro is later unquoted. + +Unquoting can also be avoided by escaping the `$` with a backslash: + +``` +comptime { + let x = quote { 1 + 2 }; + + // y contains the four tokens: `$x + 4` + let y = quote { \$x + 4 }; +} +``` + +--- + +## Annotations + +Annotations provide a way to run a `comptime` function on an item in the program. +When you use an annotation, the function with the same name will be called with that item as an argument: + +```rust +#[my_struct_annotation] +struct Foo {} + +comptime fn my_struct_annotation(s: StructDefinition) { + println("Called my_struct_annotation!"); +} + +#[my_function_annotation] +fn foo() {} + +comptime fn my_function_annotation(f: FunctionDefinition) { + println("Called my_function_annotation!"); +} +``` + +Anything returned from one of these functions will be inserted at top-level along with the original item. +Note that expressions are not valid at top-level so you'll get an error trying to return `3` or similar just as if you tried to write a program containing `3; struct Foo {}`. +You can insert other top-level items such as trait impls, structs, or functions this way though. +For example, this is the mechanism used to insert additional trait implementations into the program when deriving a trait impl from a struct: + +```rust title="derive-field-count-example" showLineNumbers +trait FieldCount { + fn field_count() -> u32; + } + + #[derive_field_count] + struct Bar { + x: Field, + y: [Field; 2], + } + + comptime fn derive_field_count(s: StructDefinition) -> Quoted { + let typ = s.as_type(); + let field_count = s.fields().len(); + quote { + impl FieldCount for $typ { + fn field_count() -> u32 { + $field_count + } + } + } + } +``` +> Source code: noir_stdlib/src/meta/mod.nr#L142-L164 + + +### Calling annotations with additional arguments + +Arguments may optionally be given to annotations. +When this is done, these additional arguments are passed to the annotation function after the item argument. + +```rust title="annotation-arguments-example" showLineNumbers +#[assert_field_is_type(quote { i32 }.as_type())] + struct MyStruct { + my_field: i32, + } + + comptime fn assert_field_is_type(s: StructDefinition, typ: Type) { + // Assert the first field in `s` has type `typ` + let fields = s.fields(); + assert_eq(fields[0].1, typ); + } +``` +> Source code: noir_stdlib/src/meta/mod.nr#L166-L177 + + +We can also take any number of arguments by adding the `varargs` annotation: + +```rust title="annotation-varargs-example" showLineNumbers +#[assert_three_args(1, 2, 3)] + struct MyOtherStruct { + my_other_field: u32, + } + + #[varargs] + comptime fn assert_three_args(_s: StructDefinition, args: [Field]) { + assert_eq(args.len(), 3); + } +``` +> Source code: noir_stdlib/src/meta/mod.nr#L179-L189 + + +--- + +## Comptime API + +Although `comptime`, `quote`, and unquoting provide a flexible base for writing macros, +Noir's true metaprogramming ability comes from being able to interact with the compiler through a compile-time API. +This API can be accessed through built-in functions in `std::meta` as well as on methods of several `comptime` types. + +The following is an incomplete list of some `comptime` types along with some useful methods on them. You can see more in the standard library [Metaprogramming section](../standard_library/meta). + +- `Quoted`: A token stream +- `Type`: The type of a Noir type + - `fn implements(self, constraint: TraitConstraint) -> bool` + - Returns true if `self` implements the given trait constraint +- `Expr`: A syntactically valid expression. Can be used to recur on a program's parse tree to inspect how it is structured. + - Methods: + - `fn as_function_call(self) -> Option<(Expr, [Expr])>` + - If this is a function call expression, return `(function, arguments)` + - `fn as_block(self) -> Option<[Expr]>` + - If this is a block, return each statement in the block +- `FunctionDefinition`: A function definition + - Methods: + - `fn parameters(self) -> [(Quoted, Type)]` + - Returns a slice of `(name, type)` pairs for each parameter +- `StructDefinition`: A struct definition + - Methods: + - `fn as_type(self) -> Type` + - Returns this `StructDefinition` as a `Type`. Any generics are kept as-is + - `fn generics(self) -> [Quoted]` + - Return the name of each generic on this struct + - `fn fields(self) -> [(Quoted, Type)]` + - Return the name and type of each field +- `TraitConstraint`: A trait constraint such as `From` +- `TypedExpr`: A type-checked expression. +- `UnresolvedType`: A syntactic notation that refers to a Noir type that hasn't been resolved yet + +There are many more functions available by exploring the `std::meta` module and its submodules. +Using these methods is the key to writing powerful metaprogramming libraries. + +### `#[use_callers_scope]` + +Since certain functions such as `Quoted::as_type`, `Expression::as_type`, or `Quoted::as_trait_constraint` will attempt +to resolve their contents in a particular scope - it can be useful to change the scope they resolve in. By default +these functions will resolve in the current function's scope which is usually the attribute function they are called in. +If you're working on a library however, this may be a completely different module or crate to the item you're trying to +use the attribute on. If you want to be able to use `Quoted::as_type` to refer to types local to the caller's scope for +example, you can annotate your attribute function with `#[use_callers_scope]`. This will ensure your attribute, and any +closures it uses, can refer to anything in the caller's scope. `#[use_callers_scope]` also works recursively. So if both +your attribute function and a helper function it calls use it, then they can both refer to the same original caller. + +--- + +## Example: Derive + +Using all of the above, we can write a `derive` macro that behaves similarly to Rust's but is not built into the language. +From the user's perspective it will look like this: + +```rust +// Example usage +#[derive(Default, Eq, Ord)] +struct MyStruct { my_field: u32 } +``` + +To implement `derive` we'll have to create a `comptime` function that accepts +a variable amount of traits. + +```rust title="derive_example" showLineNumbers +// These are needed for the unconstrained hashmap we're using to store derive functions +use crate::collections::umap::UHashMap; +use crate::hash::BuildHasherDefault; +use crate::hash::poseidon2::Poseidon2Hasher; + +// A derive function is one that given a struct definition can +// create us a quoted trait impl from it. +pub type DeriveFunction = fn(StructDefinition) -> Quoted; + +// We'll keep a global HANDLERS map to keep track of the derive handler for each trait +comptime mut global HANDLERS: UHashMap> = + UHashMap::default(); + +// Given a struct and a slice of traits to derive, create trait impls for each. +// This function is as simple as iterating over the slice, checking if we have a trait +// handler registered for the given trait, calling it, and appending the result. +#[varargs] +pub comptime fn derive(s: StructDefinition, traits: [TraitDefinition]) -> Quoted { + let mut result = quote {}; + + for trait_to_derive in traits { + let handler = unsafe { HANDLERS.get(trait_to_derive) }; + assert(handler.is_some(), f"No derive function registered for `{trait_to_derive}`"); + + let trait_impl = handler.unwrap()(s); + result = quote { $result $trait_impl }; + } + + result +} +``` +> Source code: noir_stdlib/src/meta/mod.nr#L31-L64 + + +Registering a derive function could be done as follows: + +```rust title="derive_via" showLineNumbers +// To register a handler for a trait, just add it to our handlers map +pub comptime fn derive_via(t: TraitDefinition, f: DeriveFunction) { + HANDLERS.insert(t, f); +} +``` +> Source code: noir_stdlib/src/meta/mod.nr#L66-L73 + + +```rust title="big-derive-usage-example" showLineNumbers +// Finally, to register a handler we call the above function as an annotation + // with our handler function. + #[derive_via(derive_do_nothing)] + trait DoNothing { + fn do_nothing(self); + } + + comptime fn derive_do_nothing(s: StructDefinition) -> Quoted { + // This is simplified since we don't handle generics or where clauses! + // In a real example we'd likely also need to introduce each of + // `s.generics()` as well as a trait constraint for each generic + // to ensure they also implement the trait. + let typ = s.as_type(); + quote { + impl DoNothing for $typ { + fn do_nothing(self) { + // Traits can't tell us what to do + println("something"); + } + } + } + } + + // Since `DoNothing` is a simple trait which: + // 1. Only has one method + // 2. Does not have any generics on the trait itself + // We can use `std::meta::make_trait_impl` to help us out. + // This helper function will generate our impl for us along with any + // necessary where clauses and still provides a flexible interface + // for us to work on each field on the struct. + comptime fn derive_do_nothing_alt(s: StructDefinition) -> Quoted { + let trait_name = quote { DoNothing }; + let method_signature = quote { fn do_nothing(self) }; + + // Call `do_nothing` recursively on each field in the struct + let for_each_field = |field_name| quote { self.$field_name.do_nothing(); }; + + // Some traits like Eq want to join each field expression with something like `&`. + // We don't need that here + let join_fields_with = quote {}; + + // The body function is a spot to insert any extra setup/teardown needed. + // We'll insert our println here. Since we recur on each field, we should see + // one println for the struct itself, followed by a println for every field (recursively). + let body = |body| quote { + println("something"); + $body + }; + crate::meta::make_trait_impl( + s, + trait_name, + method_signature, + for_each_field, + join_fields_with, + body, + ) + } +``` +> Source code: noir_stdlib/src/meta/mod.nr#L191-L249 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/control_flow.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/control_flow.md new file mode 100644 index 000000000000..b365bb227282 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/control_flow.md @@ -0,0 +1,79 @@ +--- +title: Control Flow +description: + Learn how to use loops and if expressions in the Noir programming language. Discover the syntax + and examples for for loops and if-else statements. +keywords: [Noir programming language, loops, for loop, if-else statements, Rust syntax] +sidebar_position: 2 +--- + +## If Expressions + +Noir supports `if-else` statements. The syntax is most similar to Rust's where it is not required +for the statement's conditional to be surrounded by parentheses. + +```rust +let a = 0; +let mut x: u32 = 0; + +if a == 0 { + if a != 0 { + x = 6; + } else { + x = 2; + } +} else { + x = 5; + assert(x == 5); +} +assert(x == 2); +``` + +## Loops + +Noir has one kind of loop: the `for` loop. `for` loops allow you to repeat a block of code multiple +times. + +The following block of code between the braces is run 10 times. + +```rust +for i in 0..10 { + // do something +} +``` + +Alternatively, `start..=end` can be used for a range that is inclusive on both ends. + +The index for loops is of type `u64`. + +### Break and Continue + +In unconstrained code, `break` and `continue` are also allowed in `for` loops. These are only allowed +in unconstrained code since normal constrained code requires that Noir knows exactly how many iterations +a loop may have. `break` and `continue` can be used like so: + +```rust +for i in 0 .. 10 { + println("Iteration start") + + if i == 2 { + continue; + } + + if i == 5 { + break; + } + + println(i); +} +println("Loop end") +``` + +When used, `break` will end the current loop early and jump to the statement after the for loop. In the example +above, the `break` will stop the loop and jump to the `println("Loop end")`. + +`continue` will stop the current iteration of the loop, and jump to the start of the next iteration. In the example +above, `continue` will jump to `println("Iteration start")` when used. Note that the loop continues as normal after this. +The iteration variable `i` is still increased by one as normal when `continue` is used. + +`break` and `continue` cannot currently be used to jump out of more than a single loop at a time. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_bus.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_bus.mdx new file mode 100644 index 000000000000..e55e58622ce8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_bus.mdx @@ -0,0 +1,23 @@ +--- +title: Data Bus +sidebar_position: 13 +--- +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +The data bus is an optimization that the backend can use to make recursion more efficient. +In order to use it, you must define some inputs of the program entry points (usually the `main()` +function) with the `call_data` modifier, and the return values with the `return_data` modifier. +These modifiers are incompatible with `pub` and `mut` modifiers. + +## Example + +```rust +fn main(mut x: u32, y: call_data u32, z: call_data [u32;4] ) -> return_data u32 { + let a = z[x]; + a+y +} +``` + +As a result, both call_data and return_data will be treated as private inputs and encapsulated into a read-only array each, for the backend to process. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/_category_.json new file mode 100644 index 000000000000..5d694210bbf3 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/arrays.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/arrays.md new file mode 100644 index 000000000000..289145a8c4d1 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/arrays.md @@ -0,0 +1,276 @@ +--- +title: Arrays +description: + Dive into the Array data type in Noir. Grasp its methods, practical examples, and best practices for efficiently using Arrays in your Noir code. +keywords: + [ + noir, + array type, + methods, + examples, + indexing, + ] +sidebar_position: 4 +--- + +An array is one way of grouping together values into one compound type. Array types can be inferred +or explicitly specified via the syntax `[; ]`: + +```rust +fn main(x : Field, y : Field) { + let my_arr = [x, y]; + let your_arr: [Field; 2] = [x, y]; +} +``` + +Here, both `my_arr` and `your_arr` are instantiated as an array containing two `Field` elements. + +Array elements can be accessed using indexing: + +```rust +fn main() { + let a = [1, 2, 3, 4, 5]; + + let first = a[0]; + let second = a[1]; +} +``` + +All elements in an array must be of the same type (i.e. homogeneous). That is, an array cannot group +a `Field` value and a `u8` value together for example. + +You can write mutable arrays, like: + +```rust +fn main() { + let mut arr = [1, 2, 3, 4, 5]; + assert(arr[0] == 1); + + arr[0] = 42; + assert(arr[0] == 42); +} +``` + +You can instantiate a new array of a fixed size with the same value repeated for each element. The following example instantiates an array of length 32 where each element is of type Field and has the value 0. + +```rust +let array: [Field; 32] = [0; 32]; +``` + +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: + +```rust +let array: [Field; 32] = [0; 32]; +let sl = array.as_slice() +``` + +You can define multidimensional arrays: + +```rust +let array : [[Field; 2]; 2]; +let element = array[0][0]; +``` + +However, multidimensional slices are not supported. For example, the following code will error at compile time: + +```rust +let slice : [[Field]] = &[]; +``` + +## Types + +You can create arrays of primitive types or structs. There is not yet support for nested arrays +(arrays of arrays) or arrays of structs that contain arrays. + +## Methods + +For convenience, the STD provides some ready-to-use, common methods for arrays. +Each of these functions are located within the generic impl `impl [T; N] {`. +So anywhere `self` appears, it refers to the variable `self: [T; N]`. + +### len + +Returns the length of an array + +```rust +fn len(self) -> Field +``` + +example + +```rust +fn main() { + let array = [42, 42]; + assert(array.len() == 2); +} +``` + +### sort + +Returns a new sorted array. The original array remains untouched. Notice that this function will +only work for arrays of fields or integers, not for any arbitrary type. This is because the sorting +logic it uses internally is optimized specifically for these values. If you need a sort function to +sort any type, you should use the function `sort_via` described below. + +```rust +fn sort(self) -> [T; N] +``` + +example + +```rust +fn main() { + let arr = [42, 32]; + let sorted = arr.sort(); + assert(sorted == [32, 42]); +} +``` + +### sort_via + +Sorts the array with a custom comparison function. The ordering function must return true if the first argument should be sorted to be before the second argument or is equal to the second argument. + +Using this method with an operator like `<` that does not return `true` for equal values will result in an assertion failure for arrays with equal elements. + +```rust +fn sort_via(self, ordering: fn(T, T) -> bool) -> [T; N] +``` + +example + +```rust +fn main() { + let arr = [42, 32] + let sorted_ascending = arr.sort_via(|a, b| a <= b); + assert(sorted_ascending == [32, 42]); // verifies + + let sorted_descending = arr.sort_via(|a, b| a >= b); + assert(sorted_descending == [32, 42]); // does not verify +} +``` + +### map + +Applies a function to each element of the array, returning a new array containing the mapped elements. + +```rust +fn map(self, f: fn(T) -> U) -> [U; N] +``` + +example + +```rust +let a = [1, 2, 3]; +let b = a.map(|a| a * 2); // b is now [2, 4, 6] +``` + +### fold + +Applies a function to each element of the array, returning the final accumulated value. The first +parameter is the initial value. + +```rust +fn fold(self, mut accumulator: U, f: fn(U, T) -> U) -> U +``` + +This is a left fold, so the given function will be applied to the accumulator and first element of +the array, then the second, and so on. For a given call the expected result would be equivalent to: + +```rust +let a1 = [1]; +let a2 = [1, 2]; +let a3 = [1, 2, 3]; + +let f = |a, b| a - b; +a1.fold(10, f) //=> f(10, 1) +a2.fold(10, f) //=> f(f(10, 1), 2) +a3.fold(10, f) //=> f(f(f(10, 1), 2), 3) +``` + +example: + +```rust + +fn main() { + let arr = [2, 2, 2, 2, 2]; + let folded = arr.fold(0, |a, b| a + b); + assert(folded == 10); +} + +``` + +### reduce + +Same as fold, but uses the first element as the starting element. + +Requires `self` to be non-empty. + +```rust +fn reduce(self, f: fn(T, T) -> T) -> T +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 2]; + let reduced = arr.reduce(|a, b| a + b); + assert(reduced == 10); +} +``` + +### all + +Returns true if all the elements satisfy the given predicate + +```rust +fn all(self, predicate: fn(T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 2]; + let all = arr.all(|a| a == 2); + assert(all); +} +``` + +### any + +Returns true if any of the elements satisfy the given predicate + +```rust +fn any(self, predicate: fn(T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let arr = [2, 2, 2, 2, 5]; + let any = arr.any(|a| a == 5); + assert(any); +} +``` + +### as_str_unchecked + +Converts a byte array of type `[u8; N]` to a string. Note that this performs no UTF-8 validation - +the given array is interpreted as-is as a string. + +```rust +impl [u8; N] { + pub fn as_str_unchecked(self) -> str +} +``` + +example: + +```rust +fn main() { + let hi = [104, 105].as_str_unchecked(); + assert_eq(hi, "hi"); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/booleans.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/booleans.md new file mode 100644 index 000000000000..2507af710e71 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/booleans.md @@ -0,0 +1,28 @@ +--- +title: Booleans +description: + Delve into the Boolean data type in Noir. Understand its methods, practical examples, and best practices for using Booleans in your Noir programs. +keywords: + [ + noir, + boolean type, + methods, + examples, + logical operations, + ] +sidebar_position: 2 +--- + + +The `bool` type in Noir has two possible values: `true` and `false`: + +```rust +fn main() { + let t = true; + let f: bool = false; +} +``` + +The boolean type is most commonly used in conditionals like `if` expressions and `assert` +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/fields.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/fields.md new file mode 100644 index 000000000000..b9b56f7ecc3e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/fields.md @@ -0,0 +1,246 @@ +--- +title: Fields +description: + Dive deep into the Field data type in Noir. Understand its methods, practical examples, and best practices to effectively use Fields in your Noir programs. +keywords: + [ + noir, + field type, + methods, + examples, + best practices, + ] +sidebar_position: 0 +--- + +The field type corresponds to the native field type of the proving backend. + +The size of a Noir field depends on the elliptic curve's finite field for the proving backend +adopted. For example, a field would be a 254-bit integer when paired with the default backend that +spans the Grumpkin curve. + +Fields support integer arithmetic and are often used as the default numeric type in Noir: + +```rust +fn main(x : Field, y : Field) { + let z = x + y; +} +``` + +`x`, `y` and `z` are all private fields in this example. Using the `let` keyword we defined a new +private value `z` constrained to be equal to `x + y`. + +If proving efficiency is of priority, fields should be used as a default for solving problems. +Smaller integer types (e.g. `u64`) incur extra range constraints. + +## Methods + +After declaring a Field, you can use these common methods on it: + +### to_le_bits + +Transforms the field into an array of bits, Little Endian. + +```rust title="to_le_bits" showLineNumbers +pub fn to_le_bits(self: Self) -> [u1; N] {} +``` +> Source code: noir_stdlib/src/field/mod.nr#L32-L34 + + +example: + +```rust title="to_le_bits_example" showLineNumbers +fn test_to_le_bits() { + let field = 2; + let bits: [u1; 8] = field.to_le_bits(); + assert_eq(bits, [0, 1, 0, 0, 0, 0, 0, 0]); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L276-L282 + + + +### to_be_bits + +Transforms the field into an array of bits, Big Endian. + +```rust title="to_be_bits" showLineNumbers +pub fn to_be_bits(self: Self) -> [u1; N] {} +``` +> Source code: noir_stdlib/src/field/mod.nr#L48-L50 + + +example: + +```rust title="to_be_bits_example" showLineNumbers +fn test_to_be_bits() { + let field = 2; + let bits: [u1; 8] = field.to_be_bits(); + assert_eq(bits, [0, 0, 0, 0, 0, 0, 1, 0]); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L267-L273 + + + +### to_le_bytes + +Transforms into an array of bytes, Little Endian + +```rust title="to_le_bytes" showLineNumbers +pub fn to_le_bytes(self: Self) -> [u8; N] { +``` +> Source code: noir_stdlib/src/field/mod.nr#L61-L63 + + +example: + +```rust title="to_le_bytes_example" showLineNumbers +fn test_to_le_bytes() { + let field = 2; + let bytes: [u8; 8] = field.to_le_bytes(); + assert_eq(bytes, [2, 0, 0, 0, 0, 0, 0, 0]); + assert_eq(Field::from_le_bytes::<8>(bytes), field); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L295-L302 + + +### to_be_bytes + +Transforms into an array of bytes, Big Endian + +```rust title="to_be_bytes" showLineNumbers +pub fn to_be_bytes(self: Self) -> [u8; N] { +``` +> Source code: noir_stdlib/src/field/mod.nr#L94-L96 + + +example: + +```rust title="to_be_bytes_example" showLineNumbers +fn test_to_be_bytes() { + let field = 2; + let bytes: [u8; 8] = field.to_be_bytes(); + assert_eq(bytes, [0, 0, 0, 0, 0, 0, 0, 2]); + assert_eq(Field::from_be_bytes::<8>(bytes), field); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L285-L292 + + + +### to_le_radix + +Decomposes into an array over the specified base, Little Endian + +```rust title="to_le_radix" showLineNumbers +pub fn to_le_radix(self: Self, radix: u32) -> [u8; N] { + // Brillig does not need an immediate radix + if !crate::runtime::is_unconstrained() { + crate::assert_constant(radix); + } + self.__to_le_radix(radix) + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L118-L126 + + + +example: + +```rust title="to_le_radix_example" showLineNumbers +fn test_to_le_radix() { + let field = 2; + let bytes: [u8; 8] = field.to_le_radix(256); + assert_eq(bytes, [2, 0, 0, 0, 0, 0, 0, 0]); + assert_eq(Field::from_le_bytes::<8>(bytes), field); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L315-L322 + + + +### to_be_radix + +Decomposes into an array over the specified base, Big Endian + +```rust title="to_be_radix" showLineNumbers +pub fn to_be_radix(self: Self, radix: u32) -> [u8; N] { + // Brillig does not need an immediate radix + if !crate::runtime::is_unconstrained() { + crate::assert_constant(radix); + } + self.__to_be_radix(radix) + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L128-L136 + + +example: + +```rust title="to_be_radix_example" showLineNumbers +fn test_to_be_radix() { + let field = 2; + let bytes: [u8; 8] = field.to_be_radix(256); + assert_eq(bytes, [0, 0, 0, 0, 0, 0, 0, 2]); + assert_eq(Field::from_be_bytes::<8>(bytes), field); + } +``` +> Source code: noir_stdlib/src/field/mod.nr#L305-L312 + + + +### pow_32 + +Returns the value to the power of the specified exponent + +```rust +fn pow_32(self, exponent: Field) -> Field +``` + +example: + +```rust +fn main() { + let field = 2 + let pow = field.pow_32(4); + assert(pow == 16); +} +``` + +### assert_max_bit_size + +Adds a constraint to specify that the field can be represented with `bit_size` number of bits + +```rust title="assert_max_bit_size" showLineNumbers +pub fn assert_max_bit_size(self) { +``` +> Source code: noir_stdlib/src/field/mod.nr#L10-L12 + + +example: + +```rust +fn main() { + let field = 2 + field.assert_max_bit_size(32); +} +``` + +### sgn0 + +Parity of (prime) Field element, i.e. sgn0(x mod p) = 0 if x ∈ \{0, ..., p-1\} is even, otherwise sgn0(x mod p) = 1. + +```rust +fn sgn0(self) -> u1 +``` + + +### lt + +Returns true if the field is less than the other field + +```rust +pub fn lt(self, another: Field) -> bool +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/function_types.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/function_types.md new file mode 100644 index 000000000000..f6121af17e24 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/function_types.md @@ -0,0 +1,26 @@ +--- +title: Function types +sidebar_position: 10 +--- + +Noir supports higher-order functions. The syntax for a function type is as follows: + +```rust +fn(arg1_type, arg2_type, ...) -> return_type +``` + +Example: + +```rust +fn assert_returns_100(f: fn() -> Field) { // f takes no args and returns a Field + assert(f() == 100); +} + +fn main() { + assert_returns_100(|| 100); // ok + assert_returns_100(|| 150); // fails +} +``` + +A function type also has an optional capture environment - this is necessary to support closures. +See [Lambdas](../lambdas.md) for more details. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/index.md new file mode 100644 index 000000000000..0f2db2b2d753 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/index.md @@ -0,0 +1,126 @@ +--- +title: Data Types +description: + Get a clear understanding of the two categories of Noir data types - primitive types and compound + types. Learn about their characteristics, differences, and how to use them in your Noir + programming. +keywords: + [ + noir, + data types, + primitive types, + compound types, + private types, + public types, + ] +--- + +Every value in Noir has a type, which determines which operations are valid for it. + +All values in Noir are fundamentally composed of `Field` elements. For a more approachable +developing experience, abstractions are added on top to introduce different data types in Noir. + +Noir has two category of data types: primitive types (e.g. `Field`, integers, `bool`) and compound +types that group primitive types (e.g. arrays, tuples, structs). Each value can either be private or +public. + +## Private & Public Types + +A **private value** is known only to the Prover, while a **public value** is known by both the +Prover and Verifier. Mark values as `private` when the value should only be known to the prover. All +primitive types (including individual fields of compound types) in Noir are private by default, and +can be marked public when certain values are intended to be revealed to the Verifier. + +> **Note:** For public values defined in Noir programs paired with smart contract verifiers, once +> the proofs are verified on-chain the values can be considered known to everyone that has access to +> that blockchain. + +Public data types are treated no differently to private types apart from the fact that their values +will be revealed in proofs generated. Simply changing the value of a public type will not change the +circuit (where the same goes for changing values of private types as well). + +_Private values_ are also referred to as _witnesses_ sometimes. + +> **Note:** The terms private and public when applied to a type (e.g. `pub Field`) have a different +> meaning than when applied to a function (e.g. `pub fn foo() {}`). +> +> The former is a visibility modifier for the Prover to interpret if a value should be made known to +> the Verifier, while the latter is a visibility modifier for the compiler to interpret if a +> function should be made accessible to external Noir programs like in other languages. + +### pub Modifier + +All data types in Noir are private by default. Types are explicitly declared as public using the +`pub` modifier: + +```rust +fn main(x : Field, y : pub Field) -> pub Field { + x + y +} +``` + +In this example, `x` is **private** while `y` and `x + y` (the return value) are **public**. Note +that visibility is handled **per variable**, so it is perfectly valid to have one input that is +private and another that is public. + +> **Note:** Public types can only be declared through parameters on `main`. + +## Type Aliases + +A type alias is a new name for an existing type. Type aliases are declared with the keyword `type`: + +```rust +type Id = u8; + +fn main() { + let id: Id = 1; + let zero: u8 = 0; + assert(zero + 1 == id); +} +``` + +Type aliases can also be used with [generics](../generics.md): + +```rust +type Id = Size; + +fn main() { + let id: Id = 1; + let zero: u32 = 0; + assert(zero + 1 == id); +} +``` + +Type aliases can even refer to other aliases. An error will be issued if they form a cycle: + +```rust +// Ok! +type A = B; +type B = Field; + +type Bad1 = Bad2; + +// error: Dependency cycle found +type Bad2 = Bad1; +// ^^^^^^^^^^^ 'Bad2' recursively depends on itself: Bad2 -> Bad1 -> Bad2 +``` + +By default, like functions, type aliases are private to the module they exist in. You can use `pub` +to make the type alias public or `pub(crate)` to make it public to just its crate: + +```rust +// This type alias is now public +pub type Id = u8; +``` + +## Wildcard Type +Noir can usually infer the type of the variable from the context, so specifying the type of a variable is only required when it cannot be inferred. However, specifying a complex type can be tedious, especially when it has multiple generic arguments. Often some of the generic types can be inferred from the context, and Noir only needs a hint to properly infer the other types. We can partially specify a variable's type by using `_` as a marker, indicating where we still want the compiler to infer the type. + +```rust +let a: [_; 4] = foo(b); +``` + + +### BigInt + +You can achieve BigInt functionality using the [Noir BigInt](https://github.com/shuklaayush/noir-bigint) library. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/integers.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/integers.md new file mode 100644 index 000000000000..a1d59bf31662 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/integers.md @@ -0,0 +1,156 @@ +--- +title: Integers +description: Explore the Integer data type in Noir. Learn about its methods, see real-world examples, and grasp how to efficiently use Integers in your Noir code. +keywords: [noir, integer types, methods, examples, arithmetic] +sidebar_position: 1 +--- + +An integer type is a range constrained field type. +The Noir frontend supports both unsigned and signed integer types. +The allowed sizes are 1, 8, 16, 32 and 64 bits. + +:::info + +When an integer is defined in Noir without a specific type, it will default to `Field`. + +The one exception is for loop indices which default to `u64` since comparisons on `Field`s are not possible. + +::: + +## Unsigned Integers + +An unsigned integer type is specified first with the letter `u` (indicating its unsigned nature) followed by its bit size (e.g. `8`): + +```rust +fn main() { + let x: u8 = 1; + let y: u8 = 1; + let z = x + y; + assert (z == 2); +} +``` + +The bit size determines the maximum value the integer type can store. For example, a `u8` variable can store a value in the range of 0 to 255 (i.e. $\\2^{8}-1\\$). + +## Signed Integers + +A signed integer type is specified first with the letter `i` (which stands for integer) followed by its bit size (e.g. `8`): + +```rust +fn main() { + let x: i8 = -1; + let y: i8 = -1; + let z = x + y; + assert (z == -2); +} +``` + +The bit size determines the maximum and minimum range of value the integer type can store. For example, an `i8` variable can store a value in the range of -128 to 127 (i.e. $\\-2^{7}\\$ to $\\2^{7}-1\\$). + +## 128 bits Unsigned Integers + +The built-in structure `U128` allows you to use 128-bit unsigned integers almost like a native integer type. However, there are some differences to keep in mind: +- You cannot cast between a native integer and `U128` +- There is a higher performance cost when using `U128`, compared to a native type. + +Conversion between unsigned integer types and U128 are done through the use of `from_integer` and `to_integer` functions. `from_integer` also accepts the `Field` type as input. + +```rust +fn main() { + let x = U128::from_integer(23); + let y = U128::from_hex("0x7"); + let z = x + y; + assert(z.to_integer() == 30); +} +``` + +`U128` is implemented with two 64 bits limbs, representing the low and high bits, which explains the performance cost. You should expect `U128` to be twice more costly for addition and four times more costly for multiplication. +You can construct a U128 from its limbs: +```rust +fn main(x: u64, y: u64) { + let x = U128::from_u64s_be(x,y); + assert(z.hi == x as Field); + assert(z.lo == y as Field); +} +``` + +Note that the limbs are stored as Field elements in order to avoid unnecessary conversions. +Apart from this, most operations will work as usual: + +```rust +fn main(x: U128, y: U128) { + // multiplication + let c = x * y; + // addition and subtraction + let c = c - x + y; + // division + let c = x / y; + // bit operation; + let c = x & y | y; + // bit shift + let c = x << y; + // comparisons; + let c = x < y; + let c = x == y; +} +``` + +## Overflows + +Computations that exceed the type boundaries will result in overflow errors. This happens with both signed and unsigned integers. For example, attempting to prove: + +```rust +fn main(x: u8, y: u8) { + let z = x + y; +} +``` + +With: + +```toml +x = "255" +y = "1" +``` + +Would result in: + +``` +$ nargo execute +error: Assertion failed: 'attempt to add with overflow' +┌─ ~/src/main.nr:9:13 +│ +│ let z = x + y; +│ ----- +│ += Call stack: + ... +``` + +A similar error would happen with signed integers: + +```rust +fn main() { + let x: i8 = -118; + let y: i8 = -11; + let z = x + y; +} +``` + +### Wrapping methods + +Although integer overflow is expected to error, some use-cases rely on wrapping. For these use-cases, the standard library provides `wrapping` variants of certain common operations: + +```rust +fn wrapping_add(x: T, y: T) -> T; +fn wrapping_sub(x: T, y: T) -> T; +fn wrapping_mul(x: T, y: T) -> T; +``` + +Example of how it is used: + +```rust + +fn main(x: u8, y: u8) -> pub u8 { + std::wrapping_add(x, y) +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/references.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/references.md new file mode 100644 index 000000000000..a5293d11cfb9 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/references.md @@ -0,0 +1,23 @@ +--- +title: References +sidebar_position: 9 +--- + +Noir supports first-class references. References are a bit like pointers: they point to a specific address that can be followed to access the data stored at that address. You can use Rust-like syntax to use pointers in Noir: the `&` operator references the variable, the `*` operator dereferences it. + +Example: + +```rust +fn main() { + let mut x = 2; + + // you can reference x as &mut and pass it to multiplyBy2 + multiplyBy2(&mut x); +} + +// you can access &mut here +fn multiplyBy2(x: &mut Field) { + // and dereference it with * + *x = *x * 2; +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/slices.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/slices.mdx new file mode 100644 index 000000000000..cfee564a302e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/slices.mdx @@ -0,0 +1,358 @@ +--- +title: Slices +description: Explore the Slice data type in Noir. Understand its methods, see real-world examples, and learn how to effectively use Slices in your Noir programs. +keywords: [noir, slice type, methods, examples, subarrays] +sidebar_position: 5 +--- + +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size. + +```rust +fn main() -> pub u32 { + let mut slice: [Field] = &[0; 2]; + + let mut new_slice = slice.push_back(6); + new_slice.len() +} +``` + +To write a slice literal, use a preceding ampersand as in: `&[0; 2]` or +`&[1, 2, 3]`. + +It is important to note that slices are not references to arrays. In Noir, +`&[..]` is more similar to an immutable, growable vector. + +View the corresponding test file [here][test-file]. + +[test-file]: https://github.com/noir-lang/noir/blob/f387ec1475129732f72ba294877efdf6857135ac/crates/nargo_cli/tests/test_data_ssa_refactor/slices/src/main.nr + +## Methods + +For convenience, the STD provides some ready-to-use, common methods for slices: + +### push_back + +Pushes a new element to the end of the slice, returning a new slice with a length one greater than the original unmodified slice. + +```rust +fn push_back(_self: [T], _elem: T) -> [T] +``` + +example: + +```rust +fn main() -> pub Field { + let mut slice: [Field] = &[0; 2]; + + let mut new_slice = slice.push_back(6); + new_slice.len() +} +``` + +View the corresponding test file [here][test-file]. + +### push_front + +Returns a new array with the specified element inserted at index 0. The existing elements indexes are incremented by 1. + +```rust +fn push_front(_self: Self, _elem: T) -> Self +``` + +Example: + +```rust +let mut new_slice: [Field] = &[]; +new_slice = new_slice.push_front(20); +assert(new_slice[0] == 20); // returns true +``` + +View the corresponding test file [here][test-file]. + +### pop_front + +Returns a tuple of two items, the first element of the array and the rest of the array. + +```rust +fn pop_front(_self: Self) -> (T, Self) +``` + +Example: + +```rust +let (first_elem, rest_of_slice) = slice.pop_front(); +``` + +View the corresponding test file [here][test-file]. + +### pop_back + +Returns a tuple of two items, the beginning of the array with the last element omitted and the last element. + +```rust +fn pop_back(_self: Self) -> (Self, T) +``` + +Example: + +```rust +let (popped_slice, last_elem) = slice.pop_back(); +``` + +View the corresponding test file [here][test-file]. + +### append + +Loops over a slice and adds it to the end of another. + +```rust +fn append(mut self, other: Self) -> Self +``` + +Example: + +```rust +let append = &[1, 2].append(&[3, 4, 5]); +``` + +### insert + +Inserts an element at a specified index and shifts all following elements by 1. + +```rust +fn insert(_self: Self, _index: Field, _elem: T) -> Self +``` + +Example: + +```rust +new_slice = rest_of_slice.insert(2, 100); +assert(new_slice[2] == 100); +``` + +View the corresponding test file [here][test-file]. + +### remove + +Remove an element at a specified index, shifting all elements after it to the left, returning the altered slice and the removed element. + +```rust +fn remove(_self: Self, _index: Field) -> (Self, T) +``` + +Example: + +```rust +let (remove_slice, removed_elem) = slice.remove(3); +``` + +### len + +Returns the length of a slice + +```rust +fn len(self) -> Field +``` + +Example: + +```rust +fn main() { + let slice = &[42, 42]; + assert(slice.len() == 2); +} +``` + +### as_array + +Converts this slice into an array. + +Make sure to specify the size of the resulting array. +Panics if the resulting array length is different than the slice's length. + +```rust +fn as_array(self) -> [T; N] +``` + +Example: + +```rust +fn main() { + let slice = &[5, 6]; + + // Always specify the length of the resulting array! + let array: [Field; 2] = slice.as_array(); + + assert(array[0] == slice[0]); + assert(array[1] == slice[1]); +} +``` + +### map + +Applies a function to each element of the slice, returning a new slice containing the mapped elements. + +```rust +fn map(self, f: fn[Env](T) -> U) -> [U] +``` + +example + +```rust +let a = &[1, 2, 3]; +let b = a.map(|a| a * 2); // b is now &[2, 4, 6] +``` + +### fold + +Applies a function to each element of the slice, returning the final accumulated value. The first +parameter is the initial value. + +```rust +fn fold(self, mut accumulator: U, f: fn[Env](U, T) -> U) -> U +``` + +This is a left fold, so the given function will be applied to the accumulator and first element of +the slice, then the second, and so on. For a given call the expected result would be equivalent to: + +```rust +let a1 = &[1]; +let a2 = &[1, 2]; +let a3 = &[1, 2, 3]; + +let f = |a, b| a - b; +a1.fold(10, f) //=> f(10, 1) +a2.fold(10, f) //=> f(f(10, 1), 2) +a3.fold(10, f) //=> f(f(f(10, 1), 2), 3) +``` + +example: + +```rust + +fn main() { + let slice = &[2, 2, 2, 2, 2]; + let folded = slice.fold(0, |a, b| a + b); + assert(folded == 10); +} + +``` + +### reduce + +Same as fold, but uses the first element as the starting element. + +```rust +fn reduce(self, f: fn[Env](T, T) -> T) -> T +``` + +example: + +```rust +fn main() { + let slice = &[2, 2, 2, 2, 2]; + let reduced = slice.reduce(|a, b| a + b); + assert(reduced == 10); +} +``` + +### filter + +Returns a new slice containing only elements for which the given predicate returns true. + +```rust +fn filter(self, f: fn[Env](T) -> bool) -> Self +``` + +example: + +```rust +fn main() { + let slice = &[1, 2, 3, 4, 5]; + let odds = slice.filter(|x| x % 2 == 1); + assert_eq(odds, &[1, 3, 5]); +} +``` + +### join + +Flatten each element in the slice into one value, separated by `separator`. + +Note that although slices implement `Append`, `join` cannot be used on slice +elements since nested slices are prohibited. + +```rust +fn join(self, separator: T) -> T where T: Append +``` + +example: + +```rust +struct Accumulator { + total: Field, +} + +// "Append" two accumulators by adding them +impl Append for Accumulator { + fn empty() -> Self { + Self { total: 0 } + } + + fn append(self, other: Self) -> Self { + Self { total: self.total + other.total } + } +} + +fn main() { + let slice = &[1, 2, 3, 4, 5].map(|total| Accumulator { total }); + + let result = slice.join(Accumulator::empty()); + assert_eq(result, Accumulator { total: 15 }); + + // We can use a non-empty separator to insert additional elements to sum: + let separator = Accumulator { total: 10 }; + let result = slice.join(separator); + assert_eq(result, Accumulator { total: 55 }); +} +``` + +### all + +Returns true if all the elements satisfy the given predicate + +```rust +fn all(self, predicate: fn[Env](T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let slice = &[2, 2, 2, 2, 2]; + let all = slice.all(|a| a == 2); + assert(all); +} +``` + +### any + +Returns true if any of the elements satisfy the given predicate + +```rust +fn any(self, predicate: fn[Env](T) -> bool) -> bool +``` + +example: + +```rust +fn main() { + let slice = &[2, 2, 2, 2, 5]; + let any = slice.any(|a| a == 5); + assert(any); +} + +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/strings.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/strings.md new file mode 100644 index 000000000000..1fdee42425e5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/strings.md @@ -0,0 +1,79 @@ +--- +title: Strings +description: + Discover the String data type in Noir. Learn about its methods, see real-world examples, and understand how to effectively manipulate and use Strings in Noir. +keywords: + [ + noir, + string type, + methods, + examples, + concatenation, + ] +sidebar_position: 3 +--- + + +The string type is a fixed length value defined with `str`. + +You can use strings in `assert()` functions or print them with +`println()`. See more about [Logging](../../standard_library/logging.md). + +```rust + +fn main(message : pub str<11>, hex_as_string : str<4>) { + println(message); + assert(message == "hello world"); + assert(hex_as_string == "0x41"); +} +``` + +You can convert a `str` to a byte array by calling `as_bytes()` +or a vector by calling `as_bytes_vec()`. + +```rust +fn main() { + let message = "hello world"; + let message_bytes = message.as_bytes(); + let mut message_vec = message.as_bytes_vec(); + assert(message_bytes.len() == 11); + assert(message_bytes[0] == 104); + assert(message_bytes[0] == message_vec.get(0)); +} +``` + +## Escape characters + +You can use escape characters for your strings: + +| Escape Sequence | Description | +|-----------------|-----------------| +| `\r` | Carriage Return | +| `\n` | Newline | +| `\t` | Tab | +| `\0` | Null Character | +| `\"` | Double Quote | +| `\\` | Backslash | + +Example: + +```rust +let s = "Hello \"world" // prints "Hello "world" +let s = "hey \tyou"; // prints "hey you" +``` + +## Raw strings + +A raw string begins with the letter `r` and is optionally delimited by a number of hashes `#`. + +Escape characters are *not* processed within raw strings. All contents are interpreted literally. + +Example: + +```rust +let s = r"Hello world"; +let s = r#"Simon says "hello world""#; + +// Any number of hashes may be used (>= 1) as long as the string also terminates with the same number of hashes +let s = r#####"One "#, Two "##, Three "###, Four "####, Five will end the string."#####; +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/structs.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/structs.md new file mode 100644 index 000000000000..29951ae843a5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/structs.md @@ -0,0 +1,96 @@ +--- +title: Structs +description: + Explore the Struct data type in Noir. Learn about its methods, see real-world examples, and grasp how to effectively define and use Structs in your Noir programs. +keywords: + [ + noir, + struct type, + methods, + examples, + data structures, + ] +sidebar_position: 8 +--- + +A struct also allows for grouping multiple values of different types. Unlike tuples, we can also +name each field. + +> **Note:** The usage of _field_ here refers to each element of the struct and is unrelated to the +> field type of Noir. + +Defining a struct requires giving it a name and listing each field within as `: ` pairs: + +```rust +struct Animal { + hands: Field, + legs: Field, + eyes: u8, +} +``` + +An instance of a struct can then be created with actual values in `: ` pairs in any +order. Struct fields are accessible using their given names: + +```rust +fn main() { + let legs = 4; + + let dog = Animal { + eyes: 2, + hands: 0, + legs, + }; + + let zero = dog.hands; +} +``` + +Structs can also be destructured in a pattern, binding each field to a new variable: + +```rust +fn main() { + let Animal { hands, legs: feet, eyes } = get_octopus(); + + let ten = hands + feet + eyes as u8; +} + +fn get_octopus() -> Animal { + let octopus = Animal { + hands: 0, + legs: 8, + eyes: 2, + }; + + octopus +} +``` + +The new variables can be bound with names different from the original struct field names, as +showcased in the `legs --> feet` binding in the example above. + +### Visibility + +By default, like functions, structs are private to the module they exist in. You can use `pub` +to make the struct public or `pub(crate)` to make it public to just its crate: + +```rust +// This struct is now public +pub struct Animal { + hands: Field, + legs: Field, + eyes: u8, +} +``` + +The same applies to struct fields: by default they are private to the module they exist in, +but they can be made `pub` or `pub(crate)`: + +```rust +// This struct is now public +pub struct Animal { + hands: Field, // private to its module + pub(crate) legs: Field, // accessible from the entire crate + pub eyes: u8, // accessible from anywhere +} +``` \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/tuples.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/tuples.md new file mode 100644 index 000000000000..2ec5c9c41135 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/data_types/tuples.md @@ -0,0 +1,48 @@ +--- +title: Tuples +description: + Dive into the Tuple data type in Noir. Understand its methods, practical examples, and best practices for efficiently using Tuples in your Noir code. +keywords: + [ + noir, + tuple type, + methods, + examples, + multi-value containers, + ] +sidebar_position: 7 +--- + +A tuple collects multiple values like an array, but with the added ability to collect values of +different types: + +```rust +fn main() { + let tup: (u8, u64, Field) = (255, 500, 1000); +} +``` + +One way to access tuple elements is via destructuring using pattern matching: + +```rust +fn main() { + let tup = (1, 2); + + let (one, two) = tup; + + let three = one + two; +} +``` + +Another way to access tuple elements is via direct member access, using a period (`.`) followed by +the index of the element we want to access. Index `0` corresponds to the first tuple element, `1` to +the second and so on: + +```rust +fn main() { + let tup = (5, 6, 7, 8); + + let five = tup.0; + let eight = tup.3; +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/functions.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/functions.md new file mode 100644 index 000000000000..f656cdfd97a1 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/functions.md @@ -0,0 +1,226 @@ +--- +title: Functions +description: + Learn how to declare functions and methods in Noir, a programming language with Rust semantics. + This guide covers parameter declaration, return types, call expressions, and more. +keywords: [Noir, Rust, functions, methods, parameter declaration, return types, call expressions] +sidebar_position: 1 +--- + +Functions in Noir follow the same semantics of Rust, though Noir does not support early returns. + +To declare a function the `fn` keyword is used. + +```rust +fn foo() {} +``` + +By default, functions are visible only within the package they are defined. To make them visible outside of that package (for example, as part of a [library](../modules_packages_crates/crates_and_packages.md#libraries)), you should mark them as `pub`: + +```rust +pub fn foo() {} +``` + +You can also restrict the visibility of the function to only the crate it was defined in, by specifying `pub(crate)`: + +```rust +pub(crate) fn foo() {} //foo can only be called within its crate +``` + +All parameters in a function must have a type and all types are known at compile time. The parameter +is pre-pended with a colon and the parameter type. Multiple parameters are separated using a comma. + +```rust +fn foo(x : Field, y : Field){} +``` + +The return type of a function can be stated by using the `->` arrow notation. The function below +states that the foo function must return a `Field`. If the function returns no value, then the arrow +is omitted. + +```rust +fn foo(x : Field, y : Field) -> Field { + x + y +} +``` + +Note that a `return` keyword is unneeded in this case - the last expression in a function's body is +returned. + +## Main function + +If you're writing a binary, the `main` function is the starting point of your program. You can pass all types of expressions to it, as long as they have a fixed size at compile time: + +```rust +fn main(x : Field) // this is fine: passing a Field +fn main(x : [Field; 2]) // this is also fine: passing a Field with known size at compile-time +fn main(x : (Field, bool)) // 👌: passing a (Field, bool) tuple means size 2 +fn main(x : str<5>) // this is fine, as long as you pass a string of size 5 + +fn main(x : Vec) // can't compile, has variable size +fn main(x : [Field]) // can't compile, has variable size +fn main(....// i think you got it by now +``` + +Keep in mind [tests](../../tooling/testing.md) don't differentiate between `main` and any other function. The following snippet passes tests, but won't compile or prove: + +```rust +fn main(x : [Field]) { + assert(x[0] == 1); +} + +#[test] +fn test_one() { + main(&[1, 2]); +} +``` + +```bash +$ nargo test +[testing] Running 1 test functions +[testing] Testing test_one... ok +[testing] All tests passed + +$ nargo check +The application panicked (crashed). +Message: Cannot have variable sized arrays as a parameter to main +``` + +## Call Expressions + +Calling a function in Noir is executed by using the function name and passing in the necessary +arguments. + +Below we show how to call the `foo` function from the `main` function using a call expression: + +```rust +fn main(x : Field, y : Field) { + let z = foo(x); +} + +fn foo(x : Field) -> Field { + x + x +} +``` + +## Methods + +You can define methods in Noir on any struct type in scope. + +```rust +struct MyStruct { + foo: Field, + bar: Field, +} + +impl MyStruct { + fn new(foo: Field) -> MyStruct { + MyStruct { + foo, + bar: 2, + } + } + + fn sum(self) -> Field { + self.foo + self.bar + } +} + +fn main() { + let s = MyStruct::new(40); + assert(s.sum() == 42); +} +``` + +Methods are just syntactic sugar for functions, so if we wanted to we could also call `sum` as +follows: + +```rust +assert(MyStruct::sum(s) == 42); +``` + +It is also possible to specialize which method is chosen depending on the [generic](./generics.md) type that is used. In this example, the `foo` function returns different values depending on its type: + +```rust +struct Foo {} + +impl Foo { + fn foo(self) -> Field { 1 } +} + +impl Foo { + fn foo(self) -> Field { 2 } +} + +fn main() { + let f1: Foo = Foo{}; + let f2: Foo = Foo{}; + assert(f1.foo() + f2.foo() == 3); +} +``` + +Also note that impls with the same method name defined in them cannot overlap. For example, if we already have `foo` defined for `Foo` and `Foo` like we do above, we cannot also define `foo` in an `impl Foo` since it would be ambiguous which version of `foo` to choose. + +```rust +// Including this impl in the same project as the above snippet would +// cause an overlapping impls error +impl Foo { + fn foo(self) -> Field { 3 } +} +``` + +## Lambdas + +Lambdas are anonymous functions. They follow the syntax of Rust - `|arg1, arg2, ..., argN| return_expression`. + +```rust +let add_50 = |val| val + 50; +assert(add_50(100) == 150); +``` + +See [Lambdas](./lambdas.md) for more details. + +## Attributes + +Attributes are metadata that can be applied to a function, using the following syntax: `#[attribute(value)]`. + +Supported attributes include: + +- **builtin**: the function is implemented by the compiler, for efficiency purposes. +- **deprecated**: mark the function as _deprecated_. Calling the function will generate a warning: `warning: use of deprecated function` +- **field**: Used to enable conditional compilation of code depending on the field size. See below for more details +- **oracle**: mark the function as _oracle_; meaning it is an external unconstrained function, implemented in noir_js. See [Unconstrained](./unconstrained.md) and [NoirJS](../../reference/NoirJS/noir_js/index.md) for more details. +- **test**: mark the function as unit tests. See [Tests](../../tooling/testing.md) for more details + +### Field Attribute + +The field attribute defines which field the function is compatible for. The function is conditionally compiled, under the condition that the field attribute matches the Noir native field. +The field can be defined implicitly, by using the name of the elliptic curve usually associated to it - for instance bn254, bls12_381 - or explicitly by using the field (prime) order, in decimal or hexadecimal form. +As a result, it is possible to define multiple versions of a function with each version specialized for a different field attribute. This can be useful when a function requires different parameters depending on the underlying elliptic curve. + +Example: we define the function `foo()` three times below. Once for the default Noir bn254 curve, once for the field $\mathbb F_{23}$, which will normally never be used by Noir, and once again for the bls12_381 curve. + +```rust +#[field(bn254)] +fn foo() -> u32 { + 1 +} + +#[field(23)] +fn foo() -> u32 { + 2 +} + +// This commented code would not compile as foo would be defined twice because it is the same field as bn254 +// #[field(21888242871839275222246405745257275088548364400416034343698204186575808495617)] +// fn foo() -> u32 { +// 2 +// } + +#[field(bls12_381)] +fn foo() -> u32 { + 3 +} +``` + +If the field name is not known to Noir, it will discard the function. Field names are case insensitive. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/generics.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/generics.md new file mode 100644 index 000000000000..c180a0ce7e6d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/generics.md @@ -0,0 +1,251 @@ +--- +title: Generics +description: Learn how to use Generics in Noir +keywords: [Noir, Rust, generics, functions, structs] +sidebar_position: 7 +--- + +Generics allow you to use the same functions with multiple different concrete data types. You can +read more about the concept of generics in the Rust documentation +[here](https://doc.rust-lang.org/book/ch10-01-syntax.html). + +Here is a trivial example showing the identity function that supports any type. In Rust, it is +common to refer to the most general type as `T`. We follow the same convention in Noir. + +```rust +fn id(x: T) -> T { + x +} +``` + +## Numeric Generics + +If we want to be generic over array lengths (which are type-level integers), we can use numeric +generics. Using these looks similar to using regular generics, but introducing them into scope +requires declaring them with `let MyGenericName: IntegerType`. This can be done anywhere a normal +generic is declared. Instead of types, these generics resolve to integers at compile-time. +Here's an example of a struct that is generic over the size of the array it contains internally: + +```rust +struct BigInt { + limbs: [u32; N], +} + +impl BigInt { + // `N` is in scope of all methods in the impl + fn first(first: BigInt, second: BigInt) -> Self { + assert(first.limbs != second.limbs); + first + + fn second(first: BigInt, second: Self) -> Self { + assert(first.limbs != second.limbs); + second + } +} +``` + +## In Structs + +Generics are useful for specifying types in structs. For example, we can specify that a field in a +struct will be of a certain generic type. In this case `value` is of type `T`. + +```rust +struct RepeatedValue { + value: T, + count: Field, +} + +impl RepeatedValue { + fn print(self) { + for _i in 0 .. self.count { + println(self.value); + } + } +} + +fn main() { + let repeated = RepeatedValue { value: "Hello!", count: 2 }; + repeated.print(); +} +``` + +The `print` function will print `Hello!` an arbitrary number of times, twice in this case. + +## Calling functions on generic parameters + +Since a generic type `T` can represent any type, how can we call functions on the underlying type? +In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" + +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over +any type `T` that implements the `Eq` trait for equality: + +```rust +fn first_element_is_equal(array1: [T; N], array2: [T; N]) -> bool + where T: Eq +{ + if (array1.len() == 0) | (array2.len() == 0) { + true + } else { + array1[0] == array2[0] + } +} + +fn main() { + assert(first_element_is_equal([1, 2, 3], [1, 5, 6])); + + // We can use first_element_is_equal for arrays of any type + // as long as we have an Eq impl for the types we pass in + let array = [MyStruct::new(), MyStruct::new()]; + assert(array_eq(array, array, MyStruct::eq)); +} + +impl Eq for MyStruct { + fn eq(self, other: MyStruct) -> bool { + self.foo == other.foo + } +} +``` + +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). + +## Manually Specifying Generics with the Turbofish Operator + +There are times when the compiler cannot reasonably infer what type should be used for a generic, or when the developer themselves may want to manually distinguish generic type parameters. This is where the `::<>` turbofish operator comes into play. + +The `::<>` operator can follow a variable or path and can be used to manually specify generic arguments within the angle brackets. +The name "turbofish" comes from that `::<>` looks like a little fish. + +Examples: +```rust +fn main() { + let mut slice = []; + slice = slice.push_back(1); + slice = slice.push_back(2); + // Without turbofish a type annotation would be needed on the left hand side + let array = slice.as_array::<2>(); +} +``` + + +```rust +trait MyTrait { + fn ten() -> Self; +} + +impl MyTrait for Field { + fn ten() -> Self { 10 } +} + +struct Foo { + inner: T +} + +impl Foo { + fn generic_method(_self: Self) -> U where U: MyTrait { + U::ten() + } +} + +fn example() { + let foo: Foo = Foo { inner: 1 }; + // Using a type other than `Field` here (e.g. u32) would fail as + // there is no matching impl for `u32: MyTrait`. + // + // Substituting the `10` on the left hand side of this assert + // with `10 as u32` would also fail with a type mismatch as we + // are expecting a `Field` from the right hand side. + assert(10 as u32 == foo.generic_method::()); +} +``` + +## Arithmetic Generics + +In addition to numeric generics, Noir also allows a limited form of arithmetic on generics. +When you have a numeric generic such as `N`, you can use the following operators on it in a +type position: `+`, `-`, `*`, `/`, and `%`. + +Note that type checking arithmetic generics is a best effort guess from the compiler and there +are many cases of types that are equal that the compiler may not see as such. For example, +we know that `T * (N + M)` should be equal to `T*N + T*M` but the compiler does not currently +apply the distributive law and thus sees these as different types. + +Even with this limitation though, the compiler can handle common cases decently well: + +```rust +trait Serialize { + fn serialize(self) -> [Field; N]; +} + +impl Serialize<1> for Field { + fn serialize(self) -> [Field; 1] { + [self] + } +} + +impl Serialize for [T; N] + where T: Serialize { .. } + +impl Serialize for (T, U) + where T: Serialize, U: Serialize { .. } + +fn main() { + let data = (1, [2, 3, 4]); + assert_eq(data.serialize().len(), 4); +} +``` + +Note that if there is any over or underflow the types will fail to unify: + +```rust title="underflow-example" showLineNumbers +fn pop(array: [Field; N]) -> [Field; N - 1] { + let mut result: [Field; N - 1] = std::mem::zeroed(); + for i in 0..N - 1 { + result[i] = array[i]; + } + result +} + +fn main() { + // error: Could not determine array length `(0 - 1)` + pop([]); +} +``` +> Source code: test_programs/compile_failure/arithmetic_generics_underflow/src/main.nr#L1-L14 + + +This also applies if there is underflow in an intermediate calculation: + +```rust title="intermediate-underflow-example" showLineNumbers +fn main() { + // From main it looks like there's nothing sketchy going on + seems_fine([]); +} + +// Since `seems_fine` says it can receive and return any length N +fn seems_fine(array: [Field; N]) -> [Field; N] { + // But inside `seems_fine` we pop from the array which + // requires the length to be greater than zero. + + // error: Could not determine array length `(0 - 1)` + push_zero(pop(array)) +} + +fn pop(array: [Field; N]) -> [Field; N - 1] { + let mut result: [Field; N - 1] = std::mem::zeroed(); + for i in 0..N - 1 { + result[i] = array[i]; + } + result +} + +fn push_zero(array: [Field; N]) -> [Field; N + 1] { + let mut result: [Field; N + 1] = std::mem::zeroed(); + for i in 0..N { + result[i] = array[i]; + } + // index N is already zeroed + result +} +``` +> Source code: test_programs/compile_failure/arithmetic_generics_intermediate_underflow/src/main.nr#L1-L32 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/globals.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/globals.md new file mode 100644 index 000000000000..6b8314399a27 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/globals.md @@ -0,0 +1,82 @@ +--- +title: Global Variables +description: + Learn about global variables in Noir. Discover how + to declare, modify, and use them in your programs. +keywords: [noir programming language, globals, global variables, constants] +sidebar_position: 8 +--- + +## Globals + + +Noir supports global variables. The global's type can be inferred by the compiler entirely: + +```rust +global N = 5; // Same as `global N: Field = 5` + +global TUPLE = (3, 2); + +fn main() { + assert(N == 5); + assert(N == TUPLE.0 + TUPLE.1); +} +``` + +:::info + +Globals can be defined as any expression, so long as they don't depend on themselves - otherwise there would be a dependency cycle! For example: + +```rust +global T = foo(T); // dependency error +``` + +::: + + +If they are initialized to a literal integer, globals can be used to specify an array's length: + +```rust +global N: u32 = 2; + +fn main(y : [Field; N]) { + assert(y[0] == y[1]) +} +``` + +A global from another module can be imported or referenced externally like any other name: + +```rust +global N = 20; + +fn main() { + assert(my_submodule::N != N); +} + +mod my_submodule { + global N: Field = 10; +} +``` + +When a global is used, Noir replaces the name with its definition on each occurrence. +This means globals defined using function calls will repeat the call each time they're used: + +```rust +global RESULT = foo(); + +fn foo() -> [Field; 100] { ... } +``` + +This is usually fine since Noir will generally optimize any function call that does not +refer to a program input into a constant. It should be kept in mind however, if the called +function performs side-effects like `println`, as these will still occur on each use. + +### Visibility + +By default, like functions, globals are private to the module they exist in. You can use `pub` +to make the global public or `pub(crate)` to make it public to just its crate: + +```rust +// This global is now public +pub global N = 5; +``` \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/lambdas.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/lambdas.md new file mode 100644 index 000000000000..be3c7e0b5caa --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/lambdas.md @@ -0,0 +1,81 @@ +--- +title: Lambdas +description: Learn how to use anonymous functions in Noir programming language. +keywords: [Noir programming language, lambda, closure, function, anonymous function] +sidebar_position: 9 +--- + +## Introduction + +Lambdas are anonymous functions. The syntax is `|arg1, arg2, ..., argN| return_expression`. + +```rust +let add_50 = |val| val + 50; +assert(add_50(100) == 150); +``` + +A block can be used as the body of a lambda, allowing you to declare local variables inside it: + +```rust +let cool = || { + let x = 100; + let y = 100; + x + y +} + +assert(cool() == 200); +``` + +## Closures + +Inside the body of a lambda, you can use variables defined in the enclosing function. Such lambdas are called **closures**. In this example `x` is defined inside `main` and is accessed from within the lambda: + +```rust +fn main() { + let x = 100; + let closure = || x + 150; + assert(closure() == 250); +} +``` + +## Passing closures to higher-order functions + +It may catch you by surprise that the following code fails to compile: + +```rust +fn foo(f: fn () -> Field) -> Field { + f() +} + +fn main() { + let (x, y) = (50, 50); + assert(foo(|| x + y) == 100); // error :( +} +``` + +The reason is that the closure's capture environment affects its type - we have a closure that captures two Fields and `foo` +expects a regular function as an argument - those are incompatible. +:::note + +Variables contained within the `||` are the closure's parameters, and the expression that follows it is the closure's body. The capture environment is comprised of any variables used in the closure's body that are not parameters. + +E.g. in |x| x + y, y would be a captured variable, but x would not be, since it is a parameter of the closure. + +::: +The syntax for the type of a closure is `fn[env](args) -> ret_type`, where `env` is the capture environment of the closure - +in this example that's `(Field, Field)`. + +The best solution in our case is to make `foo` generic over the environment type of its parameter, so that it can be called +with closures with any environment, as well as with regular functions: + +```rust +fn foo(f: fn[Env]() -> Field) -> Field { + f() +} + +fn main() { + let (x, y) = (50, 50); + assert(foo(|| x + y) == 100); // compiles fine + assert(foo(|| 60) == 60); // compiles fine +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/mutability.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/mutability.md new file mode 100644 index 000000000000..fdeef6a87c53 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/mutability.md @@ -0,0 +1,121 @@ +--- +title: Mutability +description: + Learn about mutable variables in Noir. Discover how + to declare, modify, and use them in your programs. +keywords: [noir programming language, mutability in noir, mutable variables] +sidebar_position: 8 +--- + +Variables in noir can be declared mutable via the `mut` keyword. Mutable variables can be reassigned +to via an assignment expression. + +```rust +let x = 2; +x = 3; // error: x must be mutable to be assigned to + +let mut y = 3; +let y = 4; // OK +``` + +The `mut` modifier can also apply to patterns: + +```rust +let (a, mut b) = (1, 2); +a = 11; // error: a must be mutable to be assigned to +b = 12; // OK + +let mut (c, d) = (3, 4); +c = 13; // OK +d = 14; // OK + +// etc. +let MyStruct { x: mut y } = MyStruct { x: a }; +// y is now in scope +``` + +Note that mutability in noir is local and everything is passed by value, so if a called function +mutates its parameters then the parent function will keep the old value of the parameters. + +```rust +fn main() -> pub Field { + let x = 3; + helper(x); + x // x is still 3 +} + +fn helper(mut x: i32) { + x = 4; +} +``` + +## Non-local mutability + +Non-local mutability can be achieved through the mutable reference type `&mut T`: + +```rust +fn set_to_zero(x: &mut Field) { + *x = 0; +} + +fn main() { + let mut y = 42; + set_to_zero(&mut y); + assert(*y == 0); +} +``` + +When creating a mutable reference, the original variable being referred to (`y` in this +example) must also be mutable. Since mutable references are a reference type, they must +be explicitly dereferenced via `*` to retrieve the underlying value. Note that this yields +a copy of the value, so mutating this copy will not change the original value behind the +reference: + +```rust +fn main() { + let mut x = 1; + let x_ref = &mut x; + + let mut y = *x_ref; + let y_ref = &mut y; + + x = 2; + *x_ref = 3; + + y = 4; + *y_ref = 5; + + assert(x == 3); + assert(*x_ref == 3); + assert(y == 5); + assert(*y_ref == 5); +} +``` + +Note that types in Noir are actually deeply immutable so the copy that occurs when +dereferencing is only a conceptual copy - no additional constraints will occur. + +Mutable references can also be stored within structs. Note that there is also +no lifetime parameter on these unlike rust. This is because the allocated memory +always lasts the entire program - as if it were an array of one element. + +```rust +struct Foo { + x: &mut Field +} + +impl Foo { + fn incr(mut self) { + *self.x += 1; + } +} + +fn main() { + let foo = Foo { x: &mut 0 }; + foo.incr(); + assert(*foo.x == 1); +} +``` + +In general, you should avoid non-local & shared mutability unless it is needed. Sticking +to only local mutability will improve readability and potentially improve compiler optimizations as well. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/ops.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/ops.md new file mode 100644 index 000000000000..c35c36c38a90 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/ops.md @@ -0,0 +1,98 @@ +--- +title: Logical Operations +description: + Learn about the supported arithmetic and logical operations in the Noir programming language. + Discover how to perform operations on private input types, integers, and booleans. +keywords: + [ + Noir programming language, + supported operations, + arithmetic operations, + logical operations, + predicate operators, + bitwise operations, + short-circuiting, + backend, + ] +sidebar_position: 3 +--- + +# Operations + +## Table of Supported Operations + +| Operation | Description | Requirements | +| :-------- | :------------------------------------------------------------: | -------------------------------------: | +| + | Adds two private input types together | Types must be private input | +| - | Subtracts two private input types together | Types must be private input | +| \* | Multiplies two private input types together | Types must be private input | +| / | Divides two private input types together | Types must be private input | +| ^ | XOR two private input types together | Types must be integer | +| & | AND two private input types together | Types must be integer | +| \| | OR two private input types together | Types must be integer | +| \<\< | Left shift an integer by another integer amount | Types must be integer, shift must be u8 | +| >> | Right shift an integer by another integer amount | Types must be integer, shift must be u8 | +| ! | Bitwise not of a value | Type must be integer or boolean | +| \< | returns a bool if one value is less than the other | Upper bound must have a known bit size | +| \<= | returns a bool if one value is less than or equal to the other | Upper bound must have a known bit size | +| > | returns a bool if one value is more than the other | Upper bound must have a known bit size | +| >= | returns a bool if one value is more than or equal to the other | Upper bound must have a known bit size | +| == | returns a bool if one value is equal to the other | Both types must not be constants | +| != | returns a bool if one value is not equal to the other | Both types must not be constants | + +### Predicate Operators + +`<,<=, !=, == , >, >=` are known as predicate/comparison operations because they compare two values. +This differs from the operations such as `+` where the operands are used in _computation_. + +### Bitwise Operations Example + +```rust +fn main(x : Field) { + let y = x as u32; + let z = y & y; +} +``` + +`z` is implicitly constrained to be the result of `y & y`. The `&` operand is used to denote bitwise +`&`. + +> `x & x` would not compile as `x` is a `Field` and not an integer type. + +### Logical Operators + +Noir has no support for the logical operators `||` and `&&`. This is because encoding the +short-circuiting that these operators require can be inefficient for Noir's backend. Instead you can +use the bitwise operators `|` and `&` which operate identically for booleans, just without the +short-circuiting. + +```rust +let my_val = 5; + +let mut flag = 1; +if (my_val > 6) | (my_val == 0) { + flag = 0; +} +assert(flag == 1); + +if (my_val != 10) & (my_val < 50) { + flag = 0; +} +assert(flag == 0); +``` + +### Shorthand operators + +Noir shorthand operators for most of the above operators, namely `+=, -=, *=, /=, %=, &=, |=, ^=, <<=`, and `>>=`. These allow for more concise syntax. For example: + +```rust +let mut i = 0; +i = i + 1; +``` + +could be written as: + +```rust +let mut i = 0; +i += 1; +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/oracles.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/oracles.mdx new file mode 100644 index 000000000000..77a2ac1550ac --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/oracles.mdx @@ -0,0 +1,29 @@ +--- +title: Oracles +description: Dive into how Noir supports Oracles via RPC calls, and learn how to declare an Oracle in Noir with our comprehensive guide. +keywords: + - Noir + - Oracles + - RPC Calls + - Unconstrained Functions + - Programming + - Blockchain +sidebar_position: 6 +--- + +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +Noir has support for Oracles via RPC calls. This means Noir will make an RPC call and use the return value for proof generation. + +Since Oracles are not resolved by Noir, they are [`unconstrained` functions](./unconstrained.md) + +You can declare an Oracle through the `#[oracle()]` flag. Example: + +```rust +#[oracle(get_number_sequence)] +unconstrained fn get_number_sequence(_size: Field) -> [Field] {} +``` + +The timeout for when using an external RPC oracle resolver can be set with the `NARGO_FOREIGN_CALL_TIMEOUT` environment variable. This timeout is in units of milliseconds. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/shadowing.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/shadowing.md new file mode 100644 index 000000000000..5ce6130d2011 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/shadowing.md @@ -0,0 +1,44 @@ +--- +title: Shadowing +sidebar_position: 12 +--- + +Noir allows for inheriting variables' values and re-declaring them with the same name similar to Rust, known as shadowing. + +For example, the following function is valid in Noir: + +```rust +fn main() { + let x = 5; + + { + let x = x * 2; + assert (x == 10); + } + + assert (x == 5); +} +``` + +In this example, a variable x is first defined with the value 5. + +The local scope that follows shadows the original x, i.e. creates a local mutable x based on the value of the original x. It is given a value of 2 times the original x. + +When we return to the main scope, x once again refers to just the original x, which stays at the value of 5. + +## Temporal mutability + +One way that shadowing is useful, in addition to ergonomics across scopes, is for temporarily mutating variables. + +```rust +fn main() { + let age = 30; + // age = age + 5; // Would error as `age` is immutable by default. + + let mut age = age + 5; // Temporarily mutates `age` with a new value. + + let age = age; // Locks `age`'s mutability again. + + assert (age == 35); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/traits.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/traits.md new file mode 100644 index 000000000000..9da00a77587d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/traits.md @@ -0,0 +1,501 @@ +--- +title: Traits +description: + Traits in Noir can be used to abstract out a common interface for functions across + several data types. +keywords: [noir programming language, traits, interfaces, generic, protocol] +sidebar_position: 14 +--- + +## Overview + +Traits in Noir are a useful abstraction similar to interfaces or protocols in other languages. Each trait defines +the interface of several methods contained within the trait. Types can then implement this trait by providing +implementations for these methods. For example in the program: + +```rust +struct Rectangle { + width: Field, + height: Field, +} + +impl Rectangle { + fn area(self) -> Field { + self.width * self.height + } +} + +fn log_area(r: Rectangle) { + println(r.area()); +} +``` + +We have a function `log_area` to log the area of a `Rectangle`. Now how should we change the program if we want this +function to work on `Triangle`s as well?: + +```rust +struct Triangle { + width: Field, + height: Field, +} + +impl Triangle { + fn area(self) -> Field { + self.width * self.height / 2 + } +} +``` + +Making `log_area` generic over all types `T` would be invalid since not all types have an `area` method. Instead, we can +introduce a new `Area` trait and make `log_area` generic over all types `T` that implement `Area`: + +```rust +trait Area { + fn area(self) -> Field; +} + +fn log_area(shape: T) where T: Area { + println(shape.area()); +} +``` + +We also need to explicitly implement `Area` for `Rectangle` and `Triangle`. We can do that by changing their existing +impls slightly. Note that the parameter types and return type of each of our `area` methods must match those defined +by the `Area` trait. + +```rust +impl Area for Rectangle { + fn area(self) -> Field { + self.width * self.height + } +} + +impl Area for Triangle { + fn area(self) -> Field { + self.width * self.height / 2 + } +} +``` + +Now we have a working program that is generic over any type of Shape that is used! Others can even use this program +as a library with their own types - such as `Circle` - as long as they also implement `Area` for these types. + +## Where Clauses + +As seen in `log_area` above, when we want to create a function or method that is generic over any type that implements +a trait, we can add a where clause to the generic function. + +```rust +fn log_area(shape: T) where T: Area { + println(shape.area()); +} +``` + +It is also possible to apply multiple trait constraints on the same variable at once by combining traits with the `+` +operator. Similarly, we can have multiple trait constraints by separating each with a comma: + +```rust +fn foo(elements: [T], thing: U) where + T: Default + Add + Eq, + U: Bar, +{ + let mut sum = T::default(); + + for element in elements { + sum += element; + } + + if sum == T::default() { + thing.bar(); + } +} +``` + +## Generic Implementations + +You can add generics to a trait implementation by adding the generic list after the `impl` keyword: + +```rust +trait Second { + fn second(self) -> Field; +} + +impl Second for (T, Field) { + fn second(self) -> Field { + self.1 + } +} +``` + +You can also implement a trait for every type this way: + +```rust +trait Debug { + fn debug(self); +} + +impl Debug for T { + fn debug(self) { + println(self); + } +} + +fn main() { + 1.debug(); +} +``` + +### Generic Trait Implementations With Where Clauses + +Where clauses can be placed on trait implementations themselves to restrict generics in a similar way. +For example, while `impl Foo for T` implements the trait `Foo` for every type, `impl Foo for T where T: Bar` +will implement `Foo` only for types that also implement `Bar`. This is often used for implementing generic types. +For example, here is the implementation for array equality: + +```rust +impl Eq for [T; let N: u32] where T: Eq { + // Test if two arrays have the same elements. + // Because both arrays must have length N, we know their lengths already match. + fn eq(self, other: Self) -> bool { + let mut result = true; + + for i in 0 .. self.len() { + // The T: Eq constraint is needed to call == on the array elements here + result &= self[i] == other[i]; + } + + result + } +} +``` + +Where clauses can also be placed on struct implementations. +For example, here is a method utilizing a generic type that implements the equality trait. + +```rust +struct Foo { + a: u32, + b: T, +} + +impl Foo where T: Eq { + fn eq(self, other: Self) -> bool { + (self.a == other.a) & self.b.eq(other.b) + } +} +``` + +## Generic Traits + +Traits themselves can also be generic by placing the generic arguments after the trait name. These generics are in +scope of every item within the trait. + +```rust +trait Into { + // Convert `self` to type `T` + fn into(self) -> T; +} +``` + +When implementing generic traits the generic arguments of the trait must be specified. This is also true anytime +when referencing a generic trait (e.g. in a `where` clause). + +```rust +struct MyStruct { + array: [Field; 2], +} + +impl Into<[Field; 2]> for MyStruct { + fn into(self) -> [Field; 2] { + self.array + } +} + +fn as_array(x: T) -> [Field; 2] + where T: Into<[Field; 2]> +{ + x.into() +} + +fn main() { + let array = [1, 2]; + let my_struct = MyStruct { array }; + + assert_eq(as_array(my_struct), array); +} +``` + +### Associated Types and Constants + +Traits also support associated types and constraints which can be thought of as additional generics that are referred to by name. + +Here's an example of a trait with an associated type `Foo` and a constant `Bar`: + +```rust +trait MyTrait { + type Foo; + + let Bar: u32; +} +``` + +Now when we're implementing `MyTrait` we also have to provide values for `Foo` and `Bar`: + +```rust +impl MyTrait for Field { + type Foo = i32; + + let Bar: u32 = 11; +} +``` + +Since associated constants can also be used in a type position, its values are limited to only other +expression kinds allowed in numeric generics. + +Note that currently all associated types and constants must be explicitly specified in a trait constraint. +If we leave out any, we'll get an error that we're missing one: + +```rust +// Error! Constraint is missing associated constant for `Bar` +fn foo(x: T) where T: MyTrait { + ... +} +``` + +Because all associated types and constants must be explicitly specified, they are essentially named generics, +although this is set to change in the future. Future versions of Noir will allow users to elide associated types +in trait constraints similar to Rust. When this is done, you may still refer to their value with the `::AssociatedType` +syntax: + +```rust +// Only valid in future versions of Noir: +fn foo(x: T) where T: MyTrait { + let _: ::Foo = ...; +} +``` + +The type as trait syntax is possible in Noir today but is less useful when each type must be explicitly specified anyway: + +```rust +fn foo(x: T) where T: MyTrait { + // Works, but could just use F directly + let _: >::Foo = ...; + + let _: F = ...; +} +``` + +## Trait Methods With No `self` + +A trait can contain any number of methods, each of which have access to the `Self` type which represents each type +that eventually implements the trait. Similarly, the `self` variable is available as well but is not required to be used. +For example, we can define a trait to create a default value for a type. This trait will need to return the `Self` type +but doesn't need to take any parameters: + +```rust +trait Default { + fn default() -> Self; +} +``` + +Implementing this trait can be done similarly to any other trait: + +```rust +impl Default for Field { + fn default() -> Field { + 0 + } +} + +struct MyType {} + +impl Default for MyType { + fn default() -> Field { + MyType {} + } +} +``` + +However, since there is no `self` parameter, we cannot call it via the method call syntax `object.method()`. +Instead, we'll need to refer to the function directly. This can be done either by referring to the +specific impl `MyType::default()` or referring to the trait itself `Default::default()`. In the later +case, type inference determines the impl that is selected. + +```rust +let my_struct = MyStruct::default(); + +let x: Field = Default::default(); +let result = x + Default::default(); +``` + +:::warning + +```rust +let _ = Default::default(); +``` + +If type inference cannot select which impl to use because of an ambiguous `Self` type, an impl will be +arbitrarily selected. This occurs most often when the result of a trait function call with no parameters +is unused. To avoid this, when calling a trait function with no `self` or `Self` parameters or return type, +always refer to it via the implementation type's namespace - e.g. `MyType::default()`. +This is set to change to an error in future Noir versions. + +::: + +## Default Method Implementations + +A trait can also have default implementations of its methods by giving a body to the desired functions. +Note that this body must be valid for all types that may implement the trait. As a result, the only +valid operations on `self` will be operations valid for any type or other operations on the trait itself. + +```rust +trait Numeric { + fn add(self, other: Self) -> Self; + + // Default implementation of double is (self + self) + fn double(self) -> Self { + self.add(self) + } +} +``` + +When implementing a trait with default functions, a type may choose to implement only the required functions: + +```rust +impl Numeric for Field { + fn add(self, other: Field) -> Field { + self + other + } +} +``` + +Or it may implement the optional methods as well: + +```rust +impl Numeric for u32 { + fn add(self, other: u32) -> u32 { + self + other + } + + fn double(self) -> u32 { + self * 2 + } +} +``` + +## Impl Specialization + +When implementing traits for a generic type it is possible to implement the trait for only a certain combination +of generics. This can be either as an optimization or because those specific generics are required to implement the trait. + +```rust +trait Sub { + fn sub(self, other: Self) -> Self; +} + +struct NonZero { + value: T, +} + +impl Sub for NonZero { + fn sub(self, other: Self) -> Self { + let value = self.value - other.value; + assert(value != 0); + NonZero { value } + } +} +``` + +## Overlapping Implementations + +Overlapping implementations are disallowed by Noir to ensure Noir's decision on which impl to select is never ambiguous. +This means if a trait `Foo` is already implemented +by a type `Bar` for all `T`, then we cannot also have a separate impl for `Bar` (or any other +type argument). Similarly, if there is an impl for all `T` such as `impl Debug for T`, we cannot create +any more impls to `Debug` for other types since it would be ambiguous which impl to choose for any given +method call. + +```rust +trait Trait {} + +// Previous impl defined here +impl Trait for (A, B) {} + +// error: Impl for type `(Field, Field)` overlaps with existing impl +impl Trait for (Field, Field) {} +``` + +## Trait Coherence + +Another restriction on trait implementations is coherence. This restriction ensures other crates cannot create +impls that may overlap with other impls, even if several unrelated crates are used as dependencies in the same +program. + +The coherence restriction is: to implement a trait, either the trait itself or the object type must be declared +in the crate the impl is in. + +In practice this often comes up when using types provided by libraries. If a library provides a type `Foo` that does +not implement a trait in the standard library such as `Default`, you may not `impl Default for Foo` in your own crate. +While restrictive, this prevents later issues or silent changes in the program if the `Foo` library later added its +own impl for `Default`. If you are a user of the `Foo` library in this scenario and need a trait not implemented by the +library your choices are to either submit a patch to the library or use the newtype pattern. + +### The Newtype Pattern + +The newtype pattern gets around the coherence restriction by creating a new wrapper type around the library type +that we cannot create `impl`s for. Since the new wrapper type is defined in our current crate, we can create +impls for any trait we need on it. + +```rust +struct Wrapper { + foo: some_library::Foo, +} + +impl Default for Wrapper { + fn default() -> Wrapper { + Wrapper { + foo: some_library::Foo::new(), + } + } +} +``` + +Since we have an impl for our own type, the behavior of this code will not change even if `some_library` is updated +to provide its own `impl Default for Foo`. The downside of this pattern is that it requires extra wrapping and +unwrapping of values when converting to and from the `Wrapper` and `Foo` types. + +### Trait Inheritance + +Sometimes, you might need one trait to use another trait’s functionality (like "inheritance" in some other languages). In this case, you can specify this relationship by listing any child traits after the parent trait's name and a colon. Now, whenever the parent trait is implemented it will require the child traits to be implemented as well. A parent trait is also called a "super trait." + +```rust +trait Person { + fn name(self) -> String; +} + +// Person is a supertrait of Student. +// Implementing Student requires you to also impl Person. +trait Student: Person { + fn university(self) -> String; +} + +trait Programmer { + fn fav_language(self) -> String; +} + +// CompSciStudent (computer science student) is a subtrait of both Programmer +// and Student. Implementing CompSciStudent requires you to impl both supertraits. +trait CompSciStudent: Programmer + Student { + fn git_username(self) -> String; +} +``` + +### Visibility + +By default, like functions, traits are private to the module they exist in. You can use `pub` +to make the trait public or `pub(crate)` to make it public to just its crate: + +```rust +// This trait is now public +pub trait Trait {} +``` \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/unconstrained.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/unconstrained.md new file mode 100644 index 000000000000..b5221b8d2ddf --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/concepts/unconstrained.md @@ -0,0 +1,104 @@ +--- +title: Unconstrained Functions +description: "Learn about what unconstrained functions in Noir are, how to use them and when you'd want to." + +keywords: [Noir programming language, unconstrained, open] +sidebar_position: 5 +--- + +Unconstrained functions are functions which do not constrain any of the included computation and allow for non-deterministic computation. + +## Why? + +Zero-knowledge (ZK) domain-specific languages (DSL) enable developers to generate ZK proofs from their programs by compiling code down to the constraints of an NP complete language (such as R1CS or PLONKish languages). However, the hard bounds of a constraint system can be very limiting to the functionality of a ZK DSL. + +Enabling a circuit language to perform unconstrained execution is a powerful tool. Said another way, unconstrained execution lets developers generate witnesses from code that does not generate any constraints. Being able to execute logic outside of a circuit is critical for both circuit performance and constructing proofs on information that is external to a circuit. + +Fetching information from somewhere external to a circuit can also be used to enable developers to improve circuit efficiency. + +A ZK DSL does not just prove computation, but proves that some computation was handled correctly. Thus, it is necessary that when we switch from performing some operation directly inside of a circuit to inside of an unconstrained environment that the appropriate constraints are still laid down elsewhere in the circuit. + +## Example + +An in depth example might help drive the point home. This example comes from the excellent [post](https://discord.com/channels/1113924620781883405/1124022445054111926/1128747641853972590) by Tom in the Noir Discord. + +Let's look at how we can optimize a function to turn a `u72` into an array of `u8`s. + +```rust +fn main(num: u72) -> pub [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8)) as u72 & 0xff) as u8; + } + + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 91 +Backend circuit size: 3619 +``` + +A lot of the operations in this function are optimized away by the compiler (all the bit-shifts turn into divisions by constants). However we can save a bunch of gates by casting to u8 a bit earlier. This automatically truncates the bit-shifted value to fit in a u8 which allows us to remove the AND against 0xff. This saves us ~480 gates in total. + +```rust +fn main(num: u72) -> pub [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8)) as u8; + } + + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 75 +Backend circuit size: 3143 +``` + +Those are some nice savings already but we can do better. This code is all constrained so we're proving every step of calculating out using num, but we don't actually care about how we calculate this, just that it's correct. This is where brillig comes in. + +It turns out that truncating a u72 into a u8 is hard to do inside a snark, each time we do as u8 we lay down 4 ACIR opcodes which get converted into multiple gates. It's actually much easier to calculate num from out than the other way around. All we need to do is multiply each element of out by a constant and add them all together, both relatively easy operations inside a snark. + +We can then run `u72_to_u8` as unconstrained brillig code in order to calculate out, then use that result in our constrained function and assert that if we were to do the reverse calculation we'd get back num. This looks a little like the below: + +```rust +fn main(num: u72) -> pub [u8; 8] { + let out = unsafe { + u72_to_u8(num) + }; + + let mut reconstructed_num: u72 = 0; + for i in 0..8 { + reconstructed_num += (out[i] as u72 << (56 - (8 * i))); + } + assert(num == reconstructed_num); + out +} + +unconstrained fn u72_to_u8(num: u72) -> [u8; 8] { + let mut out: [u8; 8] = [0; 8]; + for i in 0..8 { + out[i] = (num >> (56 - (i * 8))) as u8; + } + out +} +``` + +``` +Total ACIR opcodes generated for language PLONKCSat { width: 3 }: 78 +Backend circuit size: 2902 +``` + +This ends up taking off another ~250 gates from our circuit! We've ended up with more ACIR opcodes than before but they're easier for the backend to prove (resulting in fewer gates). + +Note that in order to invoke unconstrained functions we need to wrap them in an `unsafe` block, +to make it clear that the call is unconstrained. + +Generally we want to use brillig whenever there's something that's easy to verify but hard to compute within the circuit. For example, if you wanted to calculate a square root of a number it'll be a much better idea to calculate this in brillig and then assert that if you square the result you get back your number. + +## Break and Continue + +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/_category_.json new file mode 100644 index 000000000000..1debcfe76753 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Modules, Packages and Crates", + "position": 2, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/crates_and_packages.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/crates_and_packages.md new file mode 100644 index 000000000000..95ee9f52ab21 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/crates_and_packages.md @@ -0,0 +1,43 @@ +--- +title: Crates and Packages +description: Learn how to use Crates and Packages in your Noir project +keywords: [Nargo, dependencies, package management, crates, package] +sidebar_position: 0 +--- + +## Crates + +A crate is the smallest amount of code that the Noir compiler considers at a time. +Crates can contain modules, and the modules may be defined in other files that get compiled with the crate, as we’ll see in the coming sections. + +### Crate Types + +A Noir crate can come in several forms: binaries, libraries or contracts. + +#### Binaries + +_Binary crates_ are programs which you can compile to an ACIR circuit which you can then create proofs against. Each must have a function called `main` that defines the ACIR circuit which is to be proved. + +#### Libraries + +_Library crates_ don't have a `main` function and they don't compile down to ACIR. Instead they define functionality intended to be shared with multiple projects, and eventually included in a binary crate. + +#### Contracts + +Contract crates are similar to binary crates in that they compile to ACIR which you can create proofs against. They are different in that they do not have a single `main` function, but are a collection of functions to be deployed to the [Aztec network](https://aztec.network). You can learn more about the technical details of Aztec in the [monorepo](https://github.com/AztecProtocol/aztec-packages) or contract [examples](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/noir-contracts/contracts). + +### Crate Root + +Every crate has a root, which is the source file that the compiler starts, this is also known as the root module. The Noir compiler does not enforce any conditions on the name of the file which is the crate root, however if you are compiling via Nargo the crate root must be called `lib.nr` or `main.nr` for library or binary crates respectively. + +## Packages + +A Nargo _package_ is a collection of one of more crates that provides a set of functionality. A package must include a Nargo.toml file. + +A package _must_ contain either a library or a binary crate, but not both. + +### Differences from Cargo Packages + +One notable difference between Rust's Cargo and Noir's Nargo is that while Cargo allows a package to contain an unlimited number of binary crates and a single library crate, Nargo currently only allows a package to contain a single crate. + +In future this restriction may be lifted to allow a Nargo package to contain both a binary and library crate or multiple binary crates. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/dependencies.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/dependencies.md new file mode 100644 index 000000000000..24e02de08fe8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/dependencies.md @@ -0,0 +1,124 @@ +--- +title: Dependencies +description: + Learn how to specify and manage dependencies in Nargo, allowing you to upload packages to GitHub + and use them easily in your project. +keywords: [Nargo, dependencies, GitHub, package management, versioning] +sidebar_position: 1 +--- + +Nargo allows you to upload packages to GitHub and use them as dependencies. + +## Specifying a dependency + +Specifying a dependency requires a tag to a specific commit and the git url to the url containing +the package. + +Currently, there are no requirements on the tag contents. If requirements are added, it would follow +semver 2.0 guidelines. + +> Note: Without a `tag` , there would be no versioning and dependencies would change each time you +> compile your project. + +For example, to add the [ecrecover-noir library](https://github.com/colinnielsen/ecrecover-noir) to your project, add it to `Nargo.toml`: + +```toml +# Nargo.toml + +[dependencies] +ecrecover = {tag = "v0.8.0", git = "https://github.com/colinnielsen/ecrecover-noir"} +``` + +If the module is in a subdirectory, you can define a subdirectory in your git repository, for example: + +```toml +# Nargo.toml + +[dependencies] +easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "https://github.com/AztecProtocol/aztec-packages", directory = "noir-contracts/contracts/easy_private_token_contract"} +``` + +## Specifying a local dependency + +You can also specify dependencies that are local to your machine. + +For example, this file structure has a library and binary crate + +```tree +├── binary_crate +│   ├── Nargo.toml +│   └── src +│   └── main.nr +└── lib_a + ├── Nargo.toml + └── src + └── lib.nr +``` + +Inside of the binary crate, you can specify: + +```toml +# Nargo.toml + +[dependencies] +lib_a = { path = "../lib_a" } +``` + +## Importing dependencies + +You can import a dependency to a Noir file using the following syntax. For example, to import the +ecrecover-noir library and local lib_a referenced above: + +```rust +use ecrecover; +use lib_a; +``` + +You can also import only the specific parts of dependency that you want to use, like so: + +```rust +use std::hash::sha256; +use std::scalar_mul::fixed_base_embedded_curve; +``` + +Lastly, as demonstrated in the +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you +can import multiple items in the same line by enclosing them in curly braces: + +```rust +use std::ec::tecurve::affine::{Curve, Point}; +``` + +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. + +Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. + +## Dependencies of Dependencies + +Note that when you import a dependency, you also get access to all of the dependencies of that package. + +For example, the [phy_vector](https://github.com/resurgencelabs/phy_vector) library imports an [fraction](https://github.com/resurgencelabs/fraction) library. If you're importing the phy_vector library, then you can access the functions in fractions library like so: + +```rust +use phy_vector; + +fn main(x : Field, y : pub Field) { + //... + let f = phy_vector::fraction::toFraction(true, 2, 1); + //... +} +``` + +## Available Libraries + +Noir does not currently have an official package manager. You can find a list of available Noir libraries in the [awesome-noir repo here](https://github.com/noir-lang/awesome-noir#libraries). + +Some libraries that are available today include: + +- [Standard Library](https://github.com/noir-lang/noir/tree/master/noir_stdlib) - the Noir Standard Library +- [Ethereum Storage Proof Verification](https://github.com/aragonzkresearch/noir-trie-proofs) - a library that contains the primitives necessary for RLP decoding (in the form of look-up table construction) and Ethereum state and storage proof verification (or verification of any trie proof involving 32-byte long keys) +- [BigInt](https://github.com/shuklaayush/noir-bigint) - a library that provides a custom BigUint56 data type, allowing for computations on large unsigned integers +- [ECrecover](https://github.com/colinnielsen/ecrecover-noir/tree/main) - a library to verify an ECDSA signature and return the source Ethereum address +- [Sparse Merkle Tree Verifier](https://github.com/vocdoni/smtverifier-noir/tree/main) - a library for verification of sparse Merkle trees +- [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir +- [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/modules.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/modules.md new file mode 100644 index 000000000000..14aa1f0579ac --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/modules.md @@ -0,0 +1,221 @@ +--- +title: Modules +description: + Learn how to organize your files using modules in Noir, following the same convention as Rust's + module system. Examples included. +keywords: [Noir, Rust, modules, organizing files, sub-modules] +sidebar_position: 2 +--- + +Noir's module system follows the same convention as the _newer_ version of Rust's module system. + +## Purpose of Modules + +Modules are used to organize files. Without modules all of your code would need to live in a single +file. In Noir, the compiler does not automatically scan all of your files to detect modules. This +must be done explicitly by the developer. + +## Examples + +### Importing a module in the crate root + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::hello_world(); +} +``` + +Filename : `src/foo.nr` + +```rust +fn from_foo() {} +``` + +In the above snippet, the crate root is the `src/main.nr` file. The compiler sees the module +declaration `mod foo` which prompts it to look for a foo.nr file. + +Visually this module hierarchy looks like the following : + +``` +crate + ├── main + │ + └── foo + └── from_foo + +``` + +The module filename may also be the name of the module as a directory with the contents in a +file named `mod.nr` within that directory. The above example can alternatively be expressed like this: + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::hello_world(); +} +``` + +Filename : `src/foo/mod.nr` + +```rust +fn from_foo() {} +``` + +Note that it's an error to have both files `src/foo.nr` and `src/foo/mod.nr` in the filesystem. + +### Importing a module throughout the tree + +All modules are accessible from the `crate::` namespace. + +``` +crate + ├── bar + ├── foo + └── main + +``` + +In the above snippet, if `bar` would like to use functions in `foo`, it can do so by `use crate::foo::function_name`. + +### Sub-modules + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::from_foo(); +} +``` + +Filename : `src/foo.nr` + +```rust +mod bar; +fn from_foo() {} +``` + +Filename : `src/foo/bar.nr` + +```rust +fn from_bar() {} +``` + +In the above snippet, we have added an extra module to the module tree; `bar`. `bar` is a submodule +of `foo` hence we declare bar in `foo.nr` with `mod bar`. Since `foo` is not the crate root, the +compiler looks for the file associated with the `bar` module in `src/foo/bar.nr` + +Visually the module hierarchy looks as follows: + +``` +crate + ├── main + │ + └── foo + ├── from_foo + └── bar + └── from_bar +``` + +Similar to importing a module in the crate root, modules can be placed in a `mod.nr` file, like this: + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::from_foo(); +} +``` + +Filename : `src/foo/mod.nr` + +```rust +mod bar; +fn from_foo() {} +``` + +Filename : `src/foo/bar/mod.nr` + +```rust +fn from_bar() {} +``` + +### Referencing a parent module + +Given a submodule, you can refer to its parent module using the `super` keyword. + +Filename : `src/main.nr` + +```rust +mod foo; + +fn main() { + foo::from_foo(); +} +``` + +Filename : `src/foo.nr` + +```rust +mod bar; + +fn from_foo() {} +``` + +Filename : `src/foo/bar.nr` + +```rust +// Same as bar::from_foo +use super::from_foo; + +fn from_bar() { + from_foo(); // invokes super::from_foo(), which is bar::from_foo() + super::from_foo(); // also invokes bar::from_foo() +} +``` + +### `use` visibility + +`use` declarations are private to the containing module, by default. However, like functions, +they can be marked as `pub` or `pub(crate)`. Such a use declaration serves to _re-export_ a name. +A public `use` declaration can therefore redirect some public name to a different target definition: +even a definition with a private canonical path, inside a different module. + +An example of re-exporting: + +```rust +mod some_module { + pub use foo::{bar, baz}; + mod foo { + pub fn bar() {} + pub fn baz() {} + } +} + +fn main() { + some_module::bar(); + some_module::baz(); +} +``` + +In this example, the module `some_module` re-exports two public names defined in `foo`. + +### Visibility + +By default, like functions, modules are private to the module (or crate) they exist in. You can use `pub` +to make the module public or `pub(crate)` to make it public to just its crate: + +```rust +// This module is now public and can be seen by other crates. +pub mod foo; +``` \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/workspaces.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/workspaces.md new file mode 100644 index 000000000000..513497f12bf7 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/modules_packages_crates/workspaces.md @@ -0,0 +1,42 @@ +--- +title: Workspaces +sidebar_position: 3 +--- + +Workspaces are a feature of nargo that allow you to manage multiple related Noir packages in a single repository. A workspace is essentially a group of related projects that share common build output directories and configurations. + +Each Noir project (with it's own Nargo.toml file) can be thought of as a package. Each package is expected to contain exactly one "named circuit", being the "name" defined in Nargo.toml with the program logic defined in `./src/main.nr`. + +For a project with the following structure: + +```tree +├── crates +│ ├── a +│ │ ├── Nargo.toml +│ │ └── Prover.toml +│ │ └── src +│ │ └── main.nr +│ └── b +│ ├── Nargo.toml +│ └── Prover.toml +│ └── src +│ └── main.nr +│ +└── Nargo.toml +``` + +You can define a workspace in Nargo.toml like so: + +```toml +[workspace] +members = ["crates/a", "crates/b"] +default-member = "crates/a" +``` + +`members` indicates which packages are included in the workspace. As such, all member packages of a workspace will be processed when the `--workspace` flag is used with various commands or if a `default-member` is not specified. + +`default-member` indicates which package various commands process by default. + +Libraries can be defined in a workspace. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. + +Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/_category_.json new file mode 100644 index 000000000000..af04c0933fdb --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Standard Library", + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bigint.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bigint.md new file mode 100644 index 000000000000..05c3011634f4 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bigint.md @@ -0,0 +1,127 @@ +--- +title: Big Integers +description: How to use big integers from Noir standard library +keywords: + [ + Big Integer, + Noir programming language, + Noir libraries, + ] +--- + +The BigInt module in the standard library exposes some class of integers which do not fit (well) into a Noir native field. It implements modulo arithmetic, modulo a 'big' prime number. + +:::note + +The module can currently be considered as `Field`s with fixed modulo sizes used by a set of elliptic curves, in addition to just the native curve. [More work](https://github.com/noir-lang/noir/issues/510) is needed to achieve arbitrarily sized big integers. + +:::note + +`nargo` can be built with `--profile release-pedantic` to enable extra overflow checks which may affect `BigInt` results in some cases. +Consider the [`noir-bignum`](https://github.com/noir-lang/noir-bignum) library for an optimized alternative approach. + +::: + +Currently 6 classes of integers (i.e 'big' prime numbers) are available in the module, namely: + +- BN254 Fq: Bn254Fq +- BN254 Fr: Bn254Fr +- Secp256k1 Fq: Secpk1Fq +- Secp256k1 Fr: Secpk1Fr +- Secp256r1 Fr: Secpr1Fr +- Secp256r1 Fq: Secpr1Fq + +Where XXX Fq and XXX Fr denote respectively the order of the base and scalar field of the (usual) elliptic curve XXX. +For instance the big integer 'Secpk1Fq' in the standard library refers to integers modulo $2^{256}-2^{32}-977$. + +Feel free to explore the source code for the other primes: + +```rust title="big_int_definition" showLineNumbers +pub struct BigInt { + pointer: u32, + modulus: u32, +} +``` +> Source code: noir_stdlib/src/bigint.nr#L28-L33 + + +## Example usage + +A common use-case is when constructing a big integer from its bytes representation, and performing arithmetic operations on it: + +```rust title="big_int_example" showLineNumbers +fn big_int_example(x: u8, y: u8) { + let a = Secpk1Fq::from_le_bytes(&[x, y, 0, 45, 2]); + let b = Secpk1Fq::from_le_bytes(&[y, x, 9]); + let c = (a + b) * b / a; + let d = c.to_le_bytes(); + println(d[0]); +} +``` +> Source code: test_programs/execution_success/bigint/src/main.nr#L74-L82 + + +## Methods + +The available operations for each big integer are: + +### from_le_bytes + +Construct a big integer from its little-endian bytes representation. Example: + +```rust + // Construct a big integer from a slice of bytes + let a = Secpk1Fq::from_le_bytes(&[x, y, 0, 45, 2]); + // Construct a big integer from an array of 32 bytes + let a = Secpk1Fq::from_le_bytes_32([1;32]); + ``` + +Sure, here's the formatted version of the remaining methods: + +### to_le_bytes + +Return the little-endian bytes representation of a big integer. Example: + +```rust +let bytes = a.to_le_bytes(); +``` + +### add + +Add two big integers. Example: + +```rust +let sum = a + b; +``` + +### sub + +Subtract two big integers. Example: + +```rust +let difference = a - b; +``` + +### mul + +Multiply two big integers. Example: + +```rust +let product = a * b; +``` + +### div + +Divide two big integers. Note that division is field division and not euclidean division. Example: + +```rust +let quotient = a / b; +``` + +### eq + +Compare two big integers. Example: + +```rust +let are_equal = a == b; +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/black_box_fns.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/black_box_fns.md new file mode 100644 index 000000000000..d6079ab182c1 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/black_box_fns.md @@ -0,0 +1,32 @@ +--- +title: Black Box Functions +description: Black box functions are functions in Noir that rely on backends implementing support for specialized constraints. +keywords: [noir, black box functions] +--- + +Black box functions are functions in Noir that rely on backends implementing support for specialized constraints. This makes certain zk-snark unfriendly computations cheaper than if they were implemented in Noir. + +The ACVM spec defines a set of blackbox functions which backends will be expected to implement. This allows backends to use optimized implementations of these constraints if they have them, however they may also fallback to less efficient naive implementations if not. + +## Function list + +Here is a list of the current black box functions: + +- [AES128](./cryptographic_primitives/ciphers.mdx#aes128) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Blake3](./cryptographic_primitives/hashes.mdx#blake3) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Embedded curve operations (MSM, addition, ...)](./cryptographic_primitives/embedded_curve_ops.mdx) +- AND +- XOR +- RANGE +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.mdx) + +Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. + +You can view the black box functions defined in the ACVM code [here](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/circuit/black_box_functions.rs). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bn254.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bn254.md new file mode 100644 index 000000000000..3294f005dbb4 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/bn254.md @@ -0,0 +1,46 @@ +--- +title: Bn254 Field Library +--- + +Noir provides a module in standard library with some optimized functions for bn254 Fr in `std::field::bn254`. + +## decompose + +```rust +fn decompose(x: Field) -> (Field, Field) {} +``` + +Decomposes a single field into two fields, low and high. The low field contains the lower 16 bytes of the input field and the high field contains the upper 16 bytes of the input field. Both field results are range checked to 128 bits. + + +## assert_gt + +```rust +fn assert_gt(a: Field, b: Field) {} +``` + +Asserts that a > b. This will generate less constraints than using `assert(gt(a, b))`. + +## assert_lt + +```rust +fn assert_lt(a: Field, b: Field) {} +``` + +Asserts that a < b. This will generate less constraints than using `assert(lt(a, b))`. + +## gt + +```rust +fn gt(a: Field, b: Field) -> bool {} +``` + +Returns true if a > b. + +## lt + +```rust +fn lt(a: Field, b: Field) -> bool {} +``` + +Returns true if a < b. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/boundedvec.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/boundedvec.md new file mode 100644 index 000000000000..509b214bf3a3 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/boundedvec.md @@ -0,0 +1,419 @@ +--- +title: Bounded Vectors +keywords: [noir, vector, bounded vector, slice] +sidebar_position: 1 +--- + +A `BoundedVec` is a growable storage similar to a `Vec` except that it +is bounded with a maximum possible length. Unlike `Vec`, `BoundedVec` is not implemented +via slices and thus is not subject to the same restrictions slices are (notably, nested +slices - and thus nested vectors as well - are disallowed). + +Since a BoundedVec is backed by a normal array under the hood, growing the BoundedVec by +pushing an additional element is also more efficient - the length only needs to be increased +by one. + +For these reasons `BoundedVec` should generally be preferred over `Vec` when there +is a reasonable maximum bound that can be placed on the vector. + +Example: + +```rust +let mut vector: BoundedVec = BoundedVec::new(); +for i in 0..5 { + vector.push(i); +} +assert(vector.len() == 5); +assert(vector.max_len() == 10); +``` + +## Methods + +### new + +```rust +pub fn new() -> Self +``` + +Creates a new, empty vector of length zero. + +Since this container is backed by an array internally, it still needs an initial value +to give each element. To resolve this, each element is zeroed internally. This value +is guaranteed to be inaccessible unless `get_unchecked` is used. + +Example: + +```rust +let empty_vector: BoundedVec = BoundedVec::new(); +assert(empty_vector.len() == 0); +``` + +Note that whenever calling `new` the maximum length of the vector should always be specified +via a type signature: + +```rust title="new_example" showLineNumbers +fn good() -> BoundedVec { + // Ok! MaxLen is specified with a type annotation + let v1: BoundedVec = BoundedVec::new(); + let v2 = BoundedVec::new(); + + // Ok! MaxLen is known from the type of `good`'s return value + v2 +} + +fn bad() { + // Error: Type annotation needed + // The compiler can't infer `MaxLen` from this code. + let mut v3 = BoundedVec::new(); + v3.push(5); +} +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L11-L27 + + +This defaulting of `MaxLen` (and numeric generics in general) to zero may change in future noir versions +but for now make sure to use type annotations when using bounded vectors. Otherwise, you will receive a constraint failure at runtime when the vec is pushed to. + +### get + +```rust +pub fn get(self, index: u64) -> T { +``` + +Retrieves an element from the vector at the given index, starting from zero. + +If the given index is equal to or greater than the length of the vector, this +will issue a constraint failure. + +Example: + +```rust +fn foo(v: BoundedVec) { + let first = v.get(0); + let last = v.get(v.len() - 1); + assert(first != last); +} +``` + +### get_unchecked + +```rust +pub fn get_unchecked(self, index: u64) -> T { +``` + +Retrieves an element from the vector at the given index, starting from zero, without +performing a bounds check. + +Since this function does not perform a bounds check on length before accessing the element, +it is unsafe! Use at your own risk! + +Example: + +```rust title="get_unchecked_example" showLineNumbers +fn sum_of_first_three(v: BoundedVec) -> u32 { + // Always ensure the length is larger than the largest + // index passed to get_unchecked + assert(v.len() > 2); + let first = v.get_unchecked(0); + let second = v.get_unchecked(1); + let third = v.get_unchecked(2); + first + second + third +} +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L54-L64 + + +### set + +```rust +pub fn set(&mut self: Self, index: u64, value: T) { +``` + +Writes an element to the vector at the given index, starting from zero. + +If the given index is equal to or greater than the length of the vector, this will issue a constraint failure. + +Example: + +```rust +fn foo(v: BoundedVec) { + let first = v.get(0); + assert(first != 42); + v.set(0, 42); + let new_first = v.get(0); + assert(new_first == 42); +} +``` + +### set_unchecked + +```rust +pub fn set_unchecked(&mut self: Self, index: u64, value: T) -> T { +``` + +Writes an element to the vector at the given index, starting from zero, without performing a bounds check. + +Since this function does not perform a bounds check on length before accessing the element, it is unsafe! Use at your own risk! + +Example: + +```rust title="set_unchecked_example" showLineNumbers +fn set_unchecked_example() { + let mut vec: BoundedVec = BoundedVec::new(); + vec.extend_from_array([1, 2]); + + // Here we're safely writing within the valid range of `vec` + // `vec` now has the value [42, 2] + vec.set_unchecked(0, 42); + + // We can then safely read this value back out of `vec`. + // Notice that we use the checked version of `get` which would prevent reading unsafe values. + assert_eq(vec.get(0), 42); + + // We've now written past the end of `vec`. + // As this index is still within the maximum potential length of `v`, + // it won't cause a constraint failure. + vec.set_unchecked(2, 42); + println(vec); + + // This will write past the end of the maximum potential length of `vec`, + // it will then trigger a constraint failure. + vec.set_unchecked(5, 42); + println(vec); +} +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L67-L91 + + + +### push + +```rust +pub fn push(&mut self, elem: T) { +``` + +Pushes an element to the end of the vector. This increases the length +of the vector by one. + +Panics if the new length of the vector will be greater than the max length. + +Example: + +```rust title="bounded-vec-push-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + v.push(1); + v.push(2); + + // Panics with failed assertion "push out of bounds" + v.push(3); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L95-L103 + + +### pop + +```rust +pub fn pop(&mut self) -> T +``` + +Pops the element at the end of the vector. This will decrease the length +of the vector by one. + +Panics if the vector is empty. + +Example: + +```rust title="bounded-vec-pop-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + v.push(1); + v.push(2); + + let two = v.pop(); + let one = v.pop(); + + assert(two == 2); + assert(one == 1); + // error: cannot pop from an empty vector + // let _ = v.pop(); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L108-L120 + + +### len + +```rust +pub fn len(self) -> u64 { +``` + +Returns the current length of this vector + +Example: + +```rust title="bounded-vec-len-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + assert(v.len() == 0); + + v.push(100); + assert(v.len() == 1); + + v.push(200); + v.push(300); + v.push(400); + assert(v.len() == 4); + + let _ = v.pop(); + let _ = v.pop(); + assert(v.len() == 2); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L125-L140 + + +### max_len + +```rust +pub fn max_len(_self: BoundedVec) -> u64 { +``` + +Returns the maximum length of this vector. This is always +equal to the `MaxLen` parameter this vector was initialized with. + +Example: + +```rust title="bounded-vec-max-len-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + assert(v.max_len() == 5); + v.push(10); + assert(v.max_len() == 5); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L145-L151 + + +### storage + +```rust +pub fn storage(self) -> [T; MaxLen] { +``` + +Returns the internal array within this vector. +Since arrays in Noir are immutable, mutating the returned storage array will not mutate +the storage held internally by this vector. + +Note that uninitialized elements may be zeroed out! + +Example: + +```rust title="bounded-vec-storage-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + + assert(v.storage() == [0, 0, 0, 0, 0]); + + v.push(57); + assert(v.storage() == [57, 0, 0, 0, 0]); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L156-L163 + + +### extend_from_array + +```rust +pub fn extend_from_array(&mut self, array: [T; Len]) +``` + +Pushes each element from the given array to this vector. + +Panics if pushing each element would cause the length of this vector +to exceed the maximum length. + +Example: + +```rust title="bounded-vec-extend-from-array-example" showLineNumbers +let mut vec: BoundedVec = BoundedVec::new(); + vec.extend_from_array([2, 4]); + + assert(vec.len == 2); + assert(vec.get(0) == 2); + assert(vec.get(1) == 4); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L168-L175 + + +### extend_from_bounded_vec + +```rust +pub fn extend_from_bounded_vec(&mut self, vec: BoundedVec) +``` + +Pushes each element from the other vector to this vector. The length of +the other vector is left unchanged. + +Panics if pushing each element would cause the length of this vector +to exceed the maximum length. + +Example: + +```rust title="bounded-vec-extend-from-bounded-vec-example" showLineNumbers +let mut v1: BoundedVec = BoundedVec::new(); + let mut v2: BoundedVec = BoundedVec::new(); + + v2.extend_from_array([1, 2, 3]); + v1.extend_from_bounded_vec(v2); + + assert(v1.storage() == [1, 2, 3, 0, 0]); + assert(v2.storage() == [1, 2, 3, 0, 0, 0, 0]); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L180-L189 + + +### from_array + +```rust +pub fn from_array(array: [T; Len]) -> Self +``` + +Creates a new vector, populating it with values derived from an array input. +The maximum length of the vector is determined based on the type signature. + +Example: +```rust +let bounded_vec: BoundedVec = BoundedVec::from_array([1, 2, 3]) +``` + +### map + +```rust +pub fn map(self, f: fn[Env](T) -> U) -> BoundedVec +``` + +Creates a new vector of equal size by calling a closure on each element in this vector. + +Example: + +```rust title="bounded-vec-map-example" showLineNumbers +let vec: BoundedVec = BoundedVec::from_array([1, 2, 3, 4]); + let result = vec.map(|value| value * 2); +``` +> Source code: noir_stdlib/src/collections/bounded_vec.nr#L495-L498 + + +### any + +```rust +pub fn any(self, predicate: fn[Env](T) -> bool) -> bool +``` + +Returns true if the given predicate returns true for any element +in this vector. + +Example: + +```rust title="bounded-vec-any-example" showLineNumbers +let mut v: BoundedVec = BoundedVec::new(); + v.extend_from_array([2, 4, 6]); + + let all_even = !v.any(|elem: u32| elem % 2 != 0); + assert(all_even); +``` +> Source code: test_programs/noir_test_success/bounded_vec/src/main.nr#L256-L262 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/hashmap.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/hashmap.md new file mode 100644 index 000000000000..395cc312705f --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/hashmap.md @@ -0,0 +1,587 @@ +--- +title: HashMap +keywords: [noir, map, hash, hashmap] +sidebar_position: 1 +--- + +`HashMap` is used to efficiently store and look up key-value pairs. + +`HashMap` is a bounded type which can store anywhere from zero to `MaxLen` total elements. +Note that due to hash collisions, the actual maximum number of elements stored by any particular +hashmap is likely lower than `MaxLen`. This is true even with cryptographic hash functions since +every hash value will be performed modulo `MaxLen`. + +Example: + +```rust +// Create a mapping from Fields to u32s with a maximum length of 12 +// using a poseidon2 hasher +use std::hash::poseidon2::Poseidon2Hasher; +let mut map: HashMap> = HashMap::default(); + +map.insert(1, 2); +map.insert(3, 4); + +let two = map.get(1).unwrap(); +``` + +## Methods + +### default + +```rust title="default" showLineNumbers +impl Default for HashMap +where + B: BuildHasher + Default, + H: Hasher + Default, +{ + /// Constructs an empty HashMap. + /// + /// Example: + /// + /// ```noir + /// let hashmap: HashMap> = HashMap::default(); + /// assert(hashmap.is_empty()); + /// ``` + fn default() -> Self { +``` +> Source code: noir_stdlib/src/collections/map.nr#L681-L696 + + +Creates a fresh, empty HashMap. + +When using this function, always make sure to specify the maximum size of the hash map. + +This is the same `default` from the `Default` implementation given further below. It is +repeated here for convenience since it is the recommended way to create a hashmap. + +Example: + +```rust title="default_example" showLineNumbers +let hashmap: HashMap> = HashMap::default(); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L207-L210 + + +Because `HashMap` has so many generic arguments that are likely to be the same throughout +your program, it may be helpful to create a type alias: + +```rust title="type_alias" showLineNumbers +type MyMap = HashMap>; +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L201-L203 + + +### with_hasher + +```rust title="with_hasher" showLineNumbers +pub fn with_hasher(_build_hasher: B) -> Self + where + B: BuildHasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L103-L108 + + +Creates a hashmap with an existing `BuildHasher`. This can be used to ensure multiple +hashmaps are created with the same hasher instance. + +Example: + +```rust title="with_hasher_example" showLineNumbers +let my_hasher: BuildHasherDefault = Default::default(); + let hashmap: HashMap> = + HashMap::with_hasher(my_hasher); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L211-L216 + + +### get + +```rust title="get" showLineNumbers +pub fn get(self, key: K) -> Option + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L465-L472 + + +Retrieves a value from the hashmap, returning `Option::none()` if it was not found. + +Example: + +```rust title="get_example" showLineNumbers +fn get_example(map: HashMap>) { + let x = map.get(12); + + if x.is_some() { + assert(x.unwrap() == 42); + } +} +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L296-L304 + + +### insert + +```rust title="insert" showLineNumbers +pub fn insert(&mut self, key: K, value: V) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L507-L514 + + +Inserts a new key-value pair into the map. If the key was already in the map, its +previous value will be overridden with the newly provided one. + +Example: + +```rust title="insert_example" showLineNumbers +let mut map: HashMap> = HashMap::default(); + map.insert(12, 42); + assert(map.len() == 1); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L217-L221 + + +### remove + +```rust title="remove" showLineNumbers +pub fn remove(&mut self, key: K) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L563-L570 + + +Removes the given key-value pair from the map. If the key was not already present +in the map, this does nothing. + +Example: + +```rust title="remove_example" showLineNumbers +map.remove(12); + assert(map.is_empty()); + + // If a key was not present in the map, remove does nothing + map.remove(12); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L224-L231 + + +### is_empty + +```rust title="is_empty" showLineNumbers +pub fn is_empty(self) -> bool { +``` +> Source code: noir_stdlib/src/collections/map.nr#L167-L169 + + +True if the length of the hash map is empty. + +Example: + +```rust title="is_empty_example" showLineNumbers +assert(map.is_empty()); + + map.insert(1, 2); + assert(!map.is_empty()); + + map.remove(1); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L232-L240 + + +### len + +```rust title="len" showLineNumbers +pub fn len(self) -> u32 { +``` +> Source code: noir_stdlib/src/collections/map.nr#L424-L426 + + +Returns the current length of this hash map. + +Example: + +```rust title="len_example" showLineNumbers +// This is equivalent to checking map.is_empty() + assert(map.len() == 0); + + map.insert(1, 2); + map.insert(3, 4); + map.insert(5, 6); + assert(map.len() == 3); + + // 3 was already present as a key in the hash map, so the length is unchanged + map.insert(3, 7); + assert(map.len() == 3); + + map.remove(1); + assert(map.len() == 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L241-L256 + + +### capacity + +```rust title="capacity" showLineNumbers +pub fn capacity(_self: Self) -> u32 { +``` +> Source code: noir_stdlib/src/collections/map.nr#L446-L448 + + +Returns the maximum capacity of this hashmap. This is always equal to the capacity +specified in the hashmap's type. + +Unlike hashmaps in general purpose programming languages, hashmaps in Noir have a +static capacity that does not increase as the map grows larger. Thus, this capacity +is also the maximum possible element count that can be inserted into the hashmap. +Due to hash collisions (modulo the hashmap length), it is likely the actual maximum +element count will be lower than the full capacity. + +Example: + +```rust title="capacity_example" showLineNumbers +let empty_map: HashMap> = + HashMap::default(); + assert(empty_map.len() == 0); + assert(empty_map.capacity() == 42); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L257-L262 + + +### clear + +```rust title="clear" showLineNumbers +pub fn clear(&mut self) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L123-L125 + + +Clears the hashmap, removing all key-value pairs from it. + +Example: + +```rust title="clear_example" showLineNumbers +assert(!map.is_empty()); + map.clear(); + assert(map.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L263-L267 + + +### contains_key + +```rust title="contains_key" showLineNumbers +pub fn contains_key(self, key: K) -> bool + where + K: Hash + Eq, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L143-L150 + + +True if the hashmap contains the given key. Unlike `get`, this will not also return +the value associated with the key. + +Example: + +```rust title="contains_key_example" showLineNumbers +if map.contains_key(7) { + let value = map.get(7); + assert(value.is_some()); + } else { + println("No value for key 7!"); + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L268-L275 + + +### entries + +```rust title="entries" showLineNumbers +pub fn entries(self) -> BoundedVec<(K, V), N> { +``` +> Source code: noir_stdlib/src/collections/map.nr#L191-L193 + + +Returns a vector of each key-value pair present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="entries_example" showLineNumbers +let entries = map.entries(); + + // The length of a hashmap may not be compile-time known, so we + // need to loop over its capacity instead + for i in 0..map.capacity() { + if i < entries.len() { + let (key, value) = entries.get(i); + println(f"{key} -> {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L307-L318 + + +### keys + +```rust title="keys" showLineNumbers +pub fn keys(self) -> BoundedVec { +``` +> Source code: noir_stdlib/src/collections/map.nr#L227-L229 + + +Returns a vector of each key present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="keys_example" showLineNumbers +let keys = map.keys(); + + for i in 0..keys.max_len() { + if i < keys.len() { + let key = keys.get_unchecked(i); + let value = map.get(key).unwrap_unchecked(); + println(f"{key} -> {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L319-L329 + + +### values + +```rust title="values" showLineNumbers +pub fn values(self) -> BoundedVec { +``` +> Source code: noir_stdlib/src/collections/map.nr#L262-L264 + + +Returns a vector of each value present in the hashmap. + +The length of the returned vector is always equal to the length of the hashmap. + +Example: + +```rust title="values_example" showLineNumbers +let values = map.values(); + + for i in 0..values.max_len() { + if i < values.len() { + let value = values.get_unchecked(i); + println(f"Found value {value}"); + } + } +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L330-L339 + + +### iter_mut + +```rust title="iter_mut" showLineNumbers +pub fn iter_mut(&mut self, f: fn(K, V) -> (K, V)) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L297-L304 + + +Iterates through each key-value pair of the HashMap, setting each key-value pair to the +result returned from the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If this is not desired, use `iter_values_mut` if only values need to be mutated, +or `entries` if neither keys nor values need to be mutated. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +```rust title="iter_mut_example" showLineNumbers +// Add 1 to each key in the map, and double the value associated with that key. + map.iter_mut(|k, v| (k + 1, v * 2)); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L343-L346 + + +### iter_keys_mut + +```rust title="iter_keys_mut" showLineNumbers +pub fn iter_keys_mut(&mut self, f: fn(K) -> K) + where + K: Eq + Hash, + B: BuildHasher, + H: Hasher, + { +``` +> Source code: noir_stdlib/src/collections/map.nr#L335-L342 + + +Iterates through the HashMap, mutating each key to the result returned from +the given function. + +Note that since keys can be mutated, the HashMap needs to be rebuilt as it is iterated +through. If only iteration is desired and the keys are not intended to be mutated, +prefer using `entries` instead. + +The iteration order is left unspecified. As a result, if two keys are mutated to become +equal, which of the two values that will be present for the key in the resulting map is also unspecified. + +Example: + +```rust title="iter_keys_mut_example" showLineNumbers +// Double each key, leaving the value associated with that key untouched + map.iter_keys_mut(|k| k * 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L347-L350 + + +### iter_values_mut + +```rust title="iter_values_mut" showLineNumbers +pub fn iter_values_mut(&mut self, f: fn(V) -> V) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L367-L369 + + +Iterates through the HashMap, applying the given function to each value and mutating the +value to equal the result. This function is more efficient than `iter_mut` and `iter_keys_mut` +because the keys are untouched and the underlying hashmap thus does not need to be reordered. + +Example: + +```rust title="iter_values_mut_example" showLineNumbers +// Halve each value + map.iter_values_mut(|v| v / 2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L351-L354 + + +### retain + +```rust title="retain" showLineNumbers +pub fn retain(&mut self, f: fn(K, V) -> bool) { +``` +> Source code: noir_stdlib/src/collections/map.nr#L388-L390 + + +Retains only the key-value pairs for which the given function returns true. +Any key-value pairs for which the function returns false will be removed from the map. + +Example: + +```rust title="retain_example" showLineNumbers +map.retain(|k, v| (k != 0) & (v != 0)); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L279-L281 + + +## Trait Implementations + +### default + +```rust title="default" showLineNumbers +impl Default for HashMap +where + B: BuildHasher + Default, + H: Hasher + Default, +{ + /// Constructs an empty HashMap. + /// + /// Example: + /// + /// ```noir + /// let hashmap: HashMap> = HashMap::default(); + /// assert(hashmap.is_empty()); + /// ``` + fn default() -> Self { +``` +> Source code: noir_stdlib/src/collections/map.nr#L681-L696 + + +Constructs an empty HashMap. + +Example: + +```rust title="default_example" showLineNumbers +let hashmap: HashMap> = HashMap::default(); + assert(hashmap.is_empty()); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L207-L210 + + +### eq + +```rust title="eq" showLineNumbers +impl Eq for HashMap +where + K: Eq + Hash, + V: Eq, + B: BuildHasher, + H: Hasher, +{ + /// Checks if two HashMaps are equal. + /// + /// Example: + /// + /// ```noir + /// let mut map1: HashMap> = HashMap::default(); + /// let mut map2: HashMap> = HashMap::default(); + /// + /// map1.insert(1, 2); + /// map1.insert(3, 4); + /// + /// map2.insert(3, 4); + /// map2.insert(1, 2); + /// + /// assert(map1 == map2); + /// ``` + fn eq(self, other: HashMap) -> bool { +``` +> Source code: noir_stdlib/src/collections/map.nr#L629-L654 + + +Checks if two HashMaps are equal. + +Example: + +```rust title="eq_example" showLineNumbers +let mut map1: HashMap> = HashMap::default(); + let mut map2: HashMap> = HashMap::default(); + + map1.insert(1, 2); + map1.insert(3, 4); + + map2.insert(3, 4); + map2.insert(1, 2); + + assert(map1 == map2); +``` +> Source code: test_programs/execution_success/hashmap/src/main.nr#L282-L293 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/index.md new file mode 100644 index 000000000000..ea84c6d5c21e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/index.md @@ -0,0 +1,5 @@ +--- +title: Containers +description: Container types provided by Noir's standard library for storing and retrieving data +keywords: [containers, data types, vec, hashmap] +--- diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/vec.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/vec.mdx new file mode 100644 index 000000000000..475011922f81 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/containers/vec.mdx @@ -0,0 +1,170 @@ +--- +title: Vectors +description: Delve into the Vec data type in Noir. Learn about its methods, practical examples, and best practices for using Vectors in your Noir code. +keywords: [noir, vector type, methods, examples, dynamic arrays] +sidebar_position: 6 +--- + +import Experimental from '@site/src/components/Notes/_experimental.mdx'; + + + +A vector is a collection type similar to Rust's `Vec` type. In Noir, it is a convenient way to use slices as mutable arrays. + +Example: + +```rust +let mut vector: Vec = Vec::new(); +for i in 0..5 { + vector.push(i); +} +assert(vector.len() == 5); +``` + +## Methods + +### new + +Creates a new, empty vector. + +```rust +pub fn new() -> Self +``` + +Example: + +```rust +let empty_vector: Vec = Vec::new(); +assert(empty_vector.len() == 0); +``` + +### from_slice + +Creates a vector containing each element from a given slice. Mutations to the resulting vector will not affect the original slice. + +```rust +pub fn from_slice(slice: [T]) -> Self +``` + +Example: + +```rust +let slice: [Field] = &[1, 2, 3]; +let vector_from_slice = Vec::from_slice(slice); +assert(vector_from_slice.len() == 3); +``` + +### len + +Returns the number of elements in the vector. + +```rust +pub fn len(self) -> Field +``` + +Example: + +```rust +let empty_vector: Vec = Vec::new(); +assert(empty_vector.len() == 0); +``` + +### get + +Retrieves an element from the vector at a given index. Panics if the index points beyond the vector's end. + +```rust +pub fn get(self, index: Field) -> T +``` + +Example: + +```rust +let vector: Vec = Vec::from_slice(&[10, 20, 30]); +assert(vector.get(1) == 20); +``` + +### set + +```rust +pub fn set(&mut self: Self, index: u64, value: T) { +``` + +Writes an element to the vector at the given index, starting from zero. + +Panics if the index points beyond the vector's end. + +Example: + +```rust +let vector: Vec = Vec::from_slice(&[10, 20, 30]); +assert(vector.get(1) == 20); +vector.set(1, 42); +assert(vector.get(1) == 42); +``` + +### push + +Adds a new element to the vector's end, returning a new vector with a length one greater than the original unmodified vector. + +```rust +pub fn push(&mut self, elem: T) +``` + +Example: + +```rust +let mut vector: Vec = Vec::new(); +vector.push(10); +assert(vector.len() == 1); +``` + +### pop + +Removes an element from the vector's end, returning a new vector with a length one less than the original vector, along with the removed element. Panics if the vector's length is zero. + +```rust +pub fn pop(&mut self) -> T +``` + +Example: + +```rust +let mut vector = Vec::from_slice(&[10, 20]); +let popped_elem = vector.pop(); +assert(popped_elem == 20); +assert(vector.len() == 1); +``` + +### insert + +Inserts an element at a specified index, shifting subsequent elements to the right. + +```rust +pub fn insert(&mut self, index: Field, elem: T) +``` + +Example: + +```rust +let mut vector = Vec::from_slice(&[10, 30]); +vector.insert(1, 20); +assert(vector.get(1) == 20); +``` + +### remove + +Removes an element at a specified index, shifting subsequent elements to the left, and returns the removed element. + +```rust +pub fn remove(&mut self, index: Field) -> T +``` + +Example: + +```rust +let mut vector = Vec::from_slice(&[10, 20, 30]); +let removed_elem = vector.remove(1); +assert(removed_elem == 20); +assert(vector.len() == 2); +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/_category_.json new file mode 100644 index 000000000000..5d694210bbf3 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ciphers.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ciphers.mdx new file mode 100644 index 000000000000..d6a5e1a79eb2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ciphers.mdx @@ -0,0 +1,32 @@ +--- +title: Ciphers +description: + Learn about the implemented ciphers ready to use for any Noir project +keywords: + [ciphers, Noir project, aes128, encrypt] +sidebar_position: 0 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +## aes128 + +Given a plaintext as an array of bytes, returns the corresponding aes128 ciphertext (CBC mode). Input padding is automatically performed using PKCS#7, so that the output length is `input.len() + (16 - input.len() % 16)`. + +```rust title="aes128" showLineNumbers +pub fn aes128_encrypt(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -> [u8] {} +``` +> Source code: noir_stdlib/src/aes128.nr#L2-L4 + + +```rust +fn main() { + let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes. + let iv: [u8; 16] = [0; 16]; // Initialisation vector + let key: [u8; 16] = [0; 16] // AES key + let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes. +} +``` + + + \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ec_primitives.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ec_primitives.md new file mode 100644 index 000000000000..f262d8160d60 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ec_primitives.md @@ -0,0 +1,102 @@ +--- +title: Elliptic Curve Primitives +keywords: [cryptographic primitives, Noir project] +sidebar_position: 4 +--- + +Data structures and methods on them that allow you to carry out computations involving elliptic +curves over the (mathematical) field corresponding to `Field`. For the field currently at our +disposal, applications would involve a curve embedded in BN254, e.g. the +[Baby Jubjub curve](https://eips.ethereum.org/EIPS/eip-2494). + +## Data structures + +### Elliptic curve configurations + +(`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::Curve`), i.e. the specific elliptic +curve you want to use, which would be specified using any one of the methods +`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::new` which take the coefficients in the +defining equation together with a generator point as parameters. You can find more detail in the +comments in +[`noir_stdlib/src/ec/mod.nr`](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/mod.nr), but +the gist of it is that the elliptic curves of interest are usually expressed in one of the standard +forms implemented here (Twisted Edwards, Montgomery and Short Weierstraß), and in addition to that, +you could choose to use `affine` coordinates (Cartesian coordinates - the usual (x,y) - possibly +together with a point at infinity) or `curvegroup` coordinates (some form of projective coordinates +requiring more coordinates but allowing for more efficient implementations of elliptic curve +operations). Conversions between all of these forms are provided, and under the hood these +conversions are done whenever an operation is more efficient in a different representation (or a +mixed coordinate representation is employed). + +### Points + +(`std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::Point`), i.e. points lying on the +elliptic curve. For a curve configuration `c` and a point `p`, it may be checked that `p` +does indeed lie on `c` by calling `c.contains(p1)`. + +## Methods + +(given a choice of curve representation, e.g. use `std::ec::tecurve::affine::Curve` and use +`std::ec::tecurve::affine::Point`) + +- The **zero element** is given by `Point::zero()`, and we can verify whether a point `p: Point` is + zero by calling `p.is_zero()`. +- **Equality**: Points `p1: Point` and `p2: Point` may be checked for equality by calling + `p1.eq(p2)`. +- **Addition**: For `c: Curve` and points `p1: Point` and `p2: Point` on the curve, adding these two + points is accomplished by calling `c.add(p1,p2)`. +- **Negation**: For a point `p: Point`, `p.negate()` is its negation. +- **Subtraction**: For `c` and `p1`, `p2` as above, subtracting `p2` from `p1` is accomplished by + calling `c.subtract(p1,p2)`. +- **Scalar multiplication**: For `c` as above, `p: Point` a point on the curve and `n: Field`, + scalar multiplication is given by `c.mul(n,p)`. If instead `n :: [u1; N]`, i.e. `n` is a bit + array, the `bit_mul` method may be used instead: `c.bit_mul(n,p)` +- **Multi-scalar multiplication**: For `c` as above and arrays `n: [Field; N]` and `p: [Point; N]`, + multi-scalar multiplication is given by `c.msm(n,p)`. +- **Coordinate representation conversions**: The `into_group` method converts a point or curve + configuration in the affine representation to one in the CurveGroup representation, and + `into_affine` goes in the other direction. +- **Curve representation conversions**: `tecurve` and `montcurve` curves and points are equivalent + and may be converted between one another by calling `into_montcurve` or `into_tecurve` on their + configurations or points. `swcurve` is more general and a curve c of one of the other two types + may be converted to this representation by calling `c.into_swcurve()`, whereas a point `p` lying + on the curve given by `c` may be mapped to its corresponding `swcurve` point by calling + `c.map_into_swcurve(p)`. +- **Map-to-curve methods**: The Elligator 2 method of mapping a field element `n: Field` into a + `tecurve` or `montcurve` with configuration `c` may be called as `c.elligator2_map(n)`. For all of + the curve configurations, the SWU map-to-curve method may be called as `c.swu_map(z,n)`, where + `z: Field` depends on `Field` and `c` and must be chosen by the user (the conditions it needs to + satisfy are specified in the comments + [here](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/mod.nr)). + +## Examples + +The +[ec_baby_jubjub test](https://github.com/noir-lang/noir/blob/master/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr) +illustrates all of the above primitives on various forms of the Baby Jubjub curve. A couple of more +interesting examples in Noir would be: + +Public-key cryptography: Given an elliptic curve and a 'base point' on it, determine the public key +from the private key. This is a matter of using scalar multiplication. In the case of Baby Jubjub, +for example, this code would do: + +```rust +use std::ec::tecurve::affine::{Curve, Point}; + +fn bjj_pub_key(priv_key: Field) -> Point +{ + + let bjj = Curve::new(168700, 168696, G::new(995203441582195749578291179787384436505546430278305826713579947235728471134,5472060717959818805561601436314318772137091100104008585924551046643952123905)); + + let base_pt = Point::new(5299619240641551281634865583518297030282874472190772894086521144482721001553, 16950150798460657717958625567821834550301663161624707787222815936182638968203); + + bjj.mul(priv_key,base_pt) +} +``` + +This would come in handy in a Merkle proof. + +- EdDSA signature verification: This is a matter of combining these primitives with a suitable hash + function. See + [feat(stdlib): EdDSA sig verification noir#1136](https://github.com/noir-lang/noir/pull/1136) for + the case of Baby Jubjub and the Poseidon hash function. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx new file mode 100644 index 000000000000..8d96027b42cb --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/ecdsa_sig_verification.mdx @@ -0,0 +1,98 @@ +--- +title: ECDSA Signature Verification +description: Learn about the cryptographic primitives regarding ECDSA over the secp256k1 and secp256r1 curves +keywords: [cryptographic primitives, Noir project, ecdsa, secp256k1, secp256r1, signatures] +sidebar_position: 3 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +Noir supports ECDSA signatures verification over the secp256k1 and secp256r1 curves. + +## ecdsa_secp256k1::verify_signature + +Verifier for ECDSA Secp256k1 signatures. +See ecdsa_secp256k1::verify_signature_slice for a version that accepts slices directly. + +```rust title="ecdsa_secp256k1" showLineNumbers +pub fn verify_signature( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8; N], +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256k1.nr#L2-L9 + + +example: + +```rust +fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) { + let valid_signature = std::ecdsa_secp256k1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); + assert(valid_signature); +} +``` + + + +## ecdsa_secp256k1::verify_signature_slice + +Verifier for ECDSA Secp256k1 signatures where the message is a slice. + +```rust title="ecdsa_secp256k1_slice" showLineNumbers +pub fn verify_signature_slice( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8], +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256k1.nr#L13-L20 + + + + +## ecdsa_secp256r1::verify_signature + +Verifier for ECDSA Secp256r1 signatures. +See ecdsa_secp256r1::verify_signature_slice for a version that accepts slices directly. + +```rust title="ecdsa_secp256r1" showLineNumbers +pub fn verify_signature( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8; N], +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256r1.nr#L2-L9 + + +example: + +```rust +fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) { + let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); + assert(valid_signature); +} +``` + + + +## ecdsa_secp256r1::verify_signature + +Verifier for ECDSA Secp256r1 signatures where the message is a slice. + +```rust title="ecdsa_secp256r1_slice" showLineNumbers +pub fn verify_signature_slice( + public_key_x: [u8; 32], + public_key_y: [u8; 32], + signature: [u8; 64], + message_hash: [u8], +) -> bool +``` +> Source code: noir_stdlib/src/ecdsa_secp256r1.nr#L13-L20 + + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/eddsa.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/eddsa.mdx new file mode 100644 index 000000000000..b283de693c84 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/eddsa.mdx @@ -0,0 +1,37 @@ +--- +title: EdDSA Verification +description: Learn about the cryptographic primitives regarding EdDSA +keywords: [cryptographic primitives, Noir project, eddsa, signatures] +sidebar_position: 5 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +## eddsa::eddsa_poseidon_verify + +Verifier for EdDSA signatures + +```rust +fn eddsa_poseidon_verify(public_key_x : Field, public_key_y : Field, signature_s: Field, signature_r8_x: Field, signature_r8_y: Field, message: Field) -> bool +``` + +It is also possible to specify the hash algorithm used for the signature by using the `eddsa_verify` function by passing a type implementing the Hasher trait with the turbofish operator. +For instance, if you want to use Poseidon2 instead, you can do the following: +```rust +use std::hash::poseidon2::Poseidon2Hasher; + +eddsa_verify::(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg); +``` + + + +## eddsa::eddsa_to_pub + +Private to public key conversion. + +Returns `(pub_key_x, pub_key_y)` + +```rust +fn eddsa_to_pub(secret : Field) -> (Field, Field) +``` + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/embedded_curve_ops.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/embedded_curve_ops.mdx new file mode 100644 index 000000000000..482a36932b94 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/embedded_curve_ops.mdx @@ -0,0 +1,95 @@ +--- +title: Scalar multiplication +description: See how you can perform scalar multiplication in Noir +keywords: [cryptographic primitives, Noir project, scalar multiplication] +sidebar_position: 1 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +The following functions perform operations over the embedded curve whose coordinates are defined by the configured noir field. +For the BN254 scalar field, this is BabyJubJub or Grumpkin. + +:::note +Suffixes `_low` and `_high` denote low and high limbs of a scalar. +::: + +## embedded_curve_ops::multi_scalar_mul + +Performs multi scalar multiplication over the embedded curve. +The function accepts arbitrary amount of point-scalar pairs on the input, it multiplies the individual pairs over +the curve and returns a sum of the resulting points. + +Points represented as x and y coordinates [x1, y1, x2, y2, ...], scalars as low and high limbs [low1, high1, low2, high2, ...]. + +```rust title="multi_scalar_mul" showLineNumbers +pub fn multi_scalar_mul( + points: [EmbeddedCurvePoint; N], + scalars: [EmbeddedCurveScalar; N], +) -> EmbeddedCurvePoint +``` +> Source code: noir_stdlib/src/embedded_curve_ops.nr#L103-L108 + + +example + +```rust +fn main(point_x: Field, point_y: Field, scalar_low: Field, scalar_high: Field) { + let point = std::embedded_curve_ops::multi_scalar_mul([point_x, point_y], [scalar_low, scalar_high]); + println(point); +} +``` + +## embedded_curve_ops::fixed_base_scalar_mul + +Performs fixed base scalar multiplication over the embedded curve (multiplies input scalar with a generator point). +The function accepts a single scalar on the input represented as 2 fields. + +```rust title="fixed_base_scalar_mul" showLineNumbers +pub fn fixed_base_scalar_mul(scalar: EmbeddedCurveScalar) -> EmbeddedCurvePoint +``` +> Source code: noir_stdlib/src/embedded_curve_ops.nr#L120-L122 + + +example + +```rust +fn main(scalar_low: Field, scalar_high: Field) { + let point = std::embedded_curve_ops::fixed_base_scalar_mul(scalar_low, scalar_high); + println(point); +} +``` + +## embedded_curve_ops::embedded_curve_add + +Adds two points on the embedded curve. +This function takes two `EmbeddedCurvePoint` structures as parameters, representing points on the curve, and returns a new `EmbeddedCurvePoint` structure that represents their sum. + +### Parameters: +- `point1` (`EmbeddedCurvePoint`): The first point to add. +- `point2` (`EmbeddedCurvePoint`): The second point to add. + +### Returns: +- `EmbeddedCurvePoint`: The resulting point after the addition of `point1` and `point2`. + +```rust title="embedded_curve_add" showLineNumbers +pub fn embedded_curve_add( + point1: EmbeddedCurvePoint, + point2: EmbeddedCurvePoint, +) -> EmbeddedCurvePoint { +``` +> Source code: noir_stdlib/src/embedded_curve_ops.nr#L136-L141 + + +example + +```rust +fn main() { + let point1 = EmbeddedCurvePoint { x: 1, y: 2 }; + let point2 = EmbeddedCurvePoint { x: 3, y: 4 }; + let result = std::embedded_curve_ops::embedded_curve_add(point1, point2); + println!("Resulting Point: ({}, {})", result.x, result.y); +} +``` + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/hashes.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/hashes.mdx new file mode 100644 index 000000000000..541a19715619 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/hashes.mdx @@ -0,0 +1,227 @@ +--- +title: Hash methods +description: + Learn about the cryptographic primitives ready to use for any Noir project, including sha256, + blake2s and pedersen +keywords: + [cryptographic primitives, Noir project, sha256, blake2s, pedersen, hash] +sidebar_position: 0 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +## sha256 + +Given an array of bytes, returns the resulting sha256 hash. +Specify a message_size to hash only the first `message_size` bytes of the input. + +```rust title="sha256" showLineNumbers +pub fn sha256(input: [u8; N]) -> HASH +``` +> Source code: noir_stdlib/src/hash/sha256.nr#L47-L49 + + +example: +```rust title="sha256_var" showLineNumbers +let digest = std::hash::sha256_var([x as u8], 1); +``` +> Source code: test_programs/execution_success/sha256/src/main.nr#L15-L17 + + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::sha256::sha256_var(x, 4); +} +``` + + + + +## blake2s + +Given an array of bytes, returns an array with the Blake2 hash + +```rust title="blake2s" showLineNumbers +pub fn blake2s(input: [u8; N]) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash/mod.nr#L18-L20 + + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::blake2s(x); +} +``` + + + +## blake3 + +Given an array of bytes, returns an array with the Blake3 hash + +```rust title="blake3" showLineNumbers +pub fn blake3(input: [u8; N]) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash/mod.nr#L24-L26 + + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let hash = std::hash::blake3(x); +} +``` + + + +## pedersen_hash + +Given an array of Fields, returns the Pedersen hash. + +```rust title="pedersen_hash" showLineNumbers +pub fn pedersen_hash(input: [Field; N]) -> Field +``` +> Source code: noir_stdlib/src/hash/mod.nr#L49-L51 + + +example: + +```rust title="pedersen-hash" showLineNumbers +fn main(x: Field, y: Field, expected_hash: Field) { + let hash = std::hash::pedersen_hash([x, y]); + assert_eq(hash, expected_hash); +} +``` +> Source code: test_programs/execution_success/pedersen_hash/src/main.nr#L1-L6 + + + + +## pedersen_commitment + +Given an array of Fields, returns the Pedersen commitment. + +```rust title="pedersen_commitment" showLineNumbers +pub fn pedersen_commitment(input: [Field; N]) -> EmbeddedCurvePoint { +``` +> Source code: noir_stdlib/src/hash/mod.nr#L29-L31 + + +example: + +```rust title="pedersen-commitment" showLineNumbers +fn main(x: Field, y: Field, expected_commitment: std::embedded_curve_ops::EmbeddedCurvePoint) { + let commitment = std::hash::pedersen_commitment([x, y]); + assert_eq(commitment.x, expected_commitment.x); + assert_eq(commitment.y, expected_commitment.y); +} +``` +> Source code: test_programs/execution_success/pedersen_commitment/src/main.nr#L1-L7 + + + + +## keccak256 + +Given an array of bytes (`u8`), returns the resulting keccak hash as an array of +32 bytes (`[u8; 32]`). Specify a message_size to hash only the first +`message_size` bytes of the input. + +```rust title="keccak256" showLineNumbers +pub fn keccak256(input: [u8; N], message_size: u32) -> [u8; 32] +``` +> Source code: noir_stdlib/src/hash/mod.nr#L116-L118 + + +example: + +```rust title="keccak256" showLineNumbers +fn main(x: Field, result: [u8; 32]) { + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // The padding is taken care of by the program + let digest = std::hash::keccak256([x as u8], 1); + assert(digest == result); + + //#1399: variable message size + let message_size = 4; + let hash_a = std::hash::keccak256([1, 2, 3, 4], message_size); + let hash_b = std::hash::keccak256([1, 2, 3, 4, 0, 0, 0, 0], message_size); + + assert(hash_a == hash_b); + + let message_size_big = 8; + let hash_c = std::hash::keccak256([1, 2, 3, 4, 0, 0, 0, 0], message_size_big); + + assert(hash_a != hash_c); +} +``` +> Source code: test_programs/execution_success/keccak256/src/main.nr#L1-L20 + + + + +## poseidon + +Given an array of Fields, returns a new Field with the Poseidon Hash. Mind that you need to specify +how many inputs are there to your Poseidon function. + +```rust +// example for hash_1, hash_2 accepts an array of length 2, etc +fn hash_1(input: [Field; 1]) -> Field +``` + +example: + +```rust title="poseidon" showLineNumbers +use std::hash::poseidon; + +fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field) { + let hash1 = poseidon::bn254::hash_2(x1); + assert(hash1 == y1); + + let hash2 = poseidon::bn254::hash_4(x2); + assert(hash2 == y2); +} +``` +> Source code: test_programs/execution_success/poseidon_bn254_hash/src/main.nr#L1-L11 + + +## poseidon 2 + +Given an array of Fields, returns a new Field with the Poseidon2 Hash. Contrary to the Poseidon +function, there is only one hash and you can specify a message_size to hash only the first +`message_size` bytes of the input, + +```rust +// example for hashing the first three elements of the input +Poseidon2::hash(input, 3); +``` + +example: + +```rust title="poseidon2" showLineNumbers +use std::hash::poseidon2; + +fn main(inputs: [Field; 4], expected_hash: Field) { + let hash = poseidon2::Poseidon2::hash(inputs, inputs.len()); + assert_eq(hash, expected_hash); +} +``` +> Source code: test_programs/execution_success/poseidon2/src/main.nr#L1-L8 + + +## hash_to_field + +```rust +fn hash_to_field(_input : [Field]) -> Field {} +``` + +Calculates the `blake2s` hash of the inputs and returns the hash modulo the field modulus to return +a value which can be represented as a `Field`. + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/index.md new file mode 100644 index 000000000000..650f30165d56 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/index.md @@ -0,0 +1,14 @@ +--- +title: Cryptographic Primitives +description: + Learn about the cryptographic primitives ready to use for any Noir project +keywords: + [ + cryptographic primitives, + Noir project, + ] +--- + +The Noir team is progressively adding new cryptographic primitives to the standard library. Reach out for news or if you would be interested in adding more of these calculations in Noir. + +Some methods are available thanks to the Aztec backend, not being performed using Noir. When using other backends, these methods may or may not be supplied. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/schnorr.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/schnorr.mdx new file mode 100644 index 000000000000..030452645c5a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/cryptographic_primitives/schnorr.mdx @@ -0,0 +1,64 @@ +--- +title: Schnorr Signatures +description: Learn how you can verify Schnorr signatures using Noir +keywords: [cryptographic primitives, Noir project, schnorr, signatures] +sidebar_position: 2 +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +## schnorr::verify_signature + +Verifier for Schnorr signatures over the embedded curve (for BN254 it is Grumpkin). +See schnorr::verify_signature_slice for a version that works directly on slices. + +```rust title="schnorr_verify" showLineNumbers +pub fn verify_signature( + public_key_x: Field, + public_key_y: Field, + signature: [u8; 64], + message: [u8; N], +) -> bool +``` +> Source code: noir_stdlib/src/schnorr.nr#L4-L11 + + +where `_signature` can be generated like so using the npm package +[@noir-lang/barretenberg](https://www.npmjs.com/package/@noir-lang/barretenberg) + +```js +const { BarretenbergWasm } = require('@noir-lang/barretenberg/dest/wasm'); +const { Schnorr } = require('@noir-lang/barretenberg/dest/crypto/schnorr'); + +... + +const barretenberg = await BarretenbergWasm.new(); +const schnorr = new Schnorr(barretenberg); +const pubKey = schnorr.computePublicKey(privateKey); +const message = ... +const signature = Array.from( + schnorr.constructSignature(hash, privateKey).toBuffer() +); + +... +``` + + + +## schnorr::verify_signature_slice + +Verifier for Schnorr signatures over the embedded curve (for BN254 it is Grumpkin) +where the message is a slice. + +```rust title="schnorr_verify_slice" showLineNumbers +pub fn verify_signature_slice( + public_key_x: Field, + public_key_y: Field, + signature: [u8; 64], + message: [u8], +) -> bool +``` +> Source code: noir_stdlib/src/schnorr.nr#L15-L22 + + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/fmtstr.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/fmtstr.md new file mode 100644 index 000000000000..19809d60261d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/fmtstr.md @@ -0,0 +1,17 @@ +--- +title: fmtstr +--- + +`fmtstr` is the type resulting from using format string (`f"..."`). + +## Methods + +### quoted_contents + +```rust title="quoted_contents" showLineNumbers +pub comptime fn quoted_contents(self) -> Quoted {} +``` +> Source code: noir_stdlib/src/meta/format_string.nr#L3-L5 + + +Returns the format string contents (that is, without the leading and trailing double quotes) as a `Quoted` value. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/is_unconstrained.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/is_unconstrained.md new file mode 100644 index 000000000000..51bb1bda8f1b --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/is_unconstrained.md @@ -0,0 +1,69 @@ +--- +title: Is Unconstrained Function +description: + The is_unconstrained function returns wether the context at that point of the program is unconstrained or not. +keywords: + [ + unconstrained + ] +--- + +It's very common for functions in circuits to take unconstrained hints of an expensive computation and then verify it. This is done by running the hint in an unconstrained context and then verifying the result in a constrained context. + +When a function is marked as unconstrained, any subsequent functions that it calls will also be run in an unconstrained context. However, if we are implementing a library function, other users might call it within an unconstrained context or a constrained one. Generally, in an unconstrained context we prefer just computing the result instead of taking a hint of it and verifying it, since that'd mean doing the same computation twice: + +```rust + +fn my_expensive_computation(){ + ... +} + +unconstrained fn my_expensive_computation_hint(){ + my_expensive_computation() +} + +pub fn external_interface(){ + my_expensive_computation_hint(); + // verify my_expensive_computation: If external_interface is called from unconstrained, this is redundant + ... +} + +``` + +In order to improve the performance in an unconstrained context you can use the function at `std::runtime::is_unconstrained() -> bool`: + + +```rust +use dep::std::runtime::is_unconstrained; + +fn my_expensive_computation(){ + ... +} + +unconstrained fn my_expensive_computation_hint(){ + my_expensive_computation() +} + +pub fn external_interface(){ + if is_unconstrained() { + my_expensive_computation(); + } else { + my_expensive_computation_hint(); + // verify my_expensive_computation + ... + } +} + +``` + +The is_unconstrained result is resolved at compile time, so in unconstrained contexts the compiler removes the else branch, and in constrained contexts the compiler removes the if branch, reducing the amount of compute necessary to run external_interface. + +Note that using `is_unconstrained` in a `comptime` context will also return `true`: + +``` +fn main() { + comptime { + assert(is_unconstrained()); + } +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/logging.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/logging.md new file mode 100644 index 000000000000..db75ef9f86fa --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/logging.md @@ -0,0 +1,78 @@ +--- +title: Logging +description: + Learn how to use the println statement for debugging in Noir with this tutorial. Understand the + basics of logging in Noir and how to implement it in your code. +keywords: + [ + noir logging, + println statement, + print statement, + debugging in noir, + noir std library, + logging tutorial, + basic logging in noir, + noir logging implementation, + noir debugging techniques, + rust, + ] +--- + +The standard library provides two familiar statements you can use: `println` and `print`. Despite being a limited implementation of rust's `println!` and `print!` macros, these constructs can be useful for debugging. + +You can print the output of both statements in your Noir code by using the `nargo execute` command or the `--show-output` flag when using `nargo test` (provided there are print statements in your tests). + +It is recommended to use `nargo execute` if you want to debug failing constraints with `println` or `print` statements. This is due to every input in a test being a constant rather than a witness, so we issue an error during compilation while we only print during execution (which comes after compilation). Neither `println`, nor `print` are callable for failed constraints caught at compile time. + +Both `print` and `println` are generic functions which can work on integers, fields, strings, and even structs or expressions. Note however, that slices are currently unsupported. For example: + +```rust +struct Person { + age: Field, + height: Field, +} + +fn main(age: Field, height: Field) { + let person = Person { + age: age, + height: height, + }; + println(person); + println(age + height); + println("Hello world!"); +} +``` + +You can print different types in the same statement (including strings) with a type called `fmtstr`. It can be specified in the same way as a normal string, just prepended with an "f" character: + +```rust + let fmt_str = f"i: {i}, j: {j}"; + println(fmt_str); + + let s = myStruct { y: x, x: y }; + println(s); + + println(f"i: {i}, s: {s}"); + + println(x); + println([x, y]); + + let foo = fooStruct { my_struct: s, foo: 15 }; + println(f"s: {s}, foo: {foo}"); + + println(15); // prints 0x0f, implicit Field + println(-1 as u8); // prints 255 + println(-1 as i8); // prints -1 +``` + +Examples shown above are interchangeable between the two `print` statements: + +```rust +let person = Person { age : age, height : height }; + +println(person); +print(person); + +println("Hello world!"); // Prints with a newline at the end of the input +print("Hello world!"); // Prints the input and keeps cursor on the same line +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/mem.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/mem.md new file mode 100644 index 000000000000..95d36ac2a722 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/mem.md @@ -0,0 +1,52 @@ +--- +title: Memory Module +description: + This module contains functions which manipulate memory in a low-level way +keywords: + [ + mem, memory, zeroed, transmute, checked_transmute + ] +--- + +# `std::mem::zeroed` + +```rust +fn zeroed() -> T +``` + +Returns a zeroed value of any type. +This function is generally unsafe to use as the zeroed bit pattern is not guaranteed to be valid for all types. +It can however, be useful in cases when the value is guaranteed not to be used such as in a BoundedVec library implementing a growable vector, up to a certain length, backed by an array. +The array can be initialized with zeroed values which are guaranteed to be inaccessible until the vector is pushed to. +Similarly, enumerations in noir can be implemented using this method by providing zeroed values for the unused variants. + +This function currently supports the following types: + +- Field +- Bool +- Uint +- Array +- Slice +- String +- Tuple +- Functions + +Using it on other types could result in unexpected behavior. + +# `std::mem::checked_transmute` + +```rust +fn checked_transmute(value: T) -> U +``` + +Transmutes a value of one type into the same value but with a new type `U`. + +This function is safe to use since both types are asserted to be equal later during compilation after the concrete values for generic types become known. +This function is useful for cases where the compiler may fails a type check that is expected to pass where +a user knows the two types to be equal. For example, when using arithmetic generics there are cases the compiler +does not see as equal, such as `[Field; N*(A + B)]` and `[Field; N*A + N*B]`, which users may know to be equal. +In these cases, `checked_transmute` can be used to cast the value to the desired type while also preserving safety +by checking this equality once `N`, `A`, `B` are fully resolved. + +Note that since this safety check is performed after type checking rather than during, no error is issued if the function +containing `checked_transmute` is never called. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/merkle_trees.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/merkle_trees.md new file mode 100644 index 000000000000..6a9ebf72ada0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/merkle_trees.md @@ -0,0 +1,58 @@ +--- +title: Merkle Trees +description: Learn about Merkle Trees in Noir with this tutorial. Explore the basics of computing a merkle root using a proof, with examples. +keywords: + [ + Merkle trees in Noir, + Noir programming language, + check membership, + computing root from leaf, + Noir Merkle tree implementation, + Merkle tree tutorial, + Merkle tree code examples, + Noir libraries, + pedersen hash., + ] +--- + +## compute_merkle_root + +Returns the root of the tree from the provided leaf and its hash path, using a [Pedersen hash](./cryptographic_primitives/hashes.mdx#pedersen_hash). + +```rust +fn compute_merkle_root(leaf : Field, index : Field, hash_path: [Field]) -> Field +``` + +example: + +```rust +/** + // these values are for this example only + index = "0" + priv_key = "0x000000000000000000000000000000000000000000000000000000616c696365" + secret = "0x1929ea3ab8d9106a899386883d9428f8256cfedb3c4f6b66bf4aa4d28a79988f" + note_hash_path = [ + "0x1e61bdae0f027b1b2159e1f9d3f8d00fa668a952dddd822fda80dc745d6f65cc", + "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", + "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40" + ] + */ +fn main(index: Field, priv_key: Field, secret: Field, note_hash_path: [Field; 3]) { + + let pubkey = std::scalar_mul::fixed_base_embedded_curve(priv_key); + let pubkey_x = pubkey[0]; + let pubkey_y = pubkey[1]; + let note_commitment = std::hash::pedersen(&[pubkey_x, pubkey_y, secret]); + + let root = std::merkle::compute_merkle_root(note_commitment[0], index, note_hash_path.as_slice()); + println(root); +} +``` + +To check merkle tree membership: + +1. Include a merkle root as a program input. +2. Compute the merkle root of a given leaf, index and hash path. +3. Assert the merkle roots are equal. + +For more info about merkle trees, see the Wikipedia [page](https://en.wikipedia.org/wiki/Merkle_tree). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/ctstring.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/ctstring.md new file mode 100644 index 000000000000..b76f873ca037 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/ctstring.md @@ -0,0 +1,100 @@ +--- +title: CtString +--- + +`std::meta::ctstring` contains methods on the built-in `CtString` type which is +a compile-time, dynamically-sized string type. Compared to `str` and `fmtstr`, +`CtString` is useful because its size does not need to be specified in its type. This +can be used for formatting items at compile-time or general string handling in `comptime` +code. + +Since `fmtstr`s can be converted into `CtString`s, you can make use of their formatting +abilities in CtStrings by formatting in `fmtstr`s then converting the result to a CtString +afterward. + +## Traits + +### AsCtString + +```rust title="as-ctstring" showLineNumbers +pub trait AsCtString { + comptime fn as_ctstring(self) -> CtString; +} +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L43-L47 + + +Converts an object into a compile-time string. + +Implementations: + +```rust +impl AsCtString for str { ... } +impl AsCtString for fmtstr { ... } +``` + +## Methods + +### new + +```rust title="new" showLineNumbers +pub comptime fn new() -> Self { +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L4-L6 + + +Creates an empty `CtString`. + +### append_str + +```rust title="append_str" showLineNumbers +pub comptime fn append_str(self, s: str) -> Self { +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L11-L13 + + +Returns a new CtString with the given str appended onto the end. + +### append_fmtstr + +```rust title="append_fmtstr" showLineNumbers +pub comptime fn append_fmtstr(self, s: fmtstr) -> Self { +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L17-L19 + + +Returns a new CtString with the given fmtstr appended onto the end. + +### as_quoted_str + +```rust title="as_quoted_str" showLineNumbers +pub comptime fn as_quoted_str(self) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L26-L28 + + +Returns a quoted string literal from this string's contents. + +There is no direct conversion from a `CtString` to a `str` since +the size would not be known. To get around this, this function can +be used in combination with macro insertion (`!`) to insert this string +literal at this function's call site. + +Example: + +```rust title="as_quoted_str_example" showLineNumbers +let my_ctstring = "foo bar".as_ctstring(); + let my_str = my_ctstring.as_quoted_str!(); + + assert_eq(crate::meta::type_of(my_str), quote { str<7> }.as_type()); +``` +> Source code: noir_stdlib/src/meta/ctstring.nr#L92-L97 + + +## Trait Implementations + +```rust +impl Eq for CtString +impl Hash for CtString +impl Append for CtString +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/expr.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/expr.md new file mode 100644 index 000000000000..b6d395c6700c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/expr.md @@ -0,0 +1,380 @@ +--- +title: Expr +--- + +`std::meta::expr` contains methods on the built-in `Expr` type for quoted, syntactically valid expressions. + +## Methods + +### as_array + +```rust title="as_array" showLineNumbers +pub comptime fn as_array(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L10-L12 + + +If this expression is an array, this returns a slice of each element in the array. + +### as_assert + +```rust title="as_assert" showLineNumbers +pub comptime fn as_assert(self) -> Option<(Expr, Option)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L16-L18 + + +If this expression is an assert, this returns the assert expression and the optional message. + +### as_assert_eq + +```rust title="as_assert_eq" showLineNumbers +pub comptime fn as_assert_eq(self) -> Option<(Expr, Expr, Option)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L23-L25 + + +If this expression is an assert_eq, this returns the left-hand-side and right-hand-side +expressions, together with the optional message. + +### as_assign + +```rust title="as_assign" showLineNumbers +pub comptime fn as_assign(self) -> Option<(Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L30-L32 + + +If this expression is an assignment, this returns a tuple with the left hand side +and right hand side in order. + +### as_binary_op + +```rust title="as_binary_op" showLineNumbers +pub comptime fn as_binary_op(self) -> Option<(Expr, BinaryOp, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L37-L39 + + +If this expression is a binary operator operation ` `, +return the left-hand side, operator, and the right-hand side of the operation. + +### as_block + +```rust title="as_block" showLineNumbers +pub comptime fn as_block(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L44-L46 + + +If this expression is a block `{ stmt1; stmt2; ...; stmtN }`, return +a slice containing each statement. + +### as_bool + +```rust title="as_bool" showLineNumbers +pub comptime fn as_bool(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L50-L52 + + +If this expression is a boolean literal, return that literal. + +### as_cast + +```rust title="as_cast" showLineNumbers +#[builtin(expr_as_cast)] + pub comptime fn as_cast(self) -> Option<(Expr, UnresolvedType)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L56-L59 + + +If this expression is a cast expression (`expr as type`), returns the casted +expression and the type to cast to. + +### as_comptime + +```rust title="as_comptime" showLineNumbers +pub comptime fn as_comptime(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L64-L66 + + +If this expression is a `comptime { stmt1; stmt2; ...; stmtN }` block, +return each statement in the block. + +### as_constructor + +```rust title="as_constructor" showLineNumbers +pub comptime fn as_constructor(self) -> Option<(UnresolvedType, [(Quoted, Expr)])> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L71-L73 + + +If this expression is a constructor `Type { field1: expr1, ..., fieldN: exprN }`, +return the type and the fields. + +### as_for + +```rust title="as_for" showLineNumbers +pub comptime fn as_for(self) -> Option<(Quoted, Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L78-L80 + + +If this expression is a for statement over a single expression, return the identifier, +the expression and the for loop body. + +### as_for_range + +```rust title="as_for" showLineNumbers +pub comptime fn as_for(self) -> Option<(Quoted, Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L78-L80 + + +If this expression is a for statement over a range, return the identifier, +the range start, the range end and the for loop body. + +### as_function_call + +```rust title="as_function_call" showLineNumbers +pub comptime fn as_function_call(self) -> Option<(Expr, [Expr])> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L92-L94 + + +If this expression is a function call `foo(arg1, ..., argN)`, return +the function and a slice of each argument. + +### as_if + +```rust title="as_if" showLineNumbers +pub comptime fn as_if(self) -> Option<(Expr, Expr, Option)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L100-L102 + + +If this expression is an `if condition { then_branch } else { else_branch }`, +return the condition, then branch, and else branch. If there is no else branch, +`None` is returned for that branch instead. + +### as_index + +```rust title="as_index" showLineNumbers +pub comptime fn as_index(self) -> Option<(Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L107-L109 + + +If this expression is an index into an array `array[index]`, return the +array and the index. + +### as_integer + +```rust title="as_integer" showLineNumbers +pub comptime fn as_integer(self) -> Option<(Field, bool)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L114-L116 + + +If this expression is an integer literal, return the integer as a field +as well as whether the integer is negative (true) or not (false). + +### as_lambda + +```rust title="as_lambda" showLineNumbers +pub comptime fn as_lambda( + self, + ) -> Option<([(Expr, Option)], Option, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L120-L124 + + +If this expression is a lambda, returns the parameters, return type and body. + +### as_let + +```rust title="as_let" showLineNumbers +pub comptime fn as_let(self) -> Option<(Expr, Option, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L129-L131 + + +If this expression is a let statement, returns the let pattern as an `Expr`, +the optional type annotation, and the assigned expression. + +### as_member_access + +```rust title="as_member_access" showLineNumbers +pub comptime fn as_member_access(self) -> Option<(Expr, Quoted)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L136-L138 + + +If this expression is a member access `foo.bar`, return the struct/tuple +expression and the field. The field will be represented as a quoted value. + +### as_method_call + +```rust title="as_method_call" showLineNumbers +pub comptime fn as_method_call(self) -> Option<(Expr, Quoted, [UnresolvedType], [Expr])> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L143-L145 + + +If this expression is a method call `foo.bar::(arg1, ..., argN)`, return +the receiver, method name, a slice of each generic argument, and a slice of each argument. + +### as_repeated_element_array + +```rust title="as_repeated_element_array" showLineNumbers +pub comptime fn as_repeated_element_array(self) -> Option<(Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L150-L152 + + +If this expression is a repeated element array `[elem; length]`, return +the repeated element and the length expressions. + +### as_repeated_element_slice + +```rust title="as_repeated_element_slice" showLineNumbers +pub comptime fn as_repeated_element_slice(self) -> Option<(Expr, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L157-L159 + + +If this expression is a repeated element slice `[elem; length]`, return +the repeated element and the length expressions. + +### as_slice + +```rust title="as_slice" showLineNumbers +pub comptime fn as_slice(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L164-L166 + + +If this expression is a slice literal `&[elem1, ..., elemN]`, +return each element of the slice. + +### as_tuple + +```rust title="as_tuple" showLineNumbers +pub comptime fn as_tuple(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L171-L173 + + +If this expression is a tuple `(field1, ..., fieldN)`, +return each element of the tuple. + +### as_unary_op + +```rust title="as_unary_op" showLineNumbers +pub comptime fn as_unary_op(self) -> Option<(UnaryOp, Expr)> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L178-L180 + + +If this expression is a unary operation ` `, +return the unary operator as well as the right-hand side expression. + +### as_unsafe + +```rust title="as_unsafe" showLineNumbers +pub comptime fn as_unsafe(self) -> Option<[Expr]> {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L185-L187 + + +If this expression is an `unsafe { stmt1; ...; stmtN }` block, +return each statement inside in a slice. + +### has_semicolon + +```rust title="has_semicolon" showLineNumbers +pub comptime fn has_semicolon(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L206-L208 + + +`true` if this expression is trailed by a semicolon. E.g. + +``` +comptime { + let expr1 = quote { 1 + 2 }.as_expr().unwrap(); + let expr2 = quote { 1 + 2; }.as_expr().unwrap(); + + assert(expr1.as_binary_op().is_some()); + assert(expr2.as_binary_op().is_some()); + + assert(!expr1.has_semicolon()); + assert(expr2.has_semicolon()); +} +``` + +### is_break + +```rust title="is_break" showLineNumbers +pub comptime fn is_break(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L212-L214 + + +`true` if this expression is `break`. + +### is_continue + +```rust title="is_continue" showLineNumbers +pub comptime fn is_continue(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L218-L220 + + +`true` if this expression is `continue`. + +### modify + +```rust title="modify" showLineNumbers +pub comptime fn modify(self, f: fn[Env](Expr) -> Option) -> Expr { +``` +> Source code: noir_stdlib/src/meta/expr.nr#L229-L231 + + +Applies a mapping function to this expression and to all of its sub-expressions. +`f` will be applied to each sub-expression first, then applied to the expression itself. + +This happens recursively for every expression within `self`. + +For example, calling `modify` on `(&[1], &[2, 3])` with an `f` that returns `Option::some` +for expressions that are integers, doubling them, would return `(&[2], &[4, 6])`. + +### quoted + +```rust title="quoted" showLineNumbers +pub comptime fn quoted(self) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/expr.nr#L266-L268 + + +Returns this expression as a `Quoted` value. It's the same as `quote { $self }`. + +### resolve + +```rust title="resolve" showLineNumbers +pub comptime fn resolve(self, in_function: Option) -> TypedExpr {} +``` +> Source code: noir_stdlib/src/meta/expr.nr#L282-L284 + + +Resolves and type-checks this expression and returns the result as a `TypedExpr`. + +The `in_function` argument specifies where the expression is resolved: +- If it's `none`, the expression is resolved in the function where `resolve` was called +- If it's `some`, the expression is resolved in the given function + +If any names used by this expression are not in scope or if there are any type errors, +this will give compiler errors as if the expression was written directly into +the current `comptime` function. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/function_def.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/function_def.md new file mode 100644 index 000000000000..b7f2ebdb889d --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/function_def.md @@ -0,0 +1,166 @@ +--- +title: FunctionDefinition +--- + +`std::meta::function_def` contains methods on the built-in `FunctionDefinition` type representing +a function definition in the source program. + +## Methods + +### add_attribute + +```rust title="add_attribute" showLineNumbers +pub comptime fn add_attribute(self, attribute: str) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L3-L5 + + +Adds an attribute to the function. This is only valid +on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +### body + +```rust title="body" showLineNumbers +pub comptime fn body(self) -> Expr {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L8-L10 + + +Returns the body of the function as an expression. This is only valid +on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +### has_named_attribute + +```rust title="has_named_attribute" showLineNumbers +pub comptime fn has_named_attribute(self, name: str) -> bool {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L13-L15 + + +Returns true if this function has a custom attribute with the given name. + +### is_unconstrained + +```rust title="is_unconstrained" showLineNumbers +pub comptime fn is_unconstrained(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L18-L20 + + +Returns true if this function is unconstrained. + +### module + +```rust title="module" showLineNumbers +pub comptime fn module(self) -> Module {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L23-L25 + + +Returns the module where the function is defined. + +### name + +```rust title="name" showLineNumbers +pub comptime fn name(self) -> Quoted {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L28-L30 + + +Returns the name of the function. + +### parameters + +```rust title="parameters" showLineNumbers +pub comptime fn parameters(self) -> [(Quoted, Type)] {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L33-L35 + + +Returns each parameter of the function as a tuple of (parameter pattern, parameter type). + +### return_type + +```rust title="return_type" showLineNumbers +pub comptime fn return_type(self) -> Type {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L38-L40 + + +The return type of the function. + +### set_body + +```rust title="set_body" showLineNumbers +pub comptime fn set_body(self, body: Expr) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L43-L45 + + +Mutate the function body to a new expression. This is only valid +on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +### set_parameters + +```rust title="set_parameters" showLineNumbers +pub comptime fn set_parameters(self, parameters: [(Quoted, Type)]) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L48-L50 + + +Mutates the function's parameters to a new set of parameters. This is only valid +on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +Expects a slice of (parameter pattern, parameter type) for each parameter. Requires +each parameter pattern to be a syntactically valid parameter. + +### set_return_type + +```rust title="set_return_type" showLineNumbers +pub comptime fn set_return_type(self, return_type: Type) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L53-L55 + + +Mutates the function's return type to a new type. This is only valid +on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +### set_return_public + +```rust title="set_return_public" showLineNumbers +pub comptime fn set_return_public(self, public: bool) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L58-L60 + + +Mutates the function's return visibility to public (if `true` is given) or private (if `false` is given). +This is only valid on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +### set_unconstrained + +```rust title="set_unconstrained" showLineNumbers +pub comptime fn set_unconstrained(self, value: bool) {} +``` +> Source code: noir_stdlib/src/meta/function_def.nr#L66-L68 + + +Mutates the function to be unconstrained (if `true` is given) or not (if `false` is given). +This is only valid on functions in the current crate which have not yet been resolved. +This means any functions called at compile-time are invalid targets for this method. + +## Trait Implementations + +```rust +impl Eq for FunctionDefinition +impl Hash for FunctionDefinition +``` + +Note that each function is assigned a unique ID internally and this is what is used for +equality and hashing. So even functions with identical signatures and bodies may not +be equal in this sense if they were originally different items in the source program. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/index.md new file mode 100644 index 000000000000..14544c074425 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/index.md @@ -0,0 +1,224 @@ +--- +title: Metaprogramming +description: Noir's Metaprogramming API +keywords: [metaprogramming, comptime, macros, macro, quote, unquote] +--- + +`std::meta` is the entry point for Noir's metaprogramming API. This consists of `comptime` functions +and types used for inspecting and modifying Noir programs. + +## Functions + +### type_of + +```rust title="type_of" showLineNumbers +pub comptime fn type_of(x: T) -> Type {} +``` +> Source code: noir_stdlib/src/meta/mod.nr#L27-L29 + + +Returns the type of a variable at compile-time. + +Example: +```rust +comptime { + let x: i32 = 1; + let x_type: Type = std::meta::type_of(x); + + assert_eq(x_type, quote { i32 }.as_type()); +} +``` + +### unquote + +```rust title="unquote" showLineNumbers +pub comptime fn unquote(code: Quoted) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/mod.nr#L19-L21 + + +Unquotes the passed-in token stream where this function was called. + +Example: +```rust +comptime { + let code = quote { 1 + 2 }; + + // let x = 1 + 2; + let x = unquote!(code); +} +``` + +### derive + +```rust title="derive" showLineNumbers +#[varargs] +pub comptime fn derive(s: StructDefinition, traits: [TraitDefinition]) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/mod.nr#L48-L51 + + +Attribute placed on struct definitions. + +Creates a trait impl for each trait passed in as an argument. +To do this, the trait must have a derive handler registered +with `derive_via` beforehand. The traits in the stdlib that +can be derived this way are `Eq`, `Ord`, `Default`, and `Hash`. + +Example: +```rust +#[derive(Eq, Default)] +struct Foo { + x: i32, + y: T, +} + +fn main() { + let foo1 = Foo::default(); + let foo2 = Foo { x: 0, y: &[0] }; + assert_eq(foo1, foo2); +} +``` + +### derive_via + +```rust title="derive_via_signature" showLineNumbers +pub comptime fn derive_via(t: TraitDefinition, f: DeriveFunction) { +``` +> Source code: noir_stdlib/src/meta/mod.nr#L68-L70 + + +Attribute placed on trait definitions. + +Registers a function to create impls for the given trait +when the trait is used in a `derive` call. Users may use +this to register their own functions to enable their traits +to be derived by `derive`. + +Because this function requires a function as an argument which +should produce a trait impl for any given struct, users may find +it helpful to use a function like `std::meta::make_trait_impl` to +help creating these impls. + +Example: +```rust +#[derive_via(derive_do_nothing)] +trait DoNothing { + fn do_nothing(self); +} + +comptime fn derive_do_nothing(s: StructDefinition) -> Quoted { + let typ = s.as_type(); + quote { + impl DoNothing for $typ { + fn do_nothing(self) { + println("Nothing"); + } + } + } +} +``` + +As another example, `derive_eq` in the stdlib is used to derive the `Eq` +trait for any struct. It makes use of `make_trait_impl` to do this: + +```rust title="derive_eq" showLineNumbers +comptime fn derive_eq(s: StructDefinition) -> Quoted { + let signature = quote { fn eq(_self: Self, _other: Self) -> bool }; + let for_each_field = |name| quote { (_self.$name == _other.$name) }; + let body = |fields| { + if s.fields().len() == 0 { + quote { true } + } else { + fields + } + }; + crate::meta::make_trait_impl( + s, + quote { Eq }, + signature, + for_each_field, + quote { & }, + body, + ) +} +``` +> Source code: noir_stdlib/src/cmp.nr#L10-L30 + + +### make_trait_impl + +```rust title="make_trait_impl" showLineNumbers +pub comptime fn make_trait_impl( + s: StructDefinition, + trait_name: Quoted, + function_signature: Quoted, + for_each_field: fn[Env1](Quoted) -> Quoted, + join_fields_with: Quoted, + body: fn[Env2](Quoted) -> Quoted, +) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/mod.nr#L87-L96 + + +A helper function to more easily create trait impls while deriving traits. + +Note that this function only works for traits which: +1. Have only one method +2. Have no generics on the trait itself. + - E.g. Using this on a trait such as `trait Foo { ... }` will result in the + generated impl incorrectly missing the `T` generic. + +If your trait fits these criteria then `make_trait_impl` is likely the easiest +way to write your derive handler. The arguments are as follows: + +- `s`: The struct to make the impl for +- `trait_name`: The name of the trait to derive. E.g. `quote { Eq }`. +- `function_signature`: The signature of the trait method to derive. E.g. `fn eq(self, other: Self) -> bool`. +- `for_each_field`: An operation to be performed on each field. E.g. `|name| quote { (self.$name == other.$name) }`. +- `join_fields_with`: A separator to join each result of `for_each_field` with. + E.g. `quote { & }`. You can also use an empty `quote {}` for no separator. +- `body`: The result of the field operations are passed into this function for any final processing. + This is the place to insert any setup/teardown code the trait requires. If the trait doesn't require + any such code, you can return the body as-is: `|body| body`. + +Example deriving `Hash`: + +```rust title="derive_hash" showLineNumbers +comptime fn derive_hash(s: StructDefinition) -> Quoted { + let name = quote { Hash }; + let signature = quote { fn hash(_self: Self, _state: &mut H) where H: std::hash::Hasher }; + let for_each_field = |name| quote { _self.$name.hash(_state); }; + crate::meta::make_trait_impl( + s, + name, + signature, + for_each_field, + quote {}, + |fields| fields, + ) +} +``` +> Source code: noir_stdlib/src/hash/mod.nr#L137-L151 + + +Example deriving `Ord`: + +```rust title="derive_ord" showLineNumbers +comptime fn derive_ord(s: StructDefinition) -> Quoted { + let signature = quote { fn cmp(_self: Self, _other: Self) -> std::cmp::Ordering }; + let for_each_field = |name| quote { + if result == std::cmp::Ordering::equal() { + result = _self.$name.cmp(_other.$name); + } + }; + let body = |fields| quote { + let mut result = std::cmp::Ordering::equal(); + $fields + result + }; + crate::meta::make_trait_impl(s, quote { Ord }, signature, for_each_field, quote {}, body) +} +``` +> Source code: noir_stdlib/src/cmp.nr#L216-L231 + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/module.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/module.md new file mode 100644 index 000000000000..f47231972b7f --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/module.md @@ -0,0 +1,82 @@ +--- +title: Module +--- + +`std::meta::module` contains methods on the built-in `Module` type which represents a module in the source program. +Note that this type represents a module generally, it isn't limited to only `mod my_submodule { ... }` +declarations in the source program. + +## Methods + +### add_item + +```rust title="add_item" showLineNumbers +pub comptime fn add_item(self, item: Quoted) {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L3-L5 + + +Adds a top-level item (a function, a struct, a global, etc.) to the module. +Adding multiple items in one go is also valid if the `Quoted` value has multiple items in it. +Note that the items are type-checked as if they are inside the module they are being added to. + +### functions + +```rust title="functions" showLineNumbers +pub comptime fn functions(self) -> [FunctionDefinition] {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L18-L20 + + +Returns each function defined in the module. + +### has_named_attribute + +```rust title="has_named_attribute" showLineNumbers +pub comptime fn has_named_attribute(self, name: str) -> bool {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L8-L10 + + +Returns true if this module has a custom attribute with the given name. + +### is_contract + +```rust title="is_contract" showLineNumbers +pub comptime fn is_contract(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L13-L15 + + +`true` if this module is a contract module (was declared via `contract foo { ... }`). + +### name + +```rust title="name" showLineNumbers +pub comptime fn name(self) -> Quoted {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L28-L30 + + +Returns the name of the module. + +### structs + +```rust title="structs" showLineNumbers +pub comptime fn structs(self) -> [StructDefinition] {} +``` +> Source code: noir_stdlib/src/meta/module.nr#L23-L25 + + +Returns each struct defined in the module. + +## Trait Implementations + +```rust +impl Eq for Module +impl Hash for Module +``` + +Note that each module is assigned a unique ID internally and this is what is used for +equality and hashing. So even modules with identical names and contents may not +be equal in this sense if they were originally different items in the source program. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/op.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/op.md new file mode 100644 index 000000000000..03ea49ad8ec8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/op.md @@ -0,0 +1,244 @@ +--- +title: UnaryOp and BinaryOp +--- + +`std::meta::op` contains the `UnaryOp` and `BinaryOp` types as well as methods on them. +These types are used to represent a unary or binary operator respectively in Noir source code. + +## Types + +### UnaryOp + +Represents a unary operator. One of `-`, `!`, `&mut`, or `*`. + +### Methods + +#### is_minus + +```rust title="is_minus" showLineNumbers +pub fn is_minus(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L24-L26 + + +Returns `true` if this operator is `-`. + +#### is_not + +```rust title="is_not" showLineNumbers +pub fn is_not(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L30-L32 + + +`true` if this operator is `!` + +#### is_mutable_reference + +```rust title="is_mutable_reference" showLineNumbers +pub fn is_mutable_reference(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L36-L38 + + +`true` if this operator is `&mut` + +#### is_dereference + +```rust title="is_dereference" showLineNumbers +pub fn is_dereference(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L42-L44 + + +`true` if this operator is `*` + +#### quoted + +```rust title="unary_quoted" showLineNumbers +pub comptime fn quoted(self) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/op.nr#L48-L50 + + +Returns this operator as a `Quoted` value. + +### Trait Implementations + +```rust +impl Eq for UnaryOp +impl Hash for UnaryOp +``` + +### BinaryOp + +Represents a binary operator. One of `+`, `-`, `*`, `/`, `%`, `==`, `!=`, `<`, `<=`, `>`, `>=`, `&`, `|`, `^`, `>>`, or `<<`. + +### Methods + +#### is_add + +```rust title="is_add" showLineNumbers +pub fn is_add(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L86-L88 + + +`true` if this operator is `+` + +#### is_subtract + +```rust title="is_subtract" showLineNumbers +pub fn is_subtract(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L92-L94 + + +`true` if this operator is `-` + +#### is_multiply + +```rust title="is_multiply" showLineNumbers +pub fn is_multiply(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L98-L100 + + +`true` if this operator is `*` + +#### is_divide + +```rust title="is_divide" showLineNumbers +pub fn is_divide(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L104-L106 + + +`true` if this operator is `/` + +#### is_modulo + +```rust title="is_modulo" showLineNumbers +pub fn is_modulo(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L176-L178 + + +`true` if this operator is `%` + +#### is_equal + +```rust title="is_equal" showLineNumbers +pub fn is_equal(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L110-L112 + + +`true` if this operator is `==` + +#### is_not_equal + +```rust title="is_not_equal" showLineNumbers +pub fn is_not_equal(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L116-L118 + + +`true` if this operator is `!=` + +#### is_less_than + +```rust title="is_less_than" showLineNumbers +pub fn is_less_than(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L122-L124 + + +`true` if this operator is `<` + +#### is_less_than_or_equal + +```rust title="is_less_than_or_equal" showLineNumbers +pub fn is_less_than_or_equal(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L128-L130 + + +`true` if this operator is `<=` + +#### is_greater_than + +```rust title="is_greater_than" showLineNumbers +pub fn is_greater_than(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L134-L136 + + +`true` if this operator is `>` + +#### is_greater_than_or_equal + +```rust title="is_greater_than_or_equal" showLineNumbers +pub fn is_greater_than_or_equal(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L140-L142 + + +`true` if this operator is `>=` + +#### is_and + +```rust title="is_and" showLineNumbers +pub fn is_and(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L146-L148 + + +`true` if this operator is `&` + +#### is_or + +```rust title="is_or" showLineNumbers +pub fn is_or(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L152-L154 + + +`true` if this operator is `|` + +#### is_shift_right + +```rust title="is_shift_right" showLineNumbers +pub fn is_shift_right(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L164-L166 + + +`true` if this operator is `>>` + +#### is_shift_left + +```rust title="is_shift_right" showLineNumbers +pub fn is_shift_right(self) -> bool { +``` +> Source code: noir_stdlib/src/meta/op.nr#L164-L166 + + +`true` if this operator is `<<` + +#### quoted + +```rust title="binary_quoted" showLineNumbers +pub comptime fn quoted(self) -> Quoted { +``` +> Source code: noir_stdlib/src/meta/op.nr#L182-L184 + + +Returns this operator as a `Quoted` value. + +### Trait Implementations + +```rust +impl Eq for BinaryOp +impl Hash for BinaryOp +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/quoted.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/quoted.md new file mode 100644 index 000000000000..d7acf23bc070 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/quoted.md @@ -0,0 +1,141 @@ +--- +title: Quoted +--- + +`std::meta::quoted` contains methods on the built-in `Quoted` type which represents +quoted token streams and is the result of the `quote { ... }` expression. + +## Methods + +### as_expr + +```rust title="as_expr" showLineNumbers +pub comptime fn as_expr(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/quoted.nr#L6-L8 + + +Parses the quoted token stream as an expression. Returns `Option::none()` if +the expression failed to parse. + +Example: + +```rust title="as_expr_example" showLineNumbers +#[test] + fn test_expr_as_function_call() { + comptime + { + let expr = quote { foo(42) }.as_expr().unwrap(); + let (_function, args) = expr.as_function_call().unwrap(); + assert_eq(args.len(), 1); + assert_eq(args[0].as_integer().unwrap(), (42, false)); + } + } +``` +> Source code: test_programs/noir_test_success/comptime_expr/src/main.nr#L360-L371 + + +### as_module + +```rust title="as_module" showLineNumbers +pub comptime fn as_module(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/quoted.nr#L11-L13 + + +Interprets this token stream as a module path leading to the name of a module. +Returns `Option::none()` if the module isn't found or this token stream cannot be parsed as a path. + +Example: + +```rust title="as_module_example" showLineNumbers +mod baz { + pub mod qux {} +} + +#[test] +fn as_module_test() { + comptime { + let my_mod = quote { baz::qux }.as_module().unwrap(); + assert_eq(my_mod.name(), quote { qux }); + } +} +``` +> Source code: test_programs/compile_success_empty/comptime_module/src/main.nr#L115-L127 + + +### as_trait_constraint + +```rust title="as_trait_constraint" showLineNumbers +pub comptime fn as_trait_constraint(self) -> TraitConstraint {} +``` +> Source code: noir_stdlib/src/meta/quoted.nr#L16-L18 + + +Interprets this token stream as a trait constraint (without an object type). +Note that this function panics instead of returning `Option::none()` if the token +stream does not parse and resolve to a valid trait constraint. + +Example: + +```rust title="implements_example" showLineNumbers +pub fn function_with_where(_x: T) +where + T: SomeTrait, +{ + comptime { + let t = quote { T }.as_type(); + let some_trait_i32 = quote { SomeTrait }.as_trait_constraint(); + assert(t.implements(some_trait_i32)); + + assert(t.get_trait_impl(some_trait_i32).is_none()); + } +} +``` +> Source code: test_programs/compile_success_empty/comptime_type/src/main.nr#L160-L173 + + +### as_type + +```rust title="as_type" showLineNumbers +pub comptime fn as_type(self) -> Type {} +``` +> Source code: noir_stdlib/src/meta/quoted.nr#L21-L23 + + +Interprets this token stream as a resolved type. Panics if the token +stream doesn't parse to a type or if the type isn't a valid type in scope. + +```rust title="implements_example" showLineNumbers +pub fn function_with_where(_x: T) +where + T: SomeTrait, +{ + comptime { + let t = quote { T }.as_type(); + let some_trait_i32 = quote { SomeTrait }.as_trait_constraint(); + assert(t.implements(some_trait_i32)); + + assert(t.get_trait_impl(some_trait_i32).is_none()); + } +} +``` +> Source code: test_programs/compile_success_empty/comptime_type/src/main.nr#L160-L173 + + +### tokens + +```rust title="tokens" showLineNumbers +pub comptime fn tokens(self) -> [Quoted] {} +``` +> Source code: noir_stdlib/src/meta/quoted.nr#L26-L28 + + +Returns a slice of the individual tokens that form this token stream. + +## Trait Implementations + +```rust +impl Eq for Quoted +impl Hash for Quoted +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/struct_def.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/struct_def.md new file mode 100644 index 000000000000..fd609942f4e6 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/struct_def.md @@ -0,0 +1,177 @@ +--- +title: StructDefinition +--- + +`std::meta::struct_def` contains methods on the built-in `StructDefinition` type. +This type corresponds to `struct Name { field1: Type1, ... }` items in the source program. + +## Methods + +### add_attribute + +```rust title="add_attribute" showLineNumbers +pub comptime fn add_attribute(self, attribute: str) {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L3-L5 + + +Adds an attribute to the struct. + +### add_generic + +```rust title="add_generic" showLineNumbers +pub comptime fn add_generic(self, generic_name: str) -> Type {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L8-L10 + + +Adds an generic to the struct. Returns the new generic type. +Errors if the given generic name isn't a single identifier or if +the struct already has a generic with the same name. + +This method should be used carefully, if there is existing code referring +to the struct type it may be checked before this function is called and +see the struct with the original number of generics. This method should +thus be preferred to use on code generated from other macros and structs +that are not used in function signatures. + +Example: + +```rust title="add-generic-example" showLineNumbers +comptime fn add_generic(s: StructDefinition) { + assert_eq(s.generics().len(), 0); + let new_generic = s.add_generic("T"); + + let generics = s.generics(); + assert_eq(generics.len(), 1); + assert_eq(generics[0], new_generic); + } +``` +> Source code: test_programs/compile_success_empty/comptime_struct_definition/src/main.nr#L35-L44 + + +### as_type + +```rust title="as_type" showLineNumbers +pub comptime fn as_type(self) -> Type {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L15-L17 + + +Returns this struct as a type in the source program. If this struct has +any generics, the generics are also included as-is. + +### generics + +```rust title="generics" showLineNumbers +pub comptime fn generics(self) -> [Type] {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L26-L28 + + +Returns each generic on this struct. + +Example: + +``` +#[example] +struct Foo { + bar: [T; 2], + baz: Baz, +} + +comptime fn example(foo: StructDefinition) { + assert_eq(foo.generics().len(), 2); + + // Fails because `T` isn't in scope + // let t = quote { T }.as_type(); + // assert_eq(foo.generics()[0], t); +} +``` + +### fields + +```rust title="fields" showLineNumbers +pub comptime fn fields(self) -> [(Quoted, Type)] {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L33-L35 + + +Returns each field of this struct as a pair of (field name, field type). + +### has_named_attribute + +```rust title="has_named_attribute" showLineNumbers +pub comptime fn has_named_attribute(self, name: str) -> bool {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L20-L22 + + +Returns true if this struct has a custom attribute with the given name. + +### module + +```rust title="module" showLineNumbers +pub comptime fn module(self) -> Module {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L38-L40 + + +Returns the module where the struct is defined. + +### name + +```rust title="name" showLineNumbers +pub comptime fn name(self) -> Quoted {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L43-L45 + + +Returns the name of this struct + +Note that the returned quoted value will be just the struct name, it will +not be the full path to the struct, nor will it include any generics. + +### set_fields + +```rust title="set_fields" showLineNumbers +pub comptime fn set_fields(self, new_fields: [(Quoted, Type)]) {} +``` +> Source code: noir_stdlib/src/meta/struct_def.nr#L52-L54 + + +Sets the fields of this struct to the given fields list where each element +is a pair of the field's name and the field's type. Expects each field name +to be a single identifier. Note that this will override any previous fields +on this struct. If those should be preserved, use `.fields()` to retrieve the +current fields on the struct type and append the new fields from there. + +Example: + +```rust +// Change this struct to: +// struct Foo { +// a: u32, +// b: i8, +// } +#[mangle_fields] +struct Foo { x: Field } + +comptime fn mangle_fields(s: StructDefinition) { + s.set_fields(&[ + (quote { a }, quote { u32 }.as_type()), + (quote { b }, quote { i8 }.as_type()), + ]); +} +``` + +## Trait Implementations + +```rust +impl Eq for StructDefinition +impl Hash for StructDefinition +``` + +Note that each struct is assigned a unique ID internally and this is what is used for +equality and hashing. So even structs with identical generics and fields may not +be equal in this sense if they were originally different items in the source program. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_constraint.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_constraint.md new file mode 100644 index 000000000000..3106f732b5a6 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_constraint.md @@ -0,0 +1,17 @@ +--- +title: TraitConstraint +--- + +`std::meta::trait_constraint` contains methods on the built-in `TraitConstraint` type which represents +a trait constraint that can be used to search for a trait implementation. This is similar +syntactically to just the trait itself, but can also contain generic arguments. E.g. `Eq`, `Default`, +`BuildHasher`. + +This type currently has no public methods but it can be used alongside `Type` in `implements` or `get_trait_impl`. + +## Trait Implementations + +```rust +impl Eq for TraitConstraint +impl Hash for TraitConstraint +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_def.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_def.md new file mode 100644 index 000000000000..e661d3af7f1a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_def.md @@ -0,0 +1,26 @@ +--- +title: TraitDefinition +--- + +`std::meta::trait_def` contains methods on the built-in `TraitDefinition` type. This type +represents trait definitions such as `trait Foo { .. }` at the top-level of a program. + +## Methods + +### as_trait_constraint + +```rust title="as_trait_constraint" showLineNumbers +pub comptime fn as_trait_constraint(_self: Self) -> TraitConstraint {} +``` +> Source code: noir_stdlib/src/meta/trait_def.nr#L6-L8 + + +Converts this trait into a trait constraint. If there are any generics on this +trait, they will be kept as-is without instantiating or replacing them. + +## Trait Implementations + +```rust +impl Eq for TraitDefinition +impl Hash for TraitDefinition +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_impl.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_impl.md new file mode 100644 index 000000000000..a527617c1e61 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/trait_impl.md @@ -0,0 +1,60 @@ +--- +title: TraitImpl +--- + +`std::meta::trait_impl` contains methods on the built-in `TraitImpl` type which represents a trait +implementation such as `impl Foo for Bar { ... }`. + +## Methods + +### trait_generic_args + +```rust title="trait_generic_args" showLineNumbers +pub comptime fn trait_generic_args(self) -> [Type] {} +``` +> Source code: noir_stdlib/src/meta/trait_impl.nr#L3-L5 + + +Returns any generic arguments on the trait of this trait implementation, if any. + +```rs +impl Foo for Bar { ... } + +comptime { + let bar_type = quote { Bar }.as_type(); + let foo = quote { Foo }.as_trait_constraint(); + + let my_impl: TraitImpl = bar_type.get_trait_impl(foo).unwrap(); + + let generics = my_impl.trait_generic_args(); + assert_eq(generics.len(), 2); + + assert_eq(generics[0], quote { i32 }.as_type()); + assert_eq(generics[1], quote { Field }.as_type()); +} +``` + +### methods + +```rust title="methods" showLineNumbers +pub comptime fn methods(self) -> [FunctionDefinition] {} +``` +> Source code: noir_stdlib/src/meta/trait_impl.nr#L8-L10 + + +Returns each method in this trait impl. + +Example: + +```rs +comptime { + let i32_type = quote { i32 }.as_type(); + let eq = quote { Eq }.as_trait_constraint(); + + let impl_eq_for_i32: TraitImpl = i32_type.get_trait_impl(eq).unwrap(); + let methods = impl_eq_for_i32.methods(); + + assert_eq(methods.len(), 1); + assert_eq(methods[0].name(), quote { eq }); +} +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typ.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typ.md new file mode 100644 index 000000000000..90222c222f56 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typ.md @@ -0,0 +1,264 @@ +--- +title: Type +--- + +`std::meta::typ` contains methods on the built-in `Type` type used for representing +a type in the source program. + +## Functions + +```rust title="fresh_type_variable" showLineNumbers +pub comptime fn fresh_type_variable() -> Type {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L57-L59 + + +Creates and returns an unbound type variable. This is a special kind of type internal +to type checking which will type check with any other type. When it is type checked +against another type it will also be set to that type. For example, if `a` is a type +variable and we have the type equality `(a, i32) = (u8, i32)`, the compiler will set +`a` equal to `u8`. + +Unbound type variables will often be rendered as `_` while printing them. Bound type +variables will appear as the type they are bound to. + +This can be used in conjunction with functions which internally perform type checks +such as `Type::implements` or `Type::get_trait_impl` to potentially grab some of the types used. + +Note that calling `Type::implements` or `Type::get_trait_impl` on a type variable will always +fail. + +Example: + +```rust title="serialize-setup" showLineNumbers +trait Serialize {} + +impl Serialize<1> for Field {} + +impl Serialize for [T; N] +where + T: Serialize, +{} + +impl Serialize for (T, U) +where + T: Serialize, + U: Serialize, +{} +``` +> Source code: test_programs/compile_success_empty/comptime_type/src/main.nr#L14-L29 + +```rust title="fresh-type-variable-example" showLineNumbers +let typevar1 = std::meta::typ::fresh_type_variable(); + let constraint = quote { Serialize<$typevar1> }.as_trait_constraint(); + let field_type = quote { Field }.as_type(); + + // Search for a trait impl (binding typevar1 to 1 when the impl is found): + assert(field_type.implements(constraint)); + + // typevar1 should be bound to the "1" generic now: + assert_eq(typevar1.as_constant().unwrap(), 1); + + // If we want to do the same with a different type, we need to + // create a new type variable now that `typevar1` is bound + let typevar2 = std::meta::typ::fresh_type_variable(); + let constraint = quote { Serialize<$typevar2> }.as_trait_constraint(); + let array_type = quote { [(Field, Field); 5] }.as_type(); + assert(array_type.implements(constraint)); + + // Now typevar2 should be bound to the serialized pair size 2 times the array length 5 + assert_eq(typevar2.as_constant().unwrap(), 10); +``` +> Source code: test_programs/compile_success_empty/comptime_type/src/main.nr#L129-L149 + + +## Methods + +### as_array + +```rust title="as_array" showLineNumbers +pub comptime fn as_array(self) -> Option<(Type, Type)> {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L76-L78 + + +If this type is an array, return a pair of (element type, size type). + +Example: + +```rust +comptime { + let array_type = quote { [Field; 3] }.as_type(); + let (field_type, three_type) = array_type.as_array().unwrap(); + + assert(field_type.is_field()); + assert_eq(three_type.as_constant().unwrap(), 3); +} +``` + +### as_constant + +```rust title="as_constant" showLineNumbers +pub comptime fn as_constant(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L83-L85 + + +If this type is a constant integer (such as the `3` in the array type `[Field; 3]`), +return the numeric constant. + +### as_integer + +```rust title="as_integer" showLineNumbers +pub comptime fn as_integer(self) -> Option<(bool, u8)> {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L90-L92 + + +If this is an integer type, return a boolean which is `true` +if the type is signed, as well as the number of bits of this integer type. + +### as_mutable_reference + +```rust title="as_mutable_reference" showLineNumbers +comptime fn as_mutable_reference(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L96-L98 + + +If this is a mutable reference type `&mut T`, returns the mutable type `T`. + +### as_slice + +```rust title="as_slice" showLineNumbers +pub comptime fn as_slice(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L102-L104 + + +If this is a slice type, return the element type of the slice. + +### as_str + +```rust title="as_str" showLineNumbers +pub comptime fn as_str(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L108-L110 + + +If this is a `str` type, returns the length `N` as a type. + +### as_struct + +```rust title="as_struct" showLineNumbers +pub comptime fn as_struct(self) -> Option<(StructDefinition, [Type])> {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L114-L116 + + +If this is a struct type, returns the struct in addition to +any generic arguments on this type. + +### as_tuple + +```rust title="as_tuple" showLineNumbers +pub comptime fn as_tuple(self) -> Option<[Type]> {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L120-L122 + + +If this is a tuple type, returns each element type of the tuple. + +### get_trait_impl + +```rust title="get_trait_impl" showLineNumbers +pub comptime fn get_trait_impl(self, constraint: TraitConstraint) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L143-L145 + + +Retrieves the trait implementation that implements the given +trait constraint for this type. If the trait constraint is not +found, `None` is returned. Note that since the concrete trait implementation +for a trait constraint specified from a `where` clause is unknown, +this function will return `None` in these cases. If you only want to know +whether a type implements a trait, use `implements` instead. + +Example: + +```rust +comptime { + let field_type = quote { Field }.as_type(); + let default = quote { Default }.as_trait_constraint(); + + let the_impl: TraitImpl = field_type.get_trait_impl(default).unwrap(); + assert(the_impl.methods().len(), 1); +} +``` + +### implements + +```rust title="implements" showLineNumbers +pub comptime fn implements(self, constraint: TraitConstraint) -> bool {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L166-L168 + + +`true` if this type implements the given trait. Note that unlike +`get_trait_impl` this will also return true for any `where` constraints +in scope. + +Example: + +```rust +fn foo() where T: Default { + comptime { + let field_type = quote { Field }.as_type(); + let default = quote { Default }.as_trait_constraint(); + assert(field_type.implements(default)); + + let t = quote { T }.as_type(); + assert(t.implements(default)); + } +} +``` + +### is_bool + +```rust title="is_bool" showLineNumbers +pub comptime fn is_bool(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L172-L174 + + +`true` if this type is `bool`. + +### is_field + +```rust title="is_field" showLineNumbers +pub comptime fn is_field(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L178-L180 + + +`true` if this type is `Field`. + +### is_unit + +```rust title="is_unit" showLineNumbers +comptime fn is_unit(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/typ.nr#L184-L186 + + +`true` if this type is the unit `()` type. + +## Trait Implementations + +```rust +impl Eq for Type +impl Hash for Type +``` +Note that this is syntactic equality, this is not the same as whether two types will type check +to be the same type. Unless type inference or generics are being used however, users should not +typically have to worry about this distinction unless `std::meta::typ::fresh_type_variable` is used. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typed_expr.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typed_expr.md new file mode 100644 index 000000000000..0db7dbfef610 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/typed_expr.md @@ -0,0 +1,27 @@ +--- +title: TypedExpr +--- + +`std::meta::typed_expr` contains methods on the built-in `TypedExpr` type for resolved and type-checked expressions. + +## Methods + +### get_type + +```rust title="as_function_definition" showLineNumbers +pub comptime fn as_function_definition(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typed_expr.nr#L7-L9 + + +If this expression refers to a function definitions, returns it. Otherwise returns `Option::none()`. + +### get_type + +```rust title="get_type" showLineNumbers +pub comptime fn get_type(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/typed_expr.nr#L13-L15 + + +Returns the type of the expression, or `Option::none()` if there were errors when the expression was previously resolved. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/unresolved_type.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/unresolved_type.md new file mode 100644 index 000000000000..2826ec5ec0f0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/meta/unresolved_type.md @@ -0,0 +1,57 @@ +--- +title: UnresolvedType +--- + +`std::meta::unresolved_type` contains methods on the built-in `UnresolvedType` type for the syntax of types. + +## Methods + +### as_mutable_reference + +```rust title="as_mutable_reference" showLineNumbers +comptime fn as_mutable_reference(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/unresolved_type.nr#L8-L10 + + +If this is a mutable reference type `&mut T`, returns the mutable type `T`. + +### as_slice + +```rust title="as_slice" showLineNumbers +comptime fn as_slice(self) -> Option {} +``` +> Source code: noir_stdlib/src/meta/unresolved_type.nr#L14-L16 + + +If this is a slice `&[T]`, returns the element type `T`. + +### is_bool + +```rust title="is_bool" showLineNumbers +comptime fn is_bool(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/unresolved_type.nr#L20-L22 + + +Returns `true` if this type is `bool`. + +### is_field + +```rust title="is_field" showLineNumbers +pub comptime fn is_field(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/unresolved_type.nr#L26-L28 + + +Returns true if this type refers to the Field type. + +### is_unit + +```rust title="is_unit" showLineNumbers +comptime fn is_unit(self) -> bool {} +``` +> Source code: noir_stdlib/src/meta/unresolved_type.nr#L32-L34 + + +Returns true if this type is the unit `()` type. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/options.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/options.md new file mode 100644 index 000000000000..a1bd4e1de5fd --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/options.md @@ -0,0 +1,101 @@ +--- +title: Option Type +--- + +The `Option` type is a way to express that a value might be present (`Some(T))` or absent (`None`). It's a safer way to handle potential absence of values, compared to using nulls in many other languages. + +```rust +struct Option { + None, + Some(T), +} +``` + +The `Option` type, already imported into your Noir program, can be used directly: + +```rust +fn main() { + let none = Option::none(); + let some = Option::some(3); +} +``` + +See [this test](https://github.com/noir-lang/noir/blob/5cbfb9c4a06c8865c98ff2b594464b037d821a5c/crates/nargo_cli/tests/test_data/option/src/main.nr) for a more comprehensive set of examples of each of the methods described below. + +## Methods + +### none + +Constructs a none value. + +### some + +Constructs a some wrapper around a given value. + +### is_none + +Returns true if the Option is None. + +### is_some + +Returns true of the Option is Some. + +### unwrap + +Asserts `self.is_some()` and returns the wrapped value. + +### unwrap_unchecked + +Returns the inner value without asserting `self.is_some()`. This method can be useful within an if condition when we already know that `option.is_some()`. If the option is None, there is no guarantee what value will be returned, only that it will be of type T for an `Option`. + +### unwrap_or + +Returns the wrapped value if `self.is_some()`. Otherwise, returns the given default value. + +### unwrap_or_else + +Returns the wrapped value if `self.is_some()`. Otherwise, calls the given function to return a default value. + +### expect + +Asserts `self.is_some()` with a provided custom message and returns the contained `Some` value. The custom message is expected to be a format string. + +### map + +If self is `Some(x)`, this returns `Some(f(x))`. Otherwise, this returns `None`. + +### map_or + +If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns the given default value. + +### map_or_else + +If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns `default()`. + +### and + +Returns None if self is None. Otherwise, this returns `other`. + +### and_then + +If self is None, this returns None. Otherwise, this calls the given function with the Some value contained within self, and returns the result of that call. In some languages this function is called `flat_map` or `bind`. + +### or + +If self is Some, return self. Otherwise, return `other`. + +### or_else + +If self is Some, return self. Otherwise, return `default()`. + +### xor + +If only one of the two Options is Some, return that option. Otherwise, if both options are Some or both are None, None is returned. + +### filter + +Returns `Some(x)` if self is `Some(x)` and `predicate(x)` is true. Otherwise, this returns `None`. + +### flatten + +Flattens an `Option>` into a `Option`. This returns `None` if the outer Option is None. Otherwise, this returns the inner Option. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/recursion.mdx b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/recursion.mdx new file mode 100644 index 000000000000..60414a2fa519 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/recursion.mdx @@ -0,0 +1,85 @@ +--- +title: Recursive Proofs +description: Learn about how to write recursive proofs in Noir. +keywords: [recursion, recursive proofs, verification_key, verify_proof] +--- + +import BlackBoxInfo from '@site/src/components/Notes/_blackbox'; + +Noir supports recursively verifying proofs, meaning you verify the proof of a Noir program in another Noir program. This enables creating proofs of arbitrary size by doing step-wise verification of smaller components of a large proof. + +Read [the explainer on recursion](../../explainers/explainer-recursion.md) to know more about this function and the [guide on how to use it.](../../how_to/how-to-recursion.md) + +## The `#[recursive]` Attribute + +In Noir, the `#[recursive]` attribute is used to indicate that a circuit is designed for recursive proof generation. When applied, it informs the compiler and the tooling that the circuit should be compiled in a way that makes its proofs suitable for recursive verification. This attribute eliminates the need for manual flagging of recursion at the tooling level, streamlining the proof generation process for recursive circuits. + +### Example usage with `#[recursive]` + +```rust +#[recursive] +fn main(x: Field, y: pub Field) { + assert(x == y, "x and y are not equal"); +} + +// This marks the circuit as recursion-friendly and indicates that proofs generated from this circuit +// are intended for recursive verification. +``` + +By incorporating this attribute directly in the circuit's definition, tooling like Nargo and NoirJS can automatically execute recursive-specific duties for Noir programs (e.g. recursive-friendly proof artifact generation) without additional flags or configurations. + +## Verifying Recursive Proofs + +```rust +#[foreign(recursive_aggregation)] +pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [Field], key_hash: Field) {} +``` + + + +## Example usage + +```rust + +fn main( + verification_key : [Field; 114], + proof : [Field; 93], + public_inputs : [Field; 1], + key_hash : Field, + proof_b : [Field; 93], +) { + std::verify_proof( + verification_key, + proof, + public_inputs, + key_hash + ); + + std::verify_proof( + verification_key, + proof_b, + public_inputs, + key_hash + ); +} +``` + +You can see a full example of recursive proofs in [this example recursion demo repo](https://github.com/noir-lang/noir-examples/tree/master/recursion). + +## Parameters + +### `verification_key` + +The verification key for the zk program that is being verified. + +### `proof` + +The proof for the zk program that is being verified. + +### `public_inputs` + +These represent the public inputs of the proof we are verifying. + +### `key_hash` + +A key hash is used to check the validity of the verification key. The circuit implementing this opcode can use this hash to ensure that the key provided to the circuit matches the key produced by the circuit creator. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/traits.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/traits.md new file mode 100644 index 000000000000..ee20f9cd9493 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/noir/standard_library/traits.md @@ -0,0 +1,628 @@ +--- +title: Traits +description: Noir's stdlib provides a few commonly used traits. +keywords: [traits, trait, interface, protocol, default, add, eq] +--- + +## `std::default` + +### `std::default::Default` + +```rust title="default-trait" showLineNumbers +pub trait Default { + fn default() -> Self; +} +``` +> Source code: noir_stdlib/src/default.nr#L4-L8 + + +Constructs a default value of a type. + +Implementations: +```rust +impl Default for Field { .. } + +impl Default for i8 { .. } +impl Default for i16 { .. } +impl Default for i32 { .. } +impl Default for i64 { .. } + +impl Default for u8 { .. } +impl Default for u16 { .. } +impl Default for u32 { .. } +impl Default for u64 { .. } + +impl Default for () { .. } +impl Default for bool { .. } + +impl Default for [T; N] + where T: Default { .. } + +impl Default for [T] { .. } + +impl Default for (A, B) + where A: Default, B: Default { .. } + +impl Default for (A, B, C) + where A: Default, B: Default, C: Default { .. } + +impl Default for (A, B, C, D) + where A: Default, B: Default, C: Default, D: Default { .. } + +impl Default for (A, B, C, D, E) + where A: Default, B: Default, C: Default, D: Default, E: Default { .. } +``` + +For primitive integer types, the return value of `default` is `0`. Container +types such as arrays are filled with default values of their element type, +except slices whose length is unknown and thus defaulted to zero. + +--- + +## `std::convert` + +### `std::convert::From` + +```rust title="from-trait" showLineNumbers +pub trait From { + fn from(input: T) -> Self; +} +``` +> Source code: noir_stdlib/src/convert.nr#L1-L5 + + +The `From` trait defines how to convert from a given type `T` to the type on which the trait is implemented. + +The Noir standard library provides a number of implementations of `From` between primitive types. +```rust title="from-impls" showLineNumbers +// Unsigned integers + +impl From for u32 { + fn from(value: u8) -> u32 { + value as u32 + } +} + +impl From for u64 { + fn from(value: u8) -> u64 { + value as u64 + } +} +impl From for u64 { + fn from(value: u32) -> u64 { + value as u64 + } +} + +impl From for Field { + fn from(value: u8) -> Field { + value as Field + } +} +impl From for Field { + fn from(value: u32) -> Field { + value as Field + } +} +impl From for Field { + fn from(value: u64) -> Field { + value as Field + } +} + +// Signed integers + +impl From for i32 { + fn from(value: i8) -> i32 { + value as i32 + } +} + +impl From for i64 { + fn from(value: i8) -> i64 { + value as i64 + } +} +impl From for i64 { + fn from(value: i32) -> i64 { + value as i64 + } +} + +// Booleans +impl From for u8 { + fn from(value: bool) -> u8 { + value as u8 + } +} +impl From for u32 { + fn from(value: bool) -> u32 { + value as u32 + } +} +impl From for u64 { + fn from(value: bool) -> u64 { + value as u64 + } +} +impl From for i8 { + fn from(value: bool) -> i8 { + value as i8 + } +} +impl From for i32 { + fn from(value: bool) -> i32 { + value as i32 + } +} +impl From for i64 { + fn from(value: bool) -> i64 { + value as i64 + } +} +impl From for Field { + fn from(value: bool) -> Field { + value as Field + } +} +``` +> Source code: noir_stdlib/src/convert.nr#L28-L119 + + +#### When to implement `From` + +As a general rule of thumb, `From` may be implemented in the [situations where it would be suitable in Rust](https://doc.rust-lang.org/std/convert/trait.From.html#when-to-implement-from): + +- The conversion is *infallible*: Noir does not provide an equivalent to Rust's `TryFrom`, if the conversion can fail then provide a named method instead. +- The conversion is *lossless*: semantically, it should not lose or discard information. For example, `u32: From` can losslessly convert any `u16` into a valid `u32` such that the original `u16` can be recovered. On the other hand, `u16: From` should not be implemented as `2**16` is a `u32` which cannot be losslessly converted into a `u16`. +- The conversion is *value-preserving*: the conceptual kind and meaning of the resulting value is the same, even though the Noir type and technical representation might be different. While it's possible to infallibly and losslessly convert a `u8` into a `str<2>` hex representation, `4u8` and `"04"` are too different for `str<2>: From` to be implemented. +- The conversion is *obvious*: it's the only reasonable conversion between the two types. If there's ambiguity on how to convert between them such that the same input could potentially map to two different values then a named method should be used. For instance rather than implementing `U128: From<[u8; 16]>`, the methods `U128::from_le_bytes` and `U128::from_be_bytes` are used as otherwise the endianness of the array would be ambiguous, resulting in two potential values of `U128` from the same byte array. + +One additional recommendation specific to Noir is: +- The conversion is *efficient*: it's relatively cheap to convert between the two types. Due to being a ZK DSL, it's more important to avoid unnecessary computation compared to Rust. If the implementation of `From` would encourage users to perform unnecessary conversion, resulting in additional proving time, then it may be preferable to expose functionality such that this conversion may be avoided. + +### `std::convert::Into` + +The `Into` trait is defined as the reciprocal of `From`. It should be easy to convince yourself that if we can convert to type `A` from type `B`, then it's possible to convert type `B` into type `A`. + +For this reason, implementing `From` on a type will automatically generate a matching `Into` implementation. One should always prefer implementing `From` over `Into` as implementing `Into` will not generate a matching `From` implementation. + +```rust title="into-trait" showLineNumbers +pub trait Into { + fn into(self) -> T; +} + +impl Into for U +where + T: From, +{ + fn into(self) -> T { + T::from(self) + } +} +``` +> Source code: noir_stdlib/src/convert.nr#L13-L26 + + +`Into` is most useful when passing function arguments where the types don't quite match up with what the function expects. In this case, the compiler has enough type information to perform the necessary conversion by just appending `.into()` onto the arguments in question. + +--- + +## `std::cmp` + +### `std::cmp::Eq` + +```rust title="eq-trait" showLineNumbers +pub trait Eq { + fn eq(self, other: Self) -> bool; +} +``` +> Source code: noir_stdlib/src/cmp.nr#L4-L8 + + +Returns `true` if `self` is equal to `other`. Implementing this trait on a type +allows the type to be used with `==` and `!=`. + +Implementations: +```rust +impl Eq for Field { .. } + +impl Eq for i8 { .. } +impl Eq for i16 { .. } +impl Eq for i32 { .. } +impl Eq for i64 { .. } + +impl Eq for u8 { .. } +impl Eq for u16 { .. } +impl Eq for u32 { .. } +impl Eq for u64 { .. } + +impl Eq for () { .. } +impl Eq for bool { .. } + +impl Eq for [T; N] + where T: Eq { .. } + +impl Eq for [T] + where T: Eq { .. } + +impl Eq for (A, B) + where A: Eq, B: Eq { .. } + +impl Eq for (A, B, C) + where A: Eq, B: Eq, C: Eq { .. } + +impl Eq for (A, B, C, D) + where A: Eq, B: Eq, C: Eq, D: Eq { .. } + +impl Eq for (A, B, C, D, E) + where A: Eq, B: Eq, C: Eq, D: Eq, E: Eq { .. } +``` + +### `std::cmp::Ord` + +```rust title="ord-trait" showLineNumbers +pub trait Ord { + fn cmp(self, other: Self) -> Ordering; +} +``` +> Source code: noir_stdlib/src/cmp.nr#L210-L214 + + +`a.cmp(b)` compares two values returning `Ordering::less()` if `a < b`, +`Ordering::equal()` if `a == b`, or `Ordering::greater()` if `a > b`. +Implementing this trait on a type allows `<`, `<=`, `>`, and `>=` to be +used on values of the type. + +`std::cmp` also provides `max` and `min` functions for any type which implements the `Ord` trait. + +Implementations: + +```rust +impl Ord for u8 { .. } +impl Ord for u16 { .. } +impl Ord for u32 { .. } +impl Ord for u64 { .. } + +impl Ord for i8 { .. } +impl Ord for i16 { .. } +impl Ord for i32 { .. } + +impl Ord for i64 { .. } + +impl Ord for () { .. } +impl Ord for bool { .. } + +impl Ord for [T; N] + where T: Ord { .. } + +impl Ord for [T] + where T: Ord { .. } + +impl Ord for (A, B) + where A: Ord, B: Ord { .. } + +impl Ord for (A, B, C) + where A: Ord, B: Ord, C: Ord { .. } + +impl Ord for (A, B, C, D) + where A: Ord, B: Ord, C: Ord, D: Ord { .. } + +impl Ord for (A, B, C, D, E) + where A: Ord, B: Ord, C: Ord, D: Ord, E: Ord { .. } +``` + +--- + +## `std::ops` + +### `std::ops::Add`, `std::ops::Sub`, `std::ops::Mul`, and `std::ops::Div` + +These traits abstract over addition, subtraction, multiplication, and division respectively. +Implementing these traits for a given type will also allow that type to be used with the corresponding operator +for that trait (`+` for Add, etc) in addition to the normal method names. + +```rust title="add-trait" showLineNumbers +pub trait Add { + fn add(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L1-L5 + +```rust title="sub-trait" showLineNumbers +pub trait Sub { + fn sub(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L60-L64 + +```rust title="mul-trait" showLineNumbers +pub trait Mul { + fn mul(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L119-L123 + +```rust title="div-trait" showLineNumbers +pub trait Div { + fn div(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L178-L182 + + +The implementations block below is given for the `Add` trait, but the same types that implement +`Add` also implement `Sub`, `Mul`, and `Div`. + +Implementations: +```rust +impl Add for Field { .. } + +impl Add for i8 { .. } +impl Add for i16 { .. } +impl Add for i32 { .. } +impl Add for i64 { .. } + +impl Add for u8 { .. } +impl Add for u16 { .. } +impl Add for u32 { .. } +impl Add for u64 { .. } +``` + +### `std::ops::Rem` + +```rust title="rem-trait" showLineNumbers +pub trait Rem { + fn rem(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L237-L241 + + +`Rem::rem(a, b)` is the remainder function returning the result of what is +left after dividing `a` and `b`. Implementing `Rem` allows the `%` operator +to be used with the implementation type. + +Unlike other numeric traits, `Rem` is not implemented for `Field`. + +Implementations: +```rust +impl Rem for u8 { fn rem(self, other: u8) -> u8 { self % other } } +impl Rem for u16 { fn rem(self, other: u16) -> u16 { self % other } } +impl Rem for u32 { fn rem(self, other: u32) -> u32 { self % other } } +impl Rem for u64 { fn rem(self, other: u64) -> u64 { self % other } } + +impl Rem for i8 { fn rem(self, other: i8) -> i8 { self % other } } +impl Rem for i16 { fn rem(self, other: i16) -> i16 { self % other } } +impl Rem for i32 { fn rem(self, other: i32) -> i32 { self % other } } +impl Rem for i64 { fn rem(self, other: i64) -> i64 { self % other } } +``` + +### `std::ops::Neg` + +```rust title="neg-trait" showLineNumbers +pub trait Neg { + fn neg(self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L290-L294 + + +`Neg::neg` is equivalent to the unary negation operator `-`. + +Implementations: +```rust title="neg-trait-impls" showLineNumbers +impl Neg for Field { + fn neg(self) -> Field { + -self + } +} + +impl Neg for i8 { + fn neg(self) -> i8 { + -self + } +} +impl Neg for i16 { + fn neg(self) -> i16 { + -self + } +} +impl Neg for i32 { + fn neg(self) -> i32 { + -self + } +} +impl Neg for i64 { + fn neg(self) -> i64 { + -self + } +} +``` +> Source code: noir_stdlib/src/ops/arith.nr#L296-L323 + + +### `std::ops::Not` + +```rust title="not-trait" showLineNumbers +pub trait Not { + fn not(self: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L1-L5 + + +`Not::not` is equivalent to the unary bitwise NOT operator `!`. + +Implementations: +```rust title="not-trait-impls" showLineNumbers +impl Not for bool { + fn not(self) -> bool { + !self + } +} + +impl Not for u64 { + fn not(self) -> u64 { + !self + } +} +impl Not for u32 { + fn not(self) -> u32 { + !self + } +} +impl Not for u16 { + fn not(self) -> u16 { + !self + } +} +impl Not for u8 { + fn not(self) -> u8 { + !self + } +} +impl Not for u1 { + fn not(self) -> u1 { + !self + } +} + +impl Not for i8 { + fn not(self) -> i8 { + !self + } +} +impl Not for i16 { + fn not(self) -> i16 { + !self + } +} +impl Not for i32 { + fn not(self) -> i32 { + !self + } +} +impl Not for i64 { + fn not(self) -> i64 { + !self + } +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L7-L60 + + +### `std::ops::{ BitOr, BitAnd, BitXor }` + +```rust title="bitor-trait" showLineNumbers +pub trait BitOr { + fn bitor(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L62-L66 + +```rust title="bitand-trait" showLineNumbers +pub trait BitAnd { + fn bitand(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L121-L125 + +```rust title="bitxor-trait" showLineNumbers +pub trait BitXor { + fn bitxor(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L180-L184 + + +Traits for the bitwise operations `|`, `&`, and `^`. + +Implementing `BitOr`, `BitAnd` or `BitXor` for a type allows the `|`, `&`, or `^` operator respectively +to be used with the type. + +The implementations block below is given for the `BitOr` trait, but the same types that implement +`BitOr` also implement `BitAnd` and `BitXor`. + +Implementations: +```rust +impl BitOr for bool { fn bitor(self, other: bool) -> bool { self | other } } + +impl BitOr for u8 { fn bitor(self, other: u8) -> u8 { self | other } } +impl BitOr for u16 { fn bitor(self, other: u16) -> u16 { self | other } } +impl BitOr for u32 { fn bitor(self, other: u32) -> u32 { self | other } } +impl BitOr for u64 { fn bitor(self, other: u64) -> u64 { self | other } } + +impl BitOr for i8 { fn bitor(self, other: i8) -> i8 { self | other } } +impl BitOr for i16 { fn bitor(self, other: i16) -> i16 { self | other } } +impl BitOr for i32 { fn bitor(self, other: i32) -> i32 { self | other } } +impl BitOr for i64 { fn bitor(self, other: i64) -> i64 { self | other } } +``` + +### `std::ops::{ Shl, Shr }` + +```rust title="shl-trait" showLineNumbers +pub trait Shl { + fn shl(self, other: u8) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L239-L243 + +```rust title="shr-trait" showLineNumbers +pub trait Shr { + fn shr(self, other: u8) -> Self; +} +``` +> Source code: noir_stdlib/src/ops/bit.nr#L292-L296 + + +Traits for a bit shift left and bit shift right. + +Implementing `Shl` for a type allows the left shift operator (`<<`) to be used with the implementation type. +Similarly, implementing `Shr` allows the right shift operator (`>>`) to be used with the type. + +Note that bit shifting is not currently implemented for signed types. + +The implementations block below is given for the `Shl` trait, but the same types that implement +`Shl` also implement `Shr`. + +Implementations: +```rust +impl Shl for u8 { fn shl(self, other: u8) -> u8 { self << other } } +impl Shl for u16 { fn shl(self, other: u16) -> u16 { self << other } } +impl Shl for u32 { fn shl(self, other: u32) -> u32 { self << other } } +impl Shl for u64 { fn shl(self, other: u64) -> u64 { self << other } } +``` + +--- + +## `std::append` + +### `std::append::Append` + +`Append` can abstract over types that can be appended to - usually container types: + +```rust title="append-trait" showLineNumbers +pub trait Append { + fn empty() -> Self; + fn append(self, other: Self) -> Self; +} +``` +> Source code: noir_stdlib/src/append.nr#L9-L14 + + +`Append` requires two methods: + +- `empty`: Constructs an empty value of `Self`. +- `append`: Append two values together, returning the result. + +Additionally, it is expected that for any implementation: + +- `T::empty().append(x) == x` +- `x.append(T::empty()) == x` + +Implementations: +```rust +impl Append for [T] +impl Append for Quoted +``` diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/.nojekyll b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/.nojekyll new file mode 100644 index 000000000000..e2ac6616addc --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/classes/Noir.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/classes/Noir.md new file mode 100644 index 000000000000..ead255bc5047 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/classes/Noir.md @@ -0,0 +1,52 @@ +# Noir + +## Constructors + +### new Noir(circuit) + +```ts +new Noir(circuit): Noir +``` + +#### Parameters + +| Parameter | Type | +| :------ | :------ | +| `circuit` | `CompiledCircuit` | + +#### Returns + +[`Noir`](Noir.md) + +## Methods + +### execute() + +```ts +execute(inputs, foreignCallHandler?): Promise +``` + +#### Parameters + +| Parameter | Type | +| :------ | :------ | +| `inputs` | `InputMap` | +| `foreignCallHandler`? | [`ForeignCallHandler`](../type-aliases/ForeignCallHandler.md) | + +#### Returns + +`Promise`\<`object`\> + +#### Description + +Allows to execute a circuit to get its witness and return value. + +#### Example + +```typescript +async execute(inputs) +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/and.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/and.md new file mode 100644 index 000000000000..c783283e3965 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/and.md @@ -0,0 +1,22 @@ +# and() + +```ts +and(lhs, rhs): string +``` + +Performs a bitwise AND operation between `lhs` and `rhs` + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `lhs` | `string` | | +| `rhs` | `string` | | + +## Returns + +`string` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/blake2s256.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/blake2s256.md new file mode 100644 index 000000000000..7882d0da8d50 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/blake2s256.md @@ -0,0 +1,21 @@ +# blake2s256() + +```ts +blake2s256(inputs): Uint8Array +``` + +Calculates the Blake2s256 hash of the input bytes + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `inputs` | `Uint8Array` | | + +## Returns + +`Uint8Array` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256k1_verify.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256k1_verify.md new file mode 100644 index 000000000000..5e3cd53e9d36 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256k1_verify.md @@ -0,0 +1,28 @@ +# ecdsa\_secp256k1\_verify() + +```ts +ecdsa_secp256k1_verify( + hashed_msg, + public_key_x_bytes, + public_key_y_bytes, + signature): boolean +``` + +Verifies a ECDSA signature over the secp256k1 curve. + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `hashed_msg` | `Uint8Array` | | +| `public_key_x_bytes` | `Uint8Array` | | +| `public_key_y_bytes` | `Uint8Array` | | +| `signature` | `Uint8Array` | | + +## Returns + +`boolean` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256r1_verify.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256r1_verify.md new file mode 100644 index 000000000000..0b20ff689575 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/ecdsa_secp256r1_verify.md @@ -0,0 +1,28 @@ +# ecdsa\_secp256r1\_verify() + +```ts +ecdsa_secp256r1_verify( + hashed_msg, + public_key_x_bytes, + public_key_y_bytes, + signature): boolean +``` + +Verifies a ECDSA signature over the secp256r1 curve. + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `hashed_msg` | `Uint8Array` | | +| `public_key_x_bytes` | `Uint8Array` | | +| `public_key_y_bytes` | `Uint8Array` | | +| `signature` | `Uint8Array` | | + +## Returns + +`boolean` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/xor.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/xor.md new file mode 100644 index 000000000000..8d762b895d30 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/functions/xor.md @@ -0,0 +1,22 @@ +# xor() + +```ts +xor(lhs, rhs): string +``` + +Performs a bitwise XOR operation between `lhs` and `rhs` + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `lhs` | `string` | | +| `rhs` | `string` | | + +## Returns + +`string` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/index.md new file mode 100644 index 000000000000..4de7a6969910 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/index.md @@ -0,0 +1,47 @@ +# noir_js + +## Exports + +### Classes + +| Class | Description | +| :------ | :------ | +| [Noir](classes/Noir.md) | - | + +### Type Aliases + +| Type alias | Description | +| :------ | :------ | +| [ErrorWithPayload](type-aliases/ErrorWithPayload.md) | - | +| [ForeignCallHandler](type-aliases/ForeignCallHandler.md) | A callback which performs an foreign call and returns the response. | +| [ForeignCallInput](type-aliases/ForeignCallInput.md) | - | +| [ForeignCallOutput](type-aliases/ForeignCallOutput.md) | - | +| [WitnessMap](type-aliases/WitnessMap.md) | - | + +### Functions + +| Function | Description | +| :------ | :------ | +| [and](functions/and.md) | Performs a bitwise AND operation between `lhs` and `rhs` | +| [blake2s256](functions/blake2s256.md) | Calculates the Blake2s256 hash of the input bytes | +| [ecdsa\_secp256k1\_verify](functions/ecdsa_secp256k1_verify.md) | Verifies a ECDSA signature over the secp256k1 curve. | +| [ecdsa\_secp256r1\_verify](functions/ecdsa_secp256r1_verify.md) | Verifies a ECDSA signature over the secp256r1 curve. | +| [xor](functions/xor.md) | Performs a bitwise XOR operation between `lhs` and `rhs` | + +## References + +### CompiledCircuit + +Renames and re-exports [InputMap](index.md#inputmap) + +## Variables + +### InputMap + +```ts +InputMap: any; +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ErrorWithPayload.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ErrorWithPayload.md new file mode 100644 index 000000000000..e8c2f4aef3d5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ErrorWithPayload.md @@ -0,0 +1,15 @@ +# ErrorWithPayload + +```ts +type ErrorWithPayload: ExecutionError & object; +``` + +## Type declaration + +| Member | Type | Description | +| :------ | :------ | :------ | +| `decodedAssertionPayload` | `any` | - | + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md new file mode 100644 index 000000000000..812b8b164818 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md @@ -0,0 +1,24 @@ +# ForeignCallHandler + +```ts +type ForeignCallHandler: (name, inputs) => Promise; +``` + +A callback which performs an foreign call and returns the response. + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `name` | `string` | The identifier for the type of foreign call being performed. | +| `inputs` | [`ForeignCallInput`](ForeignCallInput.md)[] | An array of hex encoded inputs to the foreign call. | + +## Returns + +`Promise`\<[`ForeignCallOutput`](ForeignCallOutput.md)[]\> + +outputs - An array of hex encoded outputs containing the results of the foreign call. + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallInput.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallInput.md new file mode 100644 index 000000000000..dd95809186a2 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallInput.md @@ -0,0 +1,9 @@ +# ForeignCallInput + +```ts +type ForeignCallInput: string[]; +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md new file mode 100644 index 000000000000..b71fb78a9469 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md @@ -0,0 +1,9 @@ +# ForeignCallOutput + +```ts +type ForeignCallOutput: string | string[]; +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/WitnessMap.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/WitnessMap.md new file mode 100644 index 000000000000..258c46f9d0c9 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/type-aliases/WitnessMap.md @@ -0,0 +1,9 @@ +# WitnessMap + +```ts +type WitnessMap: Map; +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/typedoc-sidebar.cjs b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/typedoc-sidebar.cjs new file mode 100644 index 000000000000..4796b5abaa86 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_js/typedoc-sidebar.cjs @@ -0,0 +1,4 @@ +// @ts-check +/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ +const typedocSidebar = { items: [{"type":"category","label":"Classes","items":[{"type":"doc","id":"reference/NoirJS/noir_js/classes/Noir","label":"Noir"}]},{"type":"category","label":"Type Aliases","items":[{"type":"doc","id":"reference/NoirJS/noir_js/type-aliases/ErrorWithPayload","label":"ErrorWithPayload"},{"type":"doc","id":"reference/NoirJS/noir_js/type-aliases/ForeignCallHandler","label":"ForeignCallHandler"},{"type":"doc","id":"reference/NoirJS/noir_js/type-aliases/ForeignCallInput","label":"ForeignCallInput"},{"type":"doc","id":"reference/NoirJS/noir_js/type-aliases/ForeignCallOutput","label":"ForeignCallOutput"},{"type":"doc","id":"reference/NoirJS/noir_js/type-aliases/WitnessMap","label":"WitnessMap"}]},{"type":"category","label":"Functions","items":[{"type":"doc","id":"reference/NoirJS/noir_js/functions/and","label":"and"},{"type":"doc","id":"reference/NoirJS/noir_js/functions/blake2s256","label":"blake2s256"},{"type":"doc","id":"reference/NoirJS/noir_js/functions/ecdsa_secp256k1_verify","label":"ecdsa_secp256k1_verify"},{"type":"doc","id":"reference/NoirJS/noir_js/functions/ecdsa_secp256r1_verify","label":"ecdsa_secp256r1_verify"},{"type":"doc","id":"reference/NoirJS/noir_js/functions/xor","label":"xor"}]}]}; +module.exports = typedocSidebar.items; \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/.nojekyll b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/.nojekyll new file mode 100644 index 000000000000..e2ac6616addc --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile.md new file mode 100644 index 000000000000..6faf763b37f7 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile.md @@ -0,0 +1,51 @@ +# compile() + +```ts +compile( + fileManager, + projectPath?, + logFn?, +debugLogFn?): Promise +``` + +Compiles a Noir project + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `fileManager` | `FileManager` | The file manager to use | +| `projectPath`? | `string` | The path to the project inside the file manager. Defaults to the root of the file manager | +| `logFn`? | `LogFn` | A logging function. If not provided, console.log will be used | +| `debugLogFn`? | `LogFn` | A debug logging function. If not provided, logFn will be used | + +## Returns + +`Promise`\<[`ProgramCompilationArtifacts`](../index.md#programcompilationartifacts)\> + +## Example + +```typescript +// Node.js + +import { compile_program, createFileManager } from '@noir-lang/noir_wasm'; + +const fm = createFileManager(myProjectPath); +const myCompiledCode = await compile_program(fm); +``` + +```typescript +// Browser + +import { compile_program, createFileManager } from '@noir-lang/noir_wasm'; + +const fm = createFileManager('/'); +for (const path of files) { + await fm.writeFile(path, await getFileAsStream(path)); +} +const myCompiledCode = await compile_program(fm); +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile_contract.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile_contract.md new file mode 100644 index 000000000000..7d0b39a43ef8 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/compile_contract.md @@ -0,0 +1,51 @@ +# compile\_contract() + +```ts +compile_contract( + fileManager, + projectPath?, + logFn?, +debugLogFn?): Promise +``` + +Compiles a Noir project + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `fileManager` | `FileManager` | The file manager to use | +| `projectPath`? | `string` | The path to the project inside the file manager. Defaults to the root of the file manager | +| `logFn`? | `LogFn` | A logging function. If not provided, console.log will be used | +| `debugLogFn`? | `LogFn` | A debug logging function. If not provided, logFn will be used | + +## Returns + +`Promise`\<[`ContractCompilationArtifacts`](../index.md#contractcompilationartifacts)\> + +## Example + +```typescript +// Node.js + +import { compile_contract, createFileManager } from '@noir-lang/noir_wasm'; + +const fm = createFileManager(myProjectPath); +const myCompiledCode = await compile_contract(fm); +``` + +```typescript +// Browser + +import { compile_contract, createFileManager } from '@noir-lang/noir_wasm'; + +const fm = createFileManager('/'); +for (const path of files) { + await fm.writeFile(path, await getFileAsStream(path)); +} +const myCompiledCode = await compile_contract(fm); +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/createFileManager.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/createFileManager.md new file mode 100644 index 000000000000..7e65c1d69c7e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/createFileManager.md @@ -0,0 +1,21 @@ +# createFileManager() + +```ts +createFileManager(dataDir): FileManager +``` + +Creates a new FileManager instance based on fs in node and memfs in the browser (via webpack alias) + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `dataDir` | `string` | root of the file system | + +## Returns + +`FileManager` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/inflateDebugSymbols.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/inflateDebugSymbols.md new file mode 100644 index 000000000000..fcea92753412 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/functions/inflateDebugSymbols.md @@ -0,0 +1,21 @@ +# inflateDebugSymbols() + +```ts +inflateDebugSymbols(debugSymbols): any +``` + +Decompresses and decodes the debug symbols + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `debugSymbols` | `string` | The base64 encoded debug symbols | + +## Returns + +`any` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/index.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/index.md new file mode 100644 index 000000000000..b6e0f9d1bc0e --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/index.md @@ -0,0 +1,49 @@ +# noir_wasm + +## Exports + +### Functions + +| Function | Description | +| :------ | :------ | +| [compile](functions/compile.md) | Compiles a Noir project | +| [compile\_contract](functions/compile_contract.md) | Compiles a Noir project | +| [createFileManager](functions/createFileManager.md) | Creates a new FileManager instance based on fs in node and memfs in the browser (via webpack alias) | +| [inflateDebugSymbols](functions/inflateDebugSymbols.md) | Decompresses and decodes the debug symbols | + +## References + +### compile\_program + +Renames and re-exports [compile](functions/compile.md) + +## Interfaces + +### ContractCompilationArtifacts + +The compilation artifacts of a given contract. + +#### Properties + +| Property | Type | Description | +| :------ | :------ | :------ | +| `contract` | `ContractArtifact` | The compiled contract. | +| `warnings` | `unknown`[] | Compilation warnings. | + +*** + +### ProgramCompilationArtifacts + +The compilation artifacts of a given program. + +#### Properties + +| Property | Type | Description | +| :------ | :------ | :------ | +| `name` | `string` | not part of the compilation output, injected later | +| `program` | `ProgramArtifact` | The compiled contract. | +| `warnings` | `unknown`[] | Compilation warnings. | + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/typedoc-sidebar.cjs b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/typedoc-sidebar.cjs new file mode 100644 index 000000000000..e0870710349c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/NoirJS/noir_wasm/typedoc-sidebar.cjs @@ -0,0 +1,4 @@ +// @ts-check +/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ +const typedocSidebar = { items: [{"type":"doc","id":"reference/NoirJS/noir_wasm/index","label":"API"},{"type":"category","label":"Functions","items":[{"type":"doc","id":"reference/NoirJS/noir_wasm/functions/compile","label":"compile"},{"type":"doc","id":"reference/NoirJS/noir_wasm/functions/compile_contract","label":"compile_contract"},{"type":"doc","id":"reference/NoirJS/noir_wasm/functions/createFileManager","label":"createFileManager"},{"type":"doc","id":"reference/NoirJS/noir_wasm/functions/inflateDebugSymbols","label":"inflateDebugSymbols"}]}]}; +module.exports = typedocSidebar.items; \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/_category_.json new file mode 100644 index 000000000000..5b6a20a609af --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 4, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/_category_.json new file mode 100644 index 000000000000..27869205ad3c --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Debugger", + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_known_limitations.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_known_limitations.md new file mode 100644 index 000000000000..936d416ac4bc --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_known_limitations.md @@ -0,0 +1,59 @@ +--- +title: Known limitations +description: + An overview of known limitations of the current version of the Noir debugger +keywords: + [ + Nargo, + Noir Debugger, + VS Code, + ] +sidebar_position: 2 +--- + +# Debugger Known Limitations + +There are currently some limits to what the debugger can observe. + +## Mutable references + +The debugger is currently blind to any state mutated via a mutable reference. For example, in: + +``` +let mut x = 1; +let y = &mut x; +*y = 2; +``` + +The update on `x` will not be observed by the debugger. That means, when running `vars` from the debugger REPL, or inspecting the _local variables_ pane in the VS Code debugger, `x` will appear with value 1 despite having executed `*y = 2;`. + +## Variables of type function or mutable references are opaque + +When inspecting variables, any variable of type `Function` or `MutableReference` will render its value as `<>` or `<>`. + +## Debugger instrumentation affects resulting ACIR + +In order to make the state of local variables observable, the debugger compiles Noir circuits interleaving foreign calls that track any mutations to them. While this works (except in the cases described above) and doesn't introduce any behavior changes, it does as a side effect produce bigger bytecode. In particular, when running the command `opcodes` on the REPL debugger, you will notice Unconstrained VM blocks that look like this: + +``` +... +5 BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [], q_c: 2 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(2))], q_c: 0 })] + | outputs=[] + 5.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 5.1 | Mov { destination: RegisterIndex(3), source: RegisterIndex(1) } + 5.2 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 5.3 | Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 5.4 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 5.5 | Mov { destination: RegisterIndex(3), source: RegisterIndex(3) } + 5.6 | Call { location: 8 } + 5.7 | Stop + 5.8 | ForeignCall { function: "__debug_var_assign", destinations: [], inputs: [RegisterIndex(RegisterIndex(2)), RegisterIndex(RegisterIndex(3))] } +... +``` + +If you are interested in debugging/inspecting compiled ACIR without these synthetic changes, you can invoke the REPL debugger with the `--skip-instrumentation` flag or launch the VS Code debugger with the `skipConfiguration` property set to true in its launch configuration. You can find more details about those in the [Debugger REPL reference](debugger_repl.md) and the [VS Code Debugger reference](debugger_vscode.md). + +:::note +Skipping debugger instrumentation means you won't be able to inspect values of local variables. +::: + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_repl.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_repl.md new file mode 100644 index 000000000000..46e2011304e5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_repl.md @@ -0,0 +1,360 @@ +--- +title: REPL Debugger +description: + Noir Debugger REPL options and commands. +keywords: + [ + Nargo, + Noir CLI, + Noir Debugger, + REPL, + ] +sidebar_position: 1 +--- + +## Running the REPL debugger + +`nargo debug [OPTIONS] [WITNESS_NAME]` + +Runs the Noir REPL debugger. If a `WITNESS_NAME` is provided the debugger writes the resulting execution witness to a `WITNESS_NAME` file. + +### Options + +| Option | Description | +| --------------------- | ------------------------------------------------------------ | +| `-p, --prover-name ` | The name of the toml file which contains the inputs for the prover [default: Prover]| +| `--package ` | The name of the package to debug | +| `--print-acir` | Display the ACIR for compiled circuit | +| `--deny-warnings` | Treat all warnings as errors | +| `--silence-warnings` | Suppress warnings | +| `-h, --help` | Print help | + +None of these options are required. + +:::note +Since the debugger starts by compiling the target package, all Noir compiler options are also available. Check out the [compiler reference](../nargo_commands.md#nargo-compile) to learn more about the compiler options. +::: + +## REPL commands + +Once the debugger is running, it accepts the following commands. + +#### `help` (h) + +Displays the menu of available commands. + +``` +> help +Available commands: + + opcodes display ACIR opcodes + into step into to the next opcode + next step until a new source location is reached + out step until a new source location is reached + and the current stack frame is finished + break LOCATION:OpcodeLocation add a breakpoint at an opcode location + over step until a new source location is reached + without diving into function calls + restart restart the debugging session + delete LOCATION:OpcodeLocation delete breakpoint at an opcode location + witness show witness map + witness index:u32 display a single witness from the witness map + witness index:u32 value:String update a witness with the given value + memset index:usize value:String update a memory cell with the given + value + continue continue execution until the end of the + program + vars show variable values available at this point + in execution + stacktrace display the current stack trace + memory show memory (valid when executing unconstrained code) value + step step to the next ACIR opcode + +Other commands: + + help Show this help message + quit Quit repl + +``` + +### Stepping through programs + +#### `next` (n) + +Step until the next Noir source code location. While other commands, such as [`into`](#into-i) and [`step`](#step-s), allow for finer grained control of the program's execution at the opcode level, `next` is source code centric. For example: + +``` +3 ... +4 fn main(x: u32) { +5 assert(entry_point(x) == 2); +6 swap_entry_point(x, x + 1); +7 -> assert(deep_entry_point(x) == 4); +8 multiple_values_entry_point(x); +9 } +``` + + +Using `next` here would cause the debugger to jump to the definition of `deep_entry_point` (if available). + +If you want to step over `deep_entry_point` and go straight to line 8, use [the `over` command](#over) instead. + +#### `over` + +Step until the next source code location, without diving into function calls. For example: + +``` +3 ... +4 fn main(x: u32) { +5 assert(entry_point(x) == 2); +6 swap_entry_point(x, x + 1); +7 -> assert(deep_entry_point(x) == 4); +8 multiple_values_entry_point(x); +9 } +``` + + +Using `over` here would cause the debugger to execute until line 8 (`multiple_values_entry_point(x);`). + +If you want to step into `deep_entry_point` instead, use [the `next` command](#next-n). + +#### `out` + +Step until the end of the current function call. For example: + +``` + 3 ... + 4 fn main(x: u32) { + 5 assert(entry_point(x) == 2); + 6 swap_entry_point(x, x + 1); + 7 -> assert(deep_entry_point(x) == 4); + 8 multiple_values_entry_point(x); + 9 } + 10 + 11 unconstrained fn returns_multiple_values(x: u32) -> (u32, u32, u32, u32) { + 12 ... + ... + 55 + 56 unconstrained fn deep_entry_point(x: u32) -> u32 { + 57 -> level_1(x + 1) + 58 } + +``` + +Running `out` here will resume execution until line 8. + +#### `step` (s) + +Skips to the next ACIR code. A compiled Noir program is a sequence of ACIR opcodes. However, an unconstrained VM opcode denotes the start of an unconstrained code block, to be executed by the unconstrained VM. For example (redacted for brevity): + +``` +0 BLACKBOX::RANGE [(_0, num_bits: 32)] [ ] +1 -> BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 })] outputs=[Simple(Witness(1))] + 1.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 1.1 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 1.2 | Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 1.3 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 1.4 | Call { location: 7 } + ... + 1.43 | Return +2 EXPR [ (1, _1) -2 ] +``` + +The `->` here shows the debugger paused at an ACIR opcode: `BRILLIG`, at index 1, which denotes an unconstrained code block is about to start. + +Using the `step` command at this point would result in the debugger stopping at ACIR opcode 2, `EXPR`, skipping unconstrained computation steps. + +Use [the `into` command](#into-i) instead if you want to follow unconstrained computation step by step. + +#### `into` (i) + +Steps into the next opcode. A compiled Noir program is a sequence of ACIR opcodes. However, a BRILLIG opcode denotes the start of an unconstrained code block, to be executed by the unconstrained VM. For example (redacted for brevity): + +``` +0 BLACKBOX::RANGE [(_0, num_bits: 32)] [ ] +1 -> BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 })] outputs=[Simple(Witness(1))] + 1.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 1.1 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 1.2 | Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 1.3 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 1.4 | Call { location: 7 } + ... + 1.43 | Return +2 EXPR [ (1, _1) -2 ] +``` + +The `->` here shows the debugger paused at an ACIR opcode: `BRILLIG`, at index 1, which denotes an unconstrained code block is about to start. + +Using the `into` command at this point would result in the debugger stopping at opcode 1.0, `Mov ...`, allowing the debugger user to follow unconstrained computation step by step. + +Use [the `step` command](#step-s) instead if you want to skip to the next ACIR code directly. + +#### `continue` (c) + +Continues execution until the next breakpoint, or the end of the program. + +#### `restart` (res) + +Interrupts execution, and restarts a new debugging session from scratch. + +#### `opcodes` (o) + +Display the program's ACIR opcode sequence. For example: + +``` +0 BLACKBOX::RANGE [(_0, num_bits: 32)] [ ] +1 -> BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 })] outputs=[Simple(Witness(1))] + 1.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 1.1 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 1.2 | Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 1.3 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 1.4 | Call { location: 7 } + ... + 1.43 | Return +2 EXPR [ (1, _1) -2 ] +``` + +### Breakpoints + +#### `break [Opcode]` (or shorthand `b [Opcode]`) + +Sets a breakpoint on the specified opcode index. To get a list of the program opcode numbers, see [the `opcode` command](#opcodes-o). For example: + +``` +0 BLACKBOX::RANGE [(_0, num_bits: 32)] [ ] +1 -> BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 })] outputs=[Simple(Witness(1))] + 1.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 1.1 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 1.2 | Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 1.3 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 1.4 | Call { location: 7 } + ... + 1.43 | Return +2 EXPR [ (1, _1) -2 ] +``` + +In this example, issuing a `break 1.2` command adds break on opcode 1.2, as denoted by the `*` character: + +``` +0 BLACKBOX::RANGE [(_0, num_bits: 32)] [ ] +1 -> BRILLIG inputs=[Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 })] outputs=[Simple(Witness(1))] + 1.0 | Mov { destination: RegisterIndex(2), source: RegisterIndex(0) } + 1.1 | Const { destination: RegisterIndex(0), value: Value { inner: 0 } } + 1.2 | * Const { destination: RegisterIndex(1), value: Value { inner: 0 } } + 1.3 | Mov { destination: RegisterIndex(2), source: RegisterIndex(2) } + 1.4 | Call { location: 7 } + ... + 1.43 | Return +2 EXPR [ (1, _1) -2 ] +``` + +Running [the `continue` command](#continue-c) at this point would cause the debugger to execute the program until opcode 1.2. + +#### `delete [Opcode]` (or shorthand `d [Opcode]`) + +Deletes a breakpoint at an opcode location. Usage is analogous to [the `break` command](#). + +### Variable inspection + +#### vars + +Show variable values available at this point in execution. + +:::note +The ability to inspect variable values from the debugger depends on compilation to be run in a special debug instrumentation mode. This instrumentation weaves variable tracing code with the original source code. + +So variable value inspection comes at the expense of making the resulting ACIR bytecode bigger and harder to understand and optimize. + +If you find this compromise unacceptable, you can run the debugger with the flag `--skip-debug-instrumentation`. This will compile your circuit without any additional debug information, so the resulting ACIR bytecode will be identical to the one produced by standard Noir compilation. However, if you opt for this, the `vars` command will not be available while debugging. +::: + + +### Stacktrace + +#### `stacktrace` + +Displays the current stack trace. + + +### Witness map + +#### `witness` (w) + +Show witness map. For example: + +``` +_0 = 0 +_1 = 2 +_2 = 1 +``` + +#### `witness [Witness Index]` + +Display a single witness from the witness map. For example: + +``` +> witness 1 +_1 = 2 +``` + +#### `witness [Witness Index] [New value]` + +Overwrite the given index with a new value. For example: + +``` +> witness 1 3 +_1 = 3 +``` + + +### Unconstrained VM memory + +#### `memory` + +Show unconstrained VM memory state. For example: + +``` +> memory +At opcode 1.13: Store { destination_pointer: RegisterIndex(0), source: RegisterIndex(3) } +... +> registers +0 = 0 +1 = 10 +2 = 0 +3 = 1 +4 = 1 +5 = 2³² +6 = 1 +> into +At opcode 1.14: Const { destination: RegisterIndex(5), value: Value { inner: 1 } } +... +> memory +0 = 1 +> +``` + +In the example above: we start with clean memory, then step through a `Store` opcode which stores the value of register 3 (1) into the memory address stored in register 0 (0). Thus now `memory` shows memory address 0 contains value 1. + +:::note +This command is only functional while the debugger is executing unconstrained code. +::: + +#### `memset [Memory address] [New value]` + +Update a memory cell with the given value. For example: + +``` +> memory +0 = 1 +> memset 0 2 +> memory +0 = 2 +> memset 1 4 +> memory +0 = 2 +1 = 4 +> +``` + +:::note +This command is only functional while the debugger is executing unconstrained code. +::: \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_vscode.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_vscode.md new file mode 100644 index 000000000000..c027332b3b04 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/debugger/debugger_vscode.md @@ -0,0 +1,82 @@ +--- +title: VS Code Debugger +description: + VS Code Debugger configuration and features. +keywords: + [ + Nargo, + Noir CLI, + Noir Debugger, + VS Code, + IDE, + ] +sidebar_position: 0 +--- + +# VS Code Noir Debugger Reference + +The Noir debugger enabled by the vscode-noir extension ships with default settings such that the most common scenario should run without any additional configuration steps. + +These defaults can nevertheless be overridden by defining a launch configuration file. This page provides a reference for the properties you can override via a launch configuration file, as well as documenting the Nargo `dap` command, which is a dependency of the VS Code Noir debugger. + + +## Creating and editing launch configuration files + +To create a launch configuration file from VS Code, open the _debug pane_, and click on _create a launch.json file_. + +![Creating a launch configuration file](@site/static/img/debugger/ref1-create-launch.png) + +A `launch.json` file will be created, populated with basic defaults. + +### Noir Debugger launch.json properties + +#### projectFolder + +_String, optional._ + +Absolute path to the Nargo project to debug. By default, it is dynamically determined by looking for the nearest `Nargo.toml` file to the active file at the moment of launching the debugger. + +#### proverName + +_String, optional._ + +Name of the prover input to use. Defaults to `Prover`, which looks for a file named `Prover.toml` at the `projectFolder`. + +#### generateAcir + +_Boolean, optional._ + +If true, generate ACIR opcodes instead of unconstrained opcodes which will be closer to release binaries but less convenient for debugging. Defaults to `false`. + +#### skipInstrumentation + +_Boolean, optional._ + +Skips variables debugging instrumentation of code, making debugging less convenient but the resulting binary smaller and closer to production. Defaults to `false`. + +:::note +Skipping instrumentation causes the debugger to be unable to inspect local variables. +::: + +## `nargo dap [OPTIONS]` + +When run without any option flags, it starts the Nargo Debug Adapter Protocol server, which acts as the debugging backend for the VS Code Noir Debugger. + +All option flags are related to preflight checks. The Debug Adapter Protocol specifies how errors are to be informed from a running DAP server, but it doesn't specify mechanisms to communicate server initialization errors between the DAP server and its client IDE. + +Thus `nargo dap` ships with a _preflight check_ mode. If flag `--preflight-check` and the rest of the `--preflight-*` flags are provided, Nargo will run the same initialization routine except it will not start the DAP server. + +`vscode-noir` will then run `nargo dap` in preflight check mode first before a debugging session starts. If the preflight check ends in error, vscode-noir will present stderr and stdout output from this process through its own Output pane in VS Code. This makes it possible for users to diagnose what pieces of configuration might be wrong or missing in case of initialization errors. + +If the preflight check succeeds, `vscode-noir` proceeds to start the DAP server normally but running `nargo dap` without any additional flags. + +### Options + +| Option | Description | +| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `--preflight-check` | If present, dap runs in preflight check mode. | +| `--preflight-project-folder ` | Absolute path to the project to debug for preflight check. | +| `--preflight-prover-name ` | Name of prover file to use for preflight check | +| `--preflight-generate-acir` | Optional. If present, compile in ACIR mode while running preflight check. | +| `--preflight-skip-instrumentation` | Optional. If present, compile without introducing debug instrumentation while running preflight check. | +| `-h, --help` | Print help. | diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/nargo_commands.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/nargo_commands.md new file mode 100644 index 000000000000..8842fad66474 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/nargo_commands.md @@ -0,0 +1,474 @@ +--- +title: Nargo +description: + Noir CLI Commands for Noir Prover and Verifier to create, execute, prove and verify programs, + generate Solidity verifier smart contract and compile into JSON file containing ACIR + representation and ABI of circuit. +keywords: + [ + Nargo, + Noir CLI, + Noir Prover, + Noir Verifier, + generate Solidity verifier, + compile JSON file, + ACIR representation, + ABI of circuit, + TypeScript, + ] +sidebar_position: 0 +--- + +# Command-Line Help for `nargo` + +This document contains the help content for the `nargo` command-line program. + +**Command Overview:** + +* [`nargo`↴](#nargo) +* [`nargo check`↴](#nargo-check) +* [`nargo fmt`↴](#nargo-fmt) +* [`nargo compile`↴](#nargo-compile) +* [`nargo new`↴](#nargo-new) +* [`nargo init`↴](#nargo-init) +* [`nargo execute`↴](#nargo-execute) +* [`nargo debug`↴](#nargo-debug) +* [`nargo test`↴](#nargo-test) +* [`nargo info`↴](#nargo-info) +* [`nargo lsp`↴](#nargo-lsp) +* [`nargo generate-completion-script`↴](#nargo-generate-completion-script) + +## `nargo` + +Noir's package manager + +**Usage:** `nargo ` + +###### **Subcommands:** + +* `check` — Checks the constraint system for errors +* `fmt` — Format the Noir files in a workspace +* `compile` — Compile the program and its secret execution trace into ACIR format +* `new` — Create a Noir project in a new directory +* `init` — Create a Noir project in the current directory +* `execute` — Executes a circuit to calculate its return value +* `debug` — Executes a circuit in debug mode +* `test` — Run the tests for this program +* `info` — Provides detailed information on each of a program's function (represented by a single circuit) +* `lsp` — Starts the Noir LSP server +* `generate-completion-script` — Generates a shell completion script for your favorite shell + +###### **Options:** + + + + +## `nargo check` + +Checks the constraint system for errors + +**Usage:** `nargo check [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to check +* `--workspace` — Check all packages in the workspace + + Possible values: `true`, `false` + +* `--overwrite` — Force overwrite of existing files + + Possible values: `true`, `false` + +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + + + + +## `nargo fmt` + +Format the Noir files in a workspace + +**Usage:** `nargo fmt [OPTIONS]` + +###### **Options:** + +* `--check` — Run noirfmt in check mode + + Possible values: `true`, `false` + + + + +## `nargo compile` + +Compile the program and its secret execution trace into ACIR format + +**Usage:** `nargo compile [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to compile +* `--workspace` — Compile all packages in the workspace + + Possible values: `true`, `false` + +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + + + + +## `nargo new` + +Create a Noir project in a new directory + +**Usage:** `nargo new [OPTIONS] ` + +###### **Arguments:** + +* `` — The path to save the new project + +###### **Options:** + +* `--name ` — Name of the package [default: package directory name] +* `--lib` — Use a library template + + Possible values: `true`, `false` + +* `--bin` — Use a binary template [default] + + Possible values: `true`, `false` + +* `--contract` — Use a contract template + + Possible values: `true`, `false` + + + + +## `nargo init` + +Create a Noir project in the current directory + +**Usage:** `nargo init [OPTIONS]` + +###### **Options:** + +* `--name ` — Name of the package [default: current directory name] +* `--lib` — Use a library template + + Possible values: `true`, `false` + +* `--bin` — Use a binary template [default] + + Possible values: `true`, `false` + +* `--contract` — Use a contract template + + Possible values: `true`, `false` + + + + +## `nargo execute` + +Executes a circuit to calculate its return value + +**Usage:** `nargo execute [OPTIONS] [WITNESS_NAME]` + +###### **Arguments:** + +* `` — Write the execution witness to named file + +Defaults to the name of the package being executed. + +###### **Options:** + +* `-p`, `--prover-name ` — The name of the toml file which contains the inputs for the prover + + Default value: `Prover` +* `--package ` — The name of the package to execute +* `--workspace` — Execute all packages in the workspace + + Possible values: `true`, `false` + +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + +* `--oracle-resolver ` — JSON RPC url to solve oracle calls + + + +## `nargo debug` + +Executes a circuit in debug mode + +**Usage:** `nargo debug [OPTIONS] [WITNESS_NAME]` + +###### **Arguments:** + +* `` — Write the execution witness to named file + +###### **Options:** + +* `-p`, `--prover-name ` — The name of the toml file which contains the inputs for the prover + + Default value: `Prover` +* `--package ` — The name of the package to execute +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + +* `--acir-mode` — Force ACIR output (disabling instrumentation) + + Possible values: `true`, `false` + +* `--skip-instrumentation ` — Disable vars debug instrumentation (enabled by default) + + Possible values: `true`, `false` + + + + +## `nargo test` + +Run the tests for this program + +**Usage:** `nargo test [OPTIONS] [TEST_NAME]` + +###### **Arguments:** + +* `` — If given, only tests with names containing this string will be run + +###### **Options:** + +* `--show-output` — Display output of `println` statements + + Possible values: `true`, `false` + +* `--exact` — Only run tests that match exactly + + Possible values: `true`, `false` + +* `--package ` — The name of the package to test +* `--workspace` — Test all packages in the workspace + + Possible values: `true`, `false` + +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + +* `--oracle-resolver ` — JSON RPC url to solve oracle calls + + + +## `nargo info` + +Provides detailed information on each of a program's function (represented by a single circuit) + +Current information provided per circuit: 1. The number of ACIR opcodes 2. Counts the final number gates in the circuit used by a backend + +**Usage:** `nargo info [OPTIONS]` + +###### **Options:** + +* `--package ` — The name of the package to detail +* `--workspace` — Detail all packages in the workspace + + Possible values: `true`, `false` + +* `--profile-execution` + + Possible values: `true`, `false` + +* `-p`, `--prover-name ` — The name of the toml file which contains the inputs for the prover + + Default value: `Prover` +* `--expression-width ` — Specify the backend expression width that should be targeted +* `--bounded-codegen` — Generate ACIR with the target backend expression width. The default is to generate ACIR without a bound and split expressions after code generation. Activating this flag can sometimes provide optimizations for certain programs + + Default value: `false` + + Possible values: `true`, `false` + +* `--force` — Force a full recompilation + + Possible values: `true`, `false` + +* `--print-acir` — Display the ACIR for compiled circuit + + Possible values: `true`, `false` + +* `--deny-warnings` — Treat all warnings as errors + + Possible values: `true`, `false` + +* `--silence-warnings` — Suppress warnings + + Possible values: `true`, `false` + +* `--debug-comptime-in-file ` — Enable printing results of comptime evaluation: provide a path suffix for the module to debug, e.g. "package_name/src/main.nr" +* `--skip-underconstrained-check` — Flag to turn off the compiler check for under constrained values. Warning: This can improve compilation speed but can also lead to correctness errors. This check should always be run on production code + + Possible values: `true`, `false` + + + + +## `nargo lsp` + +Starts the Noir LSP server + +Starts an LSP server which allows IDEs such as VS Code to display diagnostics in Noir source. + +VS Code Noir Language Support: https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir + +**Usage:** `nargo lsp` + + + +## `nargo generate-completion-script` + +Generates a shell completion script for your favorite shell + +**Usage:** `nargo generate-completion-script ` + +###### **Arguments:** + +* `` — The shell to generate completions for. One of: bash, elvish, fish, powershell, zsh + + + +
+ + + This document was generated automatically by + clap-markdown. + + diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/noir_codegen.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/noir_codegen.md new file mode 100644 index 000000000000..e4c362f96100 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/reference/noir_codegen.md @@ -0,0 +1,116 @@ +--- +title: Noir Codegen for TypeScript +description: Learn how to use Noir codegen to generate TypeScript bindings +keywords: [Nargo, Noir, compile, TypeScript] +sidebar_position: 3 +--- + +When using TypeScript, it is extra work to interpret Noir program outputs in a type-safe way. Third party libraries may exist for popular Noir programs, but they are either hard to find or unmaintained. + +Now you can generate TypeScript bindings for your Noir programs in two steps: + +1. Exporting Noir functions using `nargo export` +2. Using the TypeScript module `noir_codegen` to generate TypeScript binding + +**Note:** you can only export functions from a Noir *library* (not binary or contract program types). + +## Installation + +### Your TypeScript project + +If you don't already have a TypeScript project you can add the module with `yarn` (or `npm`), then initialize it: + +```bash +yarn add typescript -D +npx tsc --init +``` + +### Add TypeScript module - `noir_codegen` + +The following command will add the module to your project's devDependencies: + +```bash +yarn add @noir-lang/noir_codegen -D +``` + +### Nargo library + +Make sure you have Nargo, v0.25.0 or greater, installed. If you don't, follow the [installation guide](../getting_started/noir_installation.md). + +If you're in a new project, make a `circuits` folder and create a new Noir library: + +```bash +mkdir circuits && cd circuits +nargo new --lib myNoirLib +``` + +## Usage + +### Export ABI of specified functions + +First go to the `.nr` files in your Noir library, and add the `#[export]` macro to each function that you want to use in TypeScript. + +```rust +#[export] +fn your_function(... +``` + +From your Noir library (where `Nargo.toml` is), run the following command: + +```bash +nargo export +``` + +You will now have an `export` directory with a .json file per exported function. + +You can also specify the directory of Noir programs using `--program-dir`, for example: + +```bash +nargo export --program-dir=./circuits/myNoirLib +``` + +### Generate TypeScript bindings from exported functions + +To use the `noir-codegen` package we added to the TypeScript project: + +```bash +yarn noir-codegen ./export/your_function.json +``` + +This creates an `exports` directory with an `index.ts` file containing all exported functions. + +**Note:** adding `--out-dir` allows you to specify an output dir for your TypeScript bindings to go. Eg: + +```bash +yarn noir-codegen ./export/*.json --out-dir ./path/to/output/dir +``` + +## Example .nr function to .ts output + +Consider a Noir library with this function: + +```rust +#[export] +fn not_equal(x: Field, y: Field) -> bool { + x != y +} +``` + +After the export and codegen steps, you should have an `index.ts` like: + +```typescript +export type Field = string; + + +export const is_equal_circuit: CompiledCircuit = +{"abi":{"parameters":[{"name":"x","type":{"kind":"field"},"visibility":"private"},{"name":"y","type":{"kind":"field"},"visibility":"private"}],"return_type":{"abi_type":{"kind":"boolean"},"visibility":"private"}},"bytecode":"H4sIAAAAAAAA/7WUMQ7DIAxFQ0Krrr2JjSGYLVcpKrn/CaqqDQN12WK+hPBgmWd/wEyHbF1SS923uhOs3pfoChI+wKXMAXzIKyNj4PB0TFTYc0w5RUjoqeAeEu1wqK0F54RGkWvW44LPzExnlkbMEs4JNZmN8PxS42uHv82T8a3Jeyn2Ks+VLPcO558HmyLMCDOXAXXtpPt4R/Rt9T36ss6dS9HGPx/eG17nGegKBQAA"}; + +export async function is_equal(x: Field, y: Field, foreignCallHandler?: ForeignCallHandler): Promise { + const program = new Noir(is_equal_circuit); + const args: InputMap = { x, y }; + const { returnValue } = await program.execute(args, foreignCallHandler); + return returnValue as boolean; +} +``` + +Now the `is_equal()` function and relevant types are readily available for use in TypeScript. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/debugger.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/debugger.md new file mode 100644 index 000000000000..200b5fc423ac --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/debugger.md @@ -0,0 +1,26 @@ +--- +title: Debugger +description: Learn about the Noir Debugger, in its REPL or VS Code versions. +keywords: [Nargo, VSCode, Visual Studio Code, REPL, Debugger] +sidebar_position: 2 +--- + +# Noir Debugger + +There are currently two ways of debugging Noir programs: + +1. From VS Code, via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). +2. Via the REPL debugger, which ships with Nargo. + +In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/noir_installation.md) and vscode-noir: + +- Noir & Nargo ≥0.28.0 +- Noir's VS Code extension ≥0.0.11 + +:::info +At the moment, the debugger supports debugging binary projects, but not contracts. +::: + +We cover the VS Code Noir debugger more in depth in [its VS Code debugger how-to guide](../how_to/debugger/debugging_with_vs_code.md) and [the reference](../reference/debugger/debugger_vscode.md). + +The REPL debugger is discussed at length in [the REPL debugger how-to guide](../how_to/debugger/debugging_with_the_repl.md) and [the reference](../reference/debugger/debugger_repl.md). diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/language_server.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/language_server.md new file mode 100644 index 000000000000..81e0356ef8a1 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/language_server.md @@ -0,0 +1,43 @@ +--- +title: Language Server +description: Learn about the Noir Language Server, how to install the components, and configuration that may be required. +keywords: [Nargo, Language Server, LSP, VSCode, Visual Studio Code] +sidebar_position: 0 +--- + +This section helps you install and configure the Noir Language Server. + +The Language Server Protocol (LSP) has two components, the [Server](#language-server) and the [Client](#language-client). Below we describe each in the context of Noir. + +## Language Server + +The Server component is provided by the Nargo command line tool that you installed at the beginning of this guide. +As long as Nargo is installed and you've used it to run other commands in this guide, it should be good to go! + +If you'd like to verify that the `nargo lsp` command is available, you can run `nargo --help` and look for `lsp` in the list of commands. If you see it, you're using a version of Noir with LSP support. + +## Language Client + +The Client component is usually an editor plugin that launches the Server. It communicates LSP messages between the editor and the Server. For example, when you save a file, the Client will alert the Server, so it can try to compile the project and report any errors. + +Currently, Noir provides a Language Client for Visual Studio Code via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). + +> **Note:** Noir's Language Server Protocol support currently assumes users' VSCode workspace root to be the same as users' Noir project root (i.e. where Nargo.toml lies). +> +> If LSP features seem to be missing / malfunctioning, make sure you are opening your Noir project directly (instead of as a sub-folder) in your VSCode instance. + +When your language server is running correctly and the VSCode plugin is installed, you should see handy codelens buttons for compilation, measuring circuit size, execution, and tests: + +![Compile and Execute](@site/static/img/codelens_compile_execute.png) +![Run test](@site/static/img/codelens_run_test.png) + +You should also see your tests in the `testing` panel: + +![Testing panel](@site/static/img/codelens_testing_panel.png) + +### Configuration + +- **Noir: Enable LSP** - If checked, the extension will launch the Language Server via `nargo lsp` and communicate with it. +- **Noir: Nargo Flags** - Additional flags may be specified if you require them to be added when the extension calls `nargo lsp`. +- **Noir: Nargo Path** - An absolute path to a Nargo binary with the `lsp` command. This may be useful if Nargo is not within the `PATH` of your editor. +- **Noir > Trace: Server** - Setting this to `"messages"` or `"verbose"` will log LSP messages between the Client and Server. Useful for debugging. diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/testing.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/testing.md new file mode 100644 index 000000000000..866677da5679 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tooling/testing.md @@ -0,0 +1,79 @@ +--- +title: Testing in Noir +description: Learn how to use Nargo to test your Noir program in a quick and easy way +keywords: [Nargo, testing, Noir, compile, test] +sidebar_position: 1 +--- + +You can test your Noir programs using Noir circuits. + +Nargo will automatically compile and run any functions which have the decorator `#[test]` on them if +you run `nargo test`. + +For example if you have a program like: + +```rust +fn add(x: u64, y: u64) -> u64 { + x + y +} +#[test] +fn test_add() { + assert(add(2,2) == 4); + assert(add(0,1) == 1); + assert(add(1,0) == 1); +} +``` + +Running `nargo test` will test that the `test_add` function can be executed while satisfying all +the constraints which allows you to test that add returns the expected values. Test functions can't +have any arguments currently. + +### Test fail + +You can write tests that are expected to fail by using the decorator `#[test(should_fail)]`. For example: + +```rust +fn add(x: u64, y: u64) -> u64 { + x + y +} +#[test(should_fail)] +fn test_add() { + assert(add(2,2) == 5); +} +``` + +You can be more specific and make it fail with a specific reason by using `should_fail_with = ""`: + +```rust +fn main(african_swallow_avg_speed : Field) { + assert(african_swallow_avg_speed == 65, "What is the airspeed velocity of an unladen swallow"); +} + +#[test] +fn test_king_arthur() { + main(65); +} + +#[test(should_fail_with = "What is the airspeed velocity of an unladen swallow")] +fn test_bridgekeeper() { + main(32); +} +``` + +The string given to `should_fail_with` doesn't need to exactly match the failure reason, it just needs to be a substring of it: + +```rust +fn main(african_swallow_avg_speed : Field) { + assert(african_swallow_avg_speed == 65, "What is the airspeed velocity of an unladen swallow"); +} + +#[test] +fn test_king_arthur() { + main(65); +} + +#[test(should_fail_with = "airspeed velocity")] +fn test_bridgekeeper() { + main(32); +} +``` \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tutorials/noirjs_app.md b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tutorials/noirjs_app.md new file mode 100644 index 000000000000..6e69ea0bbedf --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.38.0/tutorials/noirjs_app.md @@ -0,0 +1,366 @@ +--- +title: Building a web app with NoirJS +description: Learn how to setup a new app that uses Noir to generate and verify zero-knowledge SNARK proofs in a typescript or javascript environment. +keywords: [how to, guide, javascript, typescript, noir, barretenberg, zero-knowledge, proofs, app] +sidebar_position: 0 +pagination_next: noir/concepts/data_types/index +--- + +NoirJS is a set of packages meant to work both in a browser and a server environment. In this tutorial, we will build a simple web app using them. From here, you should get an idea on how to proceed with your own Noir projects! + +You can find the complete app code for this guide [here](https://github.com/noir-lang/tiny-noirjs-app). + +## Setup + +:::note + +Feel free to use whatever versions, just keep in mind that Nargo and the NoirJS packages are meant to be in sync. For example, Nargo 0.31.x matches `noir_js@0.31.x`, etc. + +In this guide, we will be pinned to 0.31.0. + +::: + +Before we start, we want to make sure we have Node, Nargo and the Barretenberg proving system (`bb`) installed. + +We start by opening a terminal and executing `node --version`. If we don't get an output like `v20.10.0`, that means node is not installed. Let's do that by following the handy [nvm guide](https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script). + +As for `Nargo`, we can follow the [Nargo guide](../getting_started/quick_start.md) to install it. If you're lazy, just paste this on a terminal and run `noirup`: + +```sh +curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash +``` + +Follow the instructions on [this page](https://github.com/AztecProtocol/aztec-packages/tree/master/barretenberg/cpp/src/barretenberg/bb#installation) to install `bb`. +Version 0.41.0 is compatible with `nargo` version 0.31.0, which you can install with `bbup -v 0.41.0` once `bbup` is installed. + +Easy enough. Onwards! + +## Our project + +ZK is a powerful technology. An app that doesn't reveal one of the inputs to _anyone_ is almost unbelievable, yet Noir makes it as easy as a single line of code. + +In fact, it's so simple that it comes nicely packaged in `nargo`. Let's do that! + +### Nargo + +Run: + +```bash +nargo new circuit +``` + +And... That's about it. Your program is ready to be compiled and run. + +To compile, let's `cd` into the `circuit` folder to enter our project, and call: + +```bash +nargo compile +``` + +This compiles our circuit into `json` format and add it to a new `target` folder. + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit <---- our working directory + ├── Nargo.toml + ├── src + │ └── main.nr + └── target + └── circuit.json +``` + +::: + +### Node and Vite + +If you want to explore Nargo, feel free to go on a side-quest now and follow the steps in the +[getting started](../getting_started/quick_start.md) guide. However, we want our app to run on the browser, so we need Vite. + +Vite is a powerful tool to generate static websites. While it provides all kinds of features, let's just go barebones with some good old vanilla JS. + +To do this this, go back to the previous folder (`cd ..`) and create a new vite project by running `npm create vite` and choosing "Vanilla" and "Javascript". + +A wild `vite-project` directory should now appear in your root folder! Let's not waste any time and dive right in: + +```bash +cd vite-project +``` + +### Setting Up Vite and Configuring the Project + +Before we proceed with any coding, let's get our environment tailored for Noir. We'll start by laying down the foundations with a `vite.config.js` file. This little piece of configuration is our secret sauce for making sure everything meshes well with the NoirJS libraries and other special setups we might need, like handling WebAssembly modules. Here’s how you get that going: + +#### Creating the vite.config.js + +In your freshly minted `vite-project` folder, create a new file named `vite.config.js` and open it in your code editor. Paste the following to set the stage: + +```javascript +import { defineConfig } from 'vite'; +import copy from 'rollup-plugin-copy'; +import fs from 'fs'; +import path from 'path'; + +const wasmContentTypePlugin = { + name: 'wasm-content-type-plugin', + configureServer(server) { + server.middlewares.use(async (req, res, next) => { + if (req.url.endsWith('.wasm')) { + res.setHeader('Content-Type', 'application/wasm'); + const newPath = req.url.replace('deps', 'dist'); + const targetPath = path.join(__dirname, newPath); + const wasmContent = fs.readFileSync(targetPath); + return res.end(wasmContent); + } + next(); + }); + }, +}; + +export default defineConfig(({ command }) => { + if (command === 'serve') { + return { + build: { + target: 'esnext', + rollupOptions: { + external: ['@aztec/bb.js'] + } + }, + optimizeDeps: { + esbuildOptions: { + target: 'esnext' + } + }, + plugins: [ + copy({ + targets: [{ src: 'node_modules/**/*.wasm', dest: 'node_modules/.vite/dist' }], + copySync: true, + hook: 'buildStart', + }), + command === 'serve' ? wasmContentTypePlugin : [], + ], + }; + } + + return {}; +}); +``` + +#### Install Dependencies + +Now that our stage is set, install the necessary NoirJS packages along with our other dependencies: + +```bash +npm install && npm install @noir-lang/backend_barretenberg@0.31.0 @noir-lang/noir_js@0.31.0 +npm install rollup-plugin-copy --save-dev +``` + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit + └── ...etc... +└── vite-project <---- our working directory + └── ...etc... +``` + +::: + +#### Some cleanup + +`npx create vite` is amazing but it creates a bunch of files we don't really need for our simple example. Actually, let's just delete everything except for `vite.config.js`, `index.html`, `main.js` and `package.json`. I feel lighter already. + +![my heart is ready for you, noir.js](@site/static/img/memes/titanic.jpeg) + +## HTML + +Our app won't run like this, of course. We need some working HTML, at least. Let's open our broken-hearted `index.html` and replace everything with this code snippet: + +```html + + + + + + +

Noir app

+
+ + +
+
+

Logs

+

Proof

+
+ + +``` + +It _could_ be a beautiful UI... Depending on which universe you live in. + +## Some good old vanilla Javascript + +Our love for Noir needs undivided attention, so let's just open `main.js` and delete everything (this is where the romantic scenery becomes a bit creepy). + +Start by pasting in this boilerplate code: + +```js +function display(container, msg) { + const c = document.getElementById(container); + const p = document.createElement('p'); + p.textContent = msg; + c.appendChild(p); +} + +document.getElementById('submitGuess').addEventListener('click', async () => { + try { + // here's where love happens + } catch (err) { + display('logs', 'Oh 💔 Wrong guess'); + } +}); +``` + +The display function doesn't do much. We're simply manipulating our website to see stuff happening. For example, if the proof fails, it will simply log a broken heart 😢 + +:::info + +At this point in the tutorial, your folder structure should look like this: + +```tree +. +└── circuit + └── ...same as above +└── vite-project + ├── vite.config.js + ├── main.js + ├── package.json + └── index.html +``` + +You'll see other files and folders showing up (like `package-lock.json`, `node_modules`) but you shouldn't have to care about those. + +::: + +## Some NoirJS + +We're starting with the good stuff now. If you've compiled the circuit as described above, you should have a `json` file we want to import at the very top of our `main.js` file: + +```ts +import circuit from '../circuit/target/circuit.json'; +``` + +[Noir is backend-agnostic](../index.mdx#whats-new-about-noir). We write Noir, but we also need a proving backend. That's why we need to import and instantiate the two dependencies we installed above: `BarretenbergBackend` and `Noir`. Let's import them right below: + +```js +import { BarretenbergBackend, BarretenbergVerifier as Verifier } from '@noir-lang/backend_barretenberg'; +import { Noir } from '@noir-lang/noir_js'; +``` + +And instantiate them inside our try-catch block: + +```ts +// try { +const backend = new BarretenbergBackend(circuit); +const noir = new Noir(circuit); +// } +``` + +:::note + +For the remainder of the tutorial, everything will be happening inside the `try` block + +::: + +## Our app + +Now for the app itself. We're capturing whatever is in the input when people press the submit button. Just add this: + +```js +const x = parseInt(document.getElementById('guessInput').value); +const input = { x, y: 2 }; +``` + +Now we're ready to prove stuff! Let's feed some inputs to our circuit and calculate the proof: + +```js +await setup(); // let's squeeze our wasm inits here + +display('logs', 'Generating proof... ⌛'); +const { witness } = await noir.execute(input); +const proof = await backend.generateProof(witness); +display('logs', 'Generating proof... ✅'); +display('results', proof.proof); +``` + +You're probably eager to see stuff happening, so go and run your app now! + +From your terminal, run `npm run dev`. If it doesn't open a browser for you, just visit `localhost:5173`. You should now see the worst UI ever, with an ugly input. + +![Getting Started 0](@site/static/img/noir_getting_started_1.png) + +Now, our circuit says `fn main(x: Field, y: pub Field)`. This means only the `y` value is public, and it's hardcoded above: `input = { x, y: 2 }`. In other words, you won't need to send your secret`x` to the verifier! + +By inputting any number other than 2 in the input box and clicking "submit", you should get a valid proof. Otherwise the proof won't even generate correctly. By the way, if you're human, you shouldn't be able to understand anything on the "proof" box. That's OK. We like you, human ❤️. + +## Verifying + +Time to celebrate, yes! But we shouldn't trust machines so blindly. Let's add these lines to see our proof being verified: + +```js +display('logs', 'Verifying proof... ⌛'); +const isValid = await backend.verifyProof(proof); + +// or to cache and use the verification key: +// const verificationKey = await backend.getVerificationKey(); +// const verifier = new Verifier(); +// const isValid = await verifier.verifyProof(proof, verificationKey); + +if (isValid) display('logs', 'Verifying proof... ✅'); +``` + +You have successfully generated a client-side Noir web app! + +![coded app without math knowledge](@site/static/img/memes/flextape.jpeg) + +## Further Reading + +You can see how noirjs is used in a full stack Next.js hardhat application in the [noir-starter repo here](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat). The example shows how to calculate a proof in the browser and verify it with a deployed Solidity verifier contract from noirjs. + +You should also check out the more advanced examples in the [noir-examples repo](https://github.com/noir-lang/noir-examples), where you'll find reference usage for some cool apps. + +## UltraHonk Backend + +Barretenberg has recently exposed a new UltraHonk backend. We can use UltraHonk in NoirJS after version 0.33.0. Everything will be the same as the tutorial above, except that the class we need to import will change: + +```js +import { UltraHonkBackend, UltraHonkVerifier as Verifier } from '@noir-lang/backend_barretenberg'; +``` + +The backend will then be instantiated as such: + +```js +const backend = new UltraHonkBackend(circuit); +``` + +Then all the commands to prove and verify your circuit will be same. + +The only feature currently unsupported with UltraHonk are [recursive proofs](../explainers/explainer-recursion.md). diff --git a/noir/noir-repo/docs/versioned_sidebars/version-v0.38.0-sidebars.json b/noir/noir-repo/docs/versioned_sidebars/version-v0.38.0-sidebars.json new file mode 100644 index 000000000000..b9ad026f69ff --- /dev/null +++ b/noir/noir-repo/docs/versioned_sidebars/version-v0.38.0-sidebars.json @@ -0,0 +1,93 @@ +{ + "sidebar": [ + { + "type": "doc", + "id": "index" + }, + { + "type": "category", + "label": "Getting Started", + "items": [ + { + "type": "autogenerated", + "dirName": "getting_started" + } + ] + }, + { + "type": "category", + "label": "The Noir Language", + "items": [ + { + "type": "autogenerated", + "dirName": "noir" + } + ] + }, + { + "type": "html", + "value": "
", + "defaultStyle": true + }, + { + "type": "category", + "label": "How To Guides", + "items": [ + { + "type": "autogenerated", + "dirName": "how_to" + } + ] + }, + { + "type": "category", + "label": "Explainers", + "items": [ + { + "type": "autogenerated", + "dirName": "explainers" + } + ] + }, + { + "type": "category", + "label": "Tutorials", + "items": [ + { + "type": "autogenerated", + "dirName": "tutorials" + } + ] + }, + { + "type": "category", + "label": "Reference", + "items": [ + { + "type": "autogenerated", + "dirName": "reference" + } + ] + }, + { + "type": "category", + "label": "Tooling", + "items": [ + { + "type": "autogenerated", + "dirName": "tooling" + } + ] + }, + { + "type": "html", + "value": "
", + "defaultStyle": true + }, + { + "type": "doc", + "id": "migration_notes", + "label": "Migration notes" + } + ] +} diff --git a/noir/noir-repo/examples/codegen_verifier/codegen_verifier.sh b/noir/noir-repo/examples/codegen_verifier/codegen_verifier.sh index fabd6235a67c..f224f74168ff 100755 --- a/noir/noir-repo/examples/codegen_verifier/codegen_verifier.sh +++ b/noir/noir-repo/examples/codegen_verifier/codegen_verifier.sh @@ -16,11 +16,17 @@ nargo execute witness PROOF_PATH=./target/proof $BACKEND prove -b ./target/hello_world.json -w ./target/witness.gz -o $PROOF_PATH -NUM_PUBLIC_INPUTS=1 +# Sanity check that proof is valid. +$BACKEND verify -k ./target/vk -p ./target/proof + +NUM_PUBLIC_INPUTS=2 PUBLIC_INPUT_BYTES=$((32 * $NUM_PUBLIC_INPUTS)) HEX_PUBLIC_INPUTS=$(head -c $PUBLIC_INPUT_BYTES $PROOF_PATH | od -An -v -t x1 | tr -d $' \n') HEX_PROOF=$(tail -c +$(($PUBLIC_INPUT_BYTES + 1)) $PROOF_PATH | od -An -v -t x1 | tr -d $' \n') +# Split public inputs into strings where each string represents a `bytes32`. +SPLIT_HEX_PUBLIC_INPUTS=$(sed -e 's/.\{64\}/0x&,/g' <<< $HEX_PUBLIC_INPUTS) + # Spin up an anvil node to deploy the contract to anvil & @@ -31,8 +37,7 @@ DEPLOY_INFO=$(forge create UltraVerifier \ VERIFIER_ADDRESS=$(echo $DEPLOY_INFO | jq -r '.deployedTo') # Call the verifier contract with our proof. -# Note that we haven't needed to split up `HEX_PUBLIC_INPUTS` as there's only a single public input -cast call $VERIFIER_ADDRESS "verify(bytes, bytes32[])(bool)" "0x$HEX_PROOF" "[0x$HEX_PUBLIC_INPUTS]" +cast call $VERIFIER_ADDRESS "verify(bytes, bytes32[])(bool)" "0x$HEX_PROOF" "[$SPLIT_HEX_PUBLIC_INPUTS]" # Stop anvil node again -kill %- \ No newline at end of file +kill %- diff --git a/noir/noir-repo/examples/codegen_verifier/src/main.nr b/noir/noir-repo/examples/codegen_verifier/src/main.nr index baef0c3786aa..935317977442 100644 --- a/noir/noir-repo/examples/codegen_verifier/src/main.nr +++ b/noir/noir-repo/examples/codegen_verifier/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: pub Field, y: pub Field) { assert(x != y); -} \ No newline at end of file +} diff --git a/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr b/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr index 8512413c831a..08f017c4f91c 100644 --- a/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr +++ b/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr @@ -27,7 +27,7 @@ pub mod affine { impl Point { // Point constructor - #[deprecated = "It's recommmended to use the external noir-edwards library (https://github.com/noir-lang/noir-edwards)"] + //#[deprecated = "It's recommmended to use the external noir-edwards library (https://github.com/noir-lang/noir-edwards)"] pub fn new(x: Field, y: Field) -> Self { Self { x, y } } diff --git a/noir/noir-repo/test_programs/compile_success_empty/attribute_args/src/main.nr b/noir/noir-repo/test_programs/compile_success_empty/attribute_args/src/main.nr index 492afd9e2f19..5fc193150dbe 100644 --- a/noir/noir-repo/test_programs/compile_success_empty/attribute_args/src/main.nr +++ b/noir/noir-repo/test_programs/compile_success_empty/attribute_args/src/main.nr @@ -1,6 +1,6 @@ #[attr_with_args(1, 2)] -#[varargs(1, 2)] -#[varargs(1, 2, 3, 4)] +#[attr_with_varargs(1, 2)] +#[attr_with_varargs(1, 2, 3, 4)] pub struct Foo {} comptime fn attr_with_args(s: StructDefinition, a: Field, b: Field) { @@ -12,8 +12,8 @@ comptime fn attr_with_args(s: StructDefinition, a: Field, b: Field) { } #[varargs] -comptime fn varargs(s: StructDefinition, t: [Field]) { - let _ = s; +comptime fn attr_with_varargs(s: StructDefinition, t: [Field]) { + let _: StructDefinition = s; for _ in t {} assert(t.len() < 5); } diff --git a/noir/noir-repo/test_programs/execution_success/bit_shifts_comptime/src/main.nr b/noir/noir-repo/test_programs/execution_success/bit_shifts_comptime/src/main.nr index 6d9736b6abbf..a11dae1c716b 100644 --- a/noir/noir-repo/test_programs/execution_success/bit_shifts_comptime/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/bit_shifts_comptime/src/main.nr @@ -15,6 +15,10 @@ fn main(x: u64) { assert(x << 63 == 0); assert_eq((1 as u64) << 32, 0x0100000000); + + //regression for 6201 + let a: i16 = -769; + assert_eq(a >> 3, -97); } fn regression_2250() { diff --git a/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/Prover.toml b/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/Prover.toml index 67bf6a6a2347..7b56d36c9d5a 100644 --- a/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/Prover.toml +++ b/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/Prover.toml @@ -1,2 +1,3 @@ x = 64 y = 1 +z = "-769" diff --git a/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/src/main.nr b/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/src/main.nr index 059bbe84daca..370bb699048a 100644 --- a/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/bit_shifts_runtime/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: u64, y: u8) { +fn main(x: u64, y: u8, z: i16) { // runtime shifts on compile-time known values assert(64 << y == 128); assert(64 >> y == 32); @@ -17,4 +17,6 @@ fn main(x: u64, y: u8) { assert(a << y == -2); assert(x >> (x as u8) == 0); + + assert_eq(z >> 3, -97); } diff --git a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr index 48e1e4af9fb0..d4c3664f0c92 100644 --- a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr @@ -2,7 +2,6 @@ use std::compat; use std::ec::consts::te::baby_jubjub; use std::ec::tecurve::affine::Point as TEPoint; use std::eddsa::{eddsa_poseidon_verify, eddsa_to_pub, eddsa_verify}; -use std::hash; use std::hash::poseidon2::Poseidon2Hasher; fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { diff --git a/noir/noir-repo/test_programs/execution_success/references/src/main.nr b/noir/noir-repo/test_programs/execution_success/references/src/main.nr index 4ddbf8aa1e3d..65d70dc4a5fc 100644 --- a/noir/noir-repo/test_programs/execution_success/references/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/references/src/main.nr @@ -1,7 +1,6 @@ fn main(mut x: Field) { add1(&mut x); assert(x == 3); - let mut s = S { y: x }; s.add2(); assert(s.y == 5); @@ -21,18 +20,16 @@ fn main(mut x: Field) { let mut c = C { foo: 0, bar: &mut C2 { array: &mut [1, 2] } }; *c.bar.array = [3, 4]; assert(*c.bar.array == [3, 4]); - regression_1887(); regression_2054(); regression_2030(); regression_2255(); - + regression_6443(); assert(x == 3); regression_2218_if_inner_if(x, 10); regression_2218_if_inner_else(20, x); regression_2218_else(x, 3); regression_2218_loop(x, 10); - regression_2560(s_ref); } @@ -106,6 +103,7 @@ fn regression_2030() { let _ = *array[0]; *array[0] = 1; } + // The `mut x: &mut ...` caught a bug handling lvalues where a double-dereference would occur internally // in one step rather than being tracked by two separate steps. This lead to assigning the 1 value to the // incorrect outer `mut` reference rather than the correct `&mut` reference. @@ -119,6 +117,18 @@ fn regression_2255_helper(mut x: &mut Field) { *x = 1; } +// Similar to `regression_2255` but without the double-dereferencing. +// The test checks that `mem2reg` does not eliminate storing to a reference passed as a parameter. +fn regression_6443() { + let x = &mut 0; + regression_6443_helper(x); + assert(*x == 1); +} + +fn regression_6443_helper(x: &mut Field) { + *x = 1; +} + fn regression_2218(x: Field, y: Field) -> Field { let q = &mut &mut 0; let q1 = *q; diff --git a/noir/noir-repo/test_programs/execution_success/regression_6451/Nargo.toml b/noir/noir-repo/test_programs/execution_success/regression_6451/Nargo.toml new file mode 100644 index 000000000000..e109747c7f61 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_6451/Nargo.toml @@ -0,0 +1,5 @@ +[package] +name = "regression_6451" +type = "bin" +authors = [""] +[dependencies] diff --git a/noir/noir-repo/test_programs/execution_success/regression_6451/Prover.toml b/noir/noir-repo/test_programs/execution_success/regression_6451/Prover.toml new file mode 100644 index 000000000000..74213d097ec6 --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_6451/Prover.toml @@ -0,0 +1 @@ +x = 0 \ No newline at end of file diff --git a/noir/noir-repo/test_programs/execution_success/regression_6451/src/main.nr b/noir/noir-repo/test_programs/execution_success/regression_6451/src/main.nr new file mode 100644 index 000000000000..fbee6956dfab --- /dev/null +++ b/noir/noir-repo/test_programs/execution_success/regression_6451/src/main.nr @@ -0,0 +1,23 @@ +fn main(x: Field) { + // Regression test for #6451 + let y = unsafe { empty(x) }; + let mut value = 0; + let term1 = x * x - x * y; + std::as_witness(term1); + value += term1; + let term2 = x * x - y * x; + value += term2; + value.assert_max_bit_size::<1>(); + + // Regression test for Aztec Packages issue #6451 + let y = unsafe { empty(x + 1) }; + let z = y + x + 1; + let z1 = z + y; + assert(z + z1 != 3); + let w = y + 2 * x + 3; + assert(w + z1 != z); +} + +unconstrained fn empty(_: Field) -> Field { + 0 +} diff --git a/noir/noir-repo/tooling/lsp/src/attribute_reference_finder.rs b/noir/noir-repo/tooling/lsp/src/attribute_reference_finder.rs index 660ee8ffdfba..e3f31b65b463 100644 --- a/noir/noir-repo/tooling/lsp/src/attribute_reference_finder.rs +++ b/noir/noir-repo/tooling/lsp/src/attribute_reference_finder.rs @@ -13,24 +13,22 @@ use noirc_frontend::{ graph::CrateId, hir::{ def_map::{CrateDefMap, LocalModuleId, ModuleId}, - resolution::{ - import::PathResolutionItem, - path_resolver::{PathResolver, StandardPathResolver}, - }, + resolution::import::resolve_import, }, - node_interner::{NodeInterner, ReferenceId}, - parser::{ParsedSubModule, Parser}, - token::CustomAttribute, + node_interner::ReferenceId, + parser::ParsedSubModule, + token::MetaAttribute, usage_tracker::UsageTracker, ParsedModule, }; +use crate::modules::module_def_id_to_reference_id; + pub(crate) struct AttributeReferenceFinder<'a> { byte_index: usize, /// The module ID in scope. This might change as we traverse the AST /// if we are analyzing something inside an inline module declaration. module_id: ModuleId, - interner: &'a NodeInterner, def_maps: &'a BTreeMap, reference_id: Option, } @@ -41,7 +39,6 @@ impl<'a> AttributeReferenceFinder<'a> { file: FileId, byte_index: usize, krate: CrateId, - interner: &'a NodeInterner, def_maps: &'a BTreeMap, ) -> Self { // Find the module the current file belongs to @@ -54,7 +51,7 @@ impl<'a> AttributeReferenceFinder<'a> { def_map.root() }; let module_id = ModuleId { krate, local_id }; - Self { byte_index, module_id, interner, def_maps, reference_id: None } + Self { byte_index, module_id, def_maps, reference_id: None } } pub(crate) fn find(&mut self, parsed_module: &ParsedModule) -> Option { @@ -88,42 +85,31 @@ impl<'a> Visitor for AttributeReferenceFinder<'a> { false } - fn visit_custom_attribute(&mut self, attribute: &CustomAttribute, _target: AttributeTarget) { - if !self.includes_span(attribute.contents_span) { - return; + fn visit_meta_attribute( + &mut self, + attribute: &MetaAttribute, + _target: AttributeTarget, + ) -> bool { + if !self.includes_span(attribute.span) { + return false; } - let name = match attribute.contents.split_once('(') { - Some((left, _right)) => left.to_string(), - None => attribute.contents.to_string(), - }; - let mut parser = Parser::for_str(&name); - let Some(path) = parser.parse_path_no_turbofish() else { - return; - }; - - let resolver = StandardPathResolver::new(self.module_id, None); - let mut usage_tracker = UsageTracker::default(); - let Ok(result) = - resolver.resolve(self.interner, self.def_maps, path, &mut usage_tracker, &mut None) - else { - return; + let path = attribute.name.clone(); + // The path here must resolve to a function and it's a simple path (can't have turbofish) + // so it can (and must) be solved as an import. + let Ok(Some((module_def_id, _, _))) = resolve_import( + path, + self.module_id, + self.def_maps, + &mut UsageTracker::default(), + None, // references tracker + ) + .map(|result| result.namespace.values) else { + return true; }; - self.reference_id = Some(path_resolution_item_to_reference_id(result.item)); - } -} + self.reference_id = Some(module_def_id_to_reference_id(module_def_id)); -fn path_resolution_item_to_reference_id(item: PathResolutionItem) -> ReferenceId { - match item { - PathResolutionItem::Module(module_id) => ReferenceId::Module(module_id), - PathResolutionItem::Struct(struct_id) => ReferenceId::Struct(struct_id), - PathResolutionItem::TypeAlias(type_alias_id) => ReferenceId::Alias(type_alias_id), - PathResolutionItem::Trait(trait_id) => ReferenceId::Trait(trait_id), - PathResolutionItem::Global(global_id) => ReferenceId::Global(global_id), - PathResolutionItem::ModuleFunction(func_id) - | PathResolutionItem::StructFunction(_, _, func_id) - | PathResolutionItem::TypeAliasFunction(_, _, func_id) - | PathResolutionItem::TraitFunction(_, _, func_id) => ReferenceId::Function(func_id), + true } } diff --git a/noir/noir-repo/tooling/lsp/src/requests/completion.rs b/noir/noir-repo/tooling/lsp/src/requests/completion.rs index 2dd42c740cde..d71f0414adcb 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/completion.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/completion.rs @@ -26,20 +26,21 @@ use noirc_frontend::{ graph::{CrateId, Dependency}, hir::{ def_map::{CrateDefMap, LocalModuleId, ModuleDefId, ModuleId}, - resolution::visibility::{method_call_is_visible, struct_member_is_visible}, + resolution::visibility::{ + item_in_module_is_visible, method_call_is_visible, struct_member_is_visible, + }, }, hir_def::traits::Trait, node_interner::{NodeInterner, ReferenceId, StructId}, parser::{Item, ItemKind, ParsedSubModule}, - token::{CustomAttribute, Token, Tokens}, + token::{MetaAttribute, Token, Tokens}, Kind, ParsedModule, StructType, Type, TypeBinding, }; use sort_text::underscore_sort_text; use crate::{ requests::to_lsp_location, trait_impl_method_stub_generator::TraitImplMethodStubGenerator, - use_segment_positions::UseSegmentPositions, utils, visibility::item_in_module_is_visible, - LspState, + use_segment_positions::UseSegmentPositions, utils, LspState, }; use super::process_request; @@ -583,6 +584,14 @@ impl<'a> NodeFinder<'a> { self_prefix, ); } + Type::CheckedCast { to, .. } => { + return self.complete_type_fields_and_methods( + to, + prefix, + function_completion_kind, + self_prefix, + ); + } Type::Tuple(types) => { self.complete_tuple_fields(types, self_prefix); } @@ -799,10 +808,10 @@ impl<'a> NodeFinder<'a> { let per_ns = module_data.find_name(ident); if let Some((module_def_id, visibility, _)) = per_ns.types { if item_in_module_is_visible( - module_id, + self.def_maps, self.module_id, + module_id, visibility, - self.def_maps, ) { let completion_items = self.module_def_id_completion_items( module_def_id, @@ -820,10 +829,10 @@ impl<'a> NodeFinder<'a> { if let Some((module_def_id, visibility, _)) = per_ns.values { if item_in_module_is_visible( - module_id, + self.def_maps, self.module_id, + module_id, visibility, - self.def_maps, ) { let completion_items = self.module_def_id_completion_items( module_def_id, @@ -892,24 +901,6 @@ impl<'a> NodeFinder<'a> { None } - fn suggest_attributes(&mut self, prefix: &str, target: AttributeTarget) { - self.suggest_builtin_attributes(prefix, target); - - let function_completion_kind = FunctionCompletionKind::NameAndParameters; - let requested_items = RequestedItems::OnlyAttributeFunctions(target); - - self.complete_in_module( - self.module_id, - prefix, - PathKind::Plain, - true, - function_completion_kind, - requested_items, - ); - - self.complete_auto_imports(prefix, requested_items, function_completion_kind); - } - fn suggest_no_arguments_attributes(&mut self, prefix: &str, attributes: &[&str]) { for name in attributes { if name_matches(name, prefix) { @@ -1666,12 +1657,14 @@ impl<'a> Visitor for NodeFinder<'a> { false } - fn visit_custom_attribute(&mut self, attribute: &CustomAttribute, target: AttributeTarget) { - if self.byte_index != attribute.contents_span.end() as usize { - return; + fn visit_meta_attribute(&mut self, attribute: &MetaAttribute, target: AttributeTarget) -> bool { + if self.byte_index == attribute.name.span.end() as usize { + self.suggest_builtin_attributes(&attribute.name.to_string(), target); } - self.suggest_attributes(&attribute.contents, target); + self.find_in_path(&attribute.name, RequestedItems::OnlyAttributeFunctions(target)); + + true } fn visit_quote(&mut self, tokens: &Tokens) { diff --git a/noir/noir-repo/tooling/lsp/src/requests/completion/builtins.rs b/noir/noir-repo/tooling/lsp/src/requests/completion/builtins.rs index c2c561ced32f..b4c7d8b6e011 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/completion/builtins.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/completion/builtins.rs @@ -107,6 +107,15 @@ impl<'a> NodeFinder<'a> { let one_argument_attributes = &["abi", "field", "foreign", "oracle"]; self.suggest_one_argument_attributes(prefix, one_argument_attributes); + if name_matches("deprecated", prefix) { + self.completion_items.push(snippet_completion_item( + "deprecated(\"...\")", + CompletionItemKind::METHOD, + "deprecated(\"${1:message}\")", + None, + )); + } + if name_matches("test", prefix) || name_matches("should_fail", prefix) { self.completion_items.push(snippet_completion_item( "test(should_fail)", diff --git a/noir/noir-repo/tooling/lsp/src/requests/completion/tests.rs b/noir/noir-repo/tooling/lsp/src/requests/completion/tests.rs index 745dacfc1528..8cfb2a4b5ee1 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/completion/tests.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/completion/tests.rs @@ -2350,13 +2350,13 @@ fn main() { #[test] async fn test_suggests_built_in_function_attribute() { let src = r#" - #[dep>|<] + #[no_pred>|<] fn foo() {} "#; assert_completion_excluding_auto_import( src, - vec![simple_completion_item("deprecated", CompletionItemKind::METHOD, None)], + vec![simple_completion_item("no_predicates", CompletionItemKind::METHOD, None)], ) .await; } diff --git a/noir/noir-repo/tooling/lsp/src/requests/goto_definition.rs b/noir/noir-repo/tooling/lsp/src/requests/goto_definition.rs index 9380209da5c9..a2443ea165dc 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/goto_definition.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/goto_definition.rs @@ -46,7 +46,6 @@ fn on_goto_definition_inner( file_id, byte_index, args.crate_id, - args.interner, args.def_maps, ); finder.find(&parsed_module) diff --git a/noir/noir-repo/tooling/lsp/src/requests/hover.rs b/noir/noir-repo/tooling/lsp/src/requests/hover.rs index eb066b53b78d..bb1ea661719e 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/hover.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/hover.rs @@ -47,7 +47,6 @@ pub(crate) fn on_hover_request( file_id, byte_index, args.crate_id, - args.interner, args.def_maps, ); finder.find(&parsed_module) @@ -680,6 +679,7 @@ impl<'a> TypeLinksGatherer<'a> { self.gather_type_links(lhs); self.gather_type_links(rhs); } + Type::CheckedCast { to, .. } => self.gather_type_links(to), Type::FieldElement | Type::Integer(..) | Type::Bool diff --git a/noir/noir-repo/tooling/lsp/src/requests/inlay_hint.rs b/noir/noir-repo/tooling/lsp/src/requests/inlay_hint.rs index f7b3e6a748db..c6415acb5454 100644 --- a/noir/noir-repo/tooling/lsp/src/requests/inlay_hint.rs +++ b/noir/noir-repo/tooling/lsp/src/requests/inlay_hint.rs @@ -471,6 +471,7 @@ fn push_type_parts(typ: &Type, parts: &mut Vec, files: &File push_type_variable_parts(binding, parts, files); } } + Type::CheckedCast { to, .. } => push_type_parts(to, parts, files), Type::FieldElement | Type::Integer(..) diff --git a/noir/noir-repo/tooling/lsp/src/trait_impl_method_stub_generator.rs b/noir/noir-repo/tooling/lsp/src/trait_impl_method_stub_generator.rs index b433ee2ec885..2ae0d526f3e9 100644 --- a/noir/noir-repo/tooling/lsp/src/trait_impl_method_stub_generator.rs +++ b/noir/noir-repo/tooling/lsp/src/trait_impl_method_stub_generator.rs @@ -368,6 +368,7 @@ impl<'a> TraitImplMethodStubGenerator<'a> { self.string.push(' '); self.append_type(right); } + Type::CheckedCast { to, .. } => self.append_type(to), Type::Constant(..) | Type::Integer(_, _) | Type::Bool diff --git a/noir/noir-repo/tooling/lsp/src/visibility.rs b/noir/noir-repo/tooling/lsp/src/visibility.rs index 6a21525f069a..6724a0ba5052 100644 --- a/noir/noir-repo/tooling/lsp/src/visibility.rs +++ b/noir/noir-repo/tooling/lsp/src/visibility.rs @@ -5,36 +5,13 @@ use noirc_frontend::{ graph::CrateId, hir::{ def_map::{CrateDefMap, ModuleDefId, ModuleId}, - resolution::visibility::can_reference_module_id, + resolution::visibility::item_in_module_is_visible, }, node_interner::NodeInterner, }; use crate::modules::get_parent_module; -/// Returns true if an item with the given visibility in the target module -/// is visible from the current module. For example: -/// -/// mod foo { -/// ^^^ <-- target module -/// pub(crate) fn bar() {} -/// ^^^^^^^^^^ <- visibility -/// } -pub(super) fn item_in_module_is_visible( - target_module_id: ModuleId, - current_module_id: ModuleId, - visibility: ItemVisibility, - def_maps: &BTreeMap, -) -> bool { - can_reference_module_id( - def_maps, - current_module_id.krate, - current_module_id.local_id, - target_module_id, - visibility, - ) -} - /// Returns true if the given ModuleDefId is visible from the current module, given its visibility. /// This will in turn check if the ModuleDefId parent modules are visible from the current module. /// If `defining_module` is Some, it will be considered as the parent of the item to check @@ -57,7 +34,7 @@ pub(super) fn module_def_id_is_visible( // Then check if it's visible, and upwards while let Some(module_id) = target_module_id { - if !item_in_module_is_visible(module_id, current_module_id, visibility, def_maps) { + if !item_in_module_is_visible(def_maps, current_module_id, module_id, visibility) { return false; } diff --git a/noir/noir-repo/tooling/nargo_cli/Cargo.toml b/noir/noir-repo/tooling/nargo_cli/Cargo.toml index 4e45749ddafa..317706bb2376 100644 --- a/noir/noir-repo/tooling/nargo_cli/Cargo.toml +++ b/noir/noir-repo/tooling/nargo_cli/Cargo.toml @@ -88,6 +88,7 @@ sha3.workspace = true iai = "0.1.1" test-binary = "3.0.2" test-case.workspace = true +lazy_static.workspace = true light-poseidon = "0.2.0" diff --git a/noir/noir-repo/tooling/nargo_cli/build.rs b/noir/noir-repo/tooling/nargo_cli/build.rs index 94f74a061498..438eef687b83 100644 --- a/noir/noir-repo/tooling/nargo_cli/build.rs +++ b/noir/noir-repo/tooling/nargo_cli/build.rs @@ -130,7 +130,7 @@ fn generate_execution_success_tests(test_file: &mut File, test_data_dir: &Path) &test_dir, r#" nargo.arg("execute").arg("--force"); - + nargo.assert().success();"#, ); @@ -141,7 +141,7 @@ fn generate_execution_success_tests(test_file: &mut File, test_data_dir: &Path) &test_dir, r#" nargo.arg("execute").arg("--force").arg("--force-brillig"); - + nargo.assert().success();"#, ); } @@ -169,7 +169,7 @@ fn generate_execution_failure_tests(test_file: &mut File, test_data_dir: &Path) &test_dir, r#" nargo.arg("execute").arg("--force"); - + nargo.assert().failure().stderr(predicate::str::contains("The application panicked (crashed).").not());"#, ); } @@ -196,7 +196,7 @@ fn generate_noir_test_success_tests(test_file: &mut File, test_data_dir: &Path) &test_dir, r#" nargo.arg("test"); - + nargo.assert().success();"#, ); } @@ -222,7 +222,7 @@ fn generate_noir_test_failure_tests(test_file: &mut File, test_data_dir: &Path) &test_dir, r#" nargo.arg("test"); - + nargo.assert().failure();"#, ); } @@ -273,7 +273,7 @@ fn generate_compile_success_empty_tests(test_file: &mut File, test_data_dir: &Pa &format!( r#" nargo.arg("info").arg("--json").arg("--force"); - + {assert_zero_opcodes}"#, ), ); @@ -353,7 +353,7 @@ fn generate_compile_failure_tests(test_file: &mut File, test_data_dir: &Path) { &test_name, &test_dir, r#"nargo.arg("compile").arg("--force"); - + nargo.assert().failure().stderr(predicate::str::contains("The application panicked (crashed).").not());"#, ); } diff --git a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs index df3a4370cb06..304988ed5162 100644 --- a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -192,7 +192,7 @@ fn compile_programs( let target_width = get_target_width(package.expression_width, compile_options.expression_width); let program = nargo::ops::transform_program(program, target_width); - // nargo::ops::check_program(&program)?; + nargo::ops::check_program(&program)?; save_program_to_file(&program.into(), &package.name, workspace.target_directory_path()); Ok(((), warnings)) diff --git a/noir/noir-repo/tooling/nargo_fmt/src/chunks.rs b/noir/noir-repo/tooling/nargo_fmt/src/chunks.rs index 0e55dfad3b73..fcef261284df 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/chunks.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/chunks.rs @@ -915,11 +915,18 @@ impl<'a> Formatter<'a> { self.write_indentation(); } Chunk::LeadingComment(text_chunk) => { - let ends_with_newline = text_chunk.string.ends_with('\n'); + let ends_with_multiple_newlines = text_chunk.string.ends_with("\n\n"); + let ends_with_newline = + ends_with_multiple_newlines || text_chunk.string.ends_with('\n'); self.write_chunk_lines(text_chunk.string.trim()); // Respect whether the leading comment had a newline before what comes next or not - if ends_with_newline { + if ends_with_multiple_newlines { + // Remove any indentation that could exist (we'll add it later) + self.buffer.trim_spaces(); + self.write_multiple_lines_without_skipping_whitespace_and_comments(); + self.write_indentation(); + } else if ends_with_newline { self.write_line_without_skipping_whitespace_and_comments(); self.write_indentation(); } else { diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs index 4ae5443a2cc9..9a9386e1911c 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs @@ -188,8 +188,7 @@ impl<'a> Formatter<'a> { pub(crate) fn write_token(&mut self, token: Token) { self.skip_comments_and_whitespace(); if self.token == token { - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); } else { panic!("Expected token {:?}, got: {:?}", token, self.token); } @@ -200,6 +199,12 @@ impl<'a> Formatter<'a> { self.write(&self.token.to_string()); } + /// Writes the current token and advances to the next one + pub(crate) fn write_current_token_and_bump(&mut self) { + self.write(&self.token.to_string()); + self.bump(); + } + /// Writes the current token trimming its end but doesn't advance to the next one. /// Mainly used when writing comment lines, because we never want trailing spaces /// inside comments. diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/attribute.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/attribute.rs index c13ba2a8c4ca..19d5730a546c 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/attribute.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/attribute.rs @@ -1,30 +1,342 @@ -use noirc_frontend::token::Token; +use noirc_frontend::token::{ + Attribute, Attributes, FunctionAttribute, MetaAttribute, SecondaryAttribute, TestScope, Token, +}; + +use crate::chunks::ChunkGroup; use super::Formatter; impl<'a> Formatter<'a> { - pub(super) fn format_attributes(&mut self) { - loop { - self.skip_comments_and_whitespace(); + pub(super) fn format_attributes(&mut self, attributes: Attributes) { + let mut all_attributes = Vec::new(); + for attribute in attributes.secondary { + all_attributes.push(Attribute::Secondary(attribute)); + } + if let Some((function_attribute, index)) = attributes.function { + all_attributes.insert(index, Attribute::Function(function_attribute)); + } + for attribute in all_attributes { + self.format_attribute(attribute); + } + } - if let Token::Attribute(_) = self.token { - self.write_indentation(); - self.write_current_token(); - self.bump(); - self.write_line(); - } else { - break; + pub(super) fn format_secondary_attributes(&mut self, attributes: Vec) { + for attribute in attributes { + self.format_secondary_attribute(attribute); + } + } + + fn format_attribute(&mut self, attribute: Attribute) { + match attribute { + Attribute::Function(function_attribute) => { + self.format_function_attribute(function_attribute); + } + Attribute::Secondary(secondary_attribute) => { + self.format_secondary_attribute(secondary_attribute); } } } - pub(super) fn format_inner_attribute(&mut self) { + fn format_function_attribute(&mut self, attribute: FunctionAttribute) { self.skip_comments_and_whitespace(); - let Token::InnerAttribute(..) = self.token else { - panic!("Expected inner attribute, got {:?}", self.token); - }; self.write_indentation(); - self.write_current_token(); - self.bump(); + + if !matches!(self.token, Token::AttributeStart { .. }) { + panic!("Expected attribute start, got: {:?}", self.token); + } + + match attribute { + FunctionAttribute::Foreign(_) + | FunctionAttribute::Builtin(_) + | FunctionAttribute::Oracle(_) => self.format_one_arg_attribute(), + FunctionAttribute::Test(test_scope) => self.format_test_attribute(test_scope), + FunctionAttribute::Fold + | FunctionAttribute::NoPredicates + | FunctionAttribute::InlineAlways => self.format_no_args_attribute(), + } + + self.write_line(); + } + + pub(super) fn format_secondary_attribute(&mut self, attribute: SecondaryAttribute) { + self.skip_comments_and_whitespace(); + self.write_indentation(); + + if !matches!(self.token, Token::AttributeStart { .. }) { + panic!("Expected attribute start, got: {:?}", self.token); + } + + match attribute { + SecondaryAttribute::Deprecated(message) => { + self.format_deprecated_attribute(message); + } + SecondaryAttribute::ContractLibraryMethod + | SecondaryAttribute::Export + | SecondaryAttribute::Varargs + | SecondaryAttribute::UseCallersScope => { + self.format_no_args_attribute(); + } + SecondaryAttribute::Field(_) + | SecondaryAttribute::Abi(_) + | SecondaryAttribute::Allow(_) => { + self.format_one_arg_attribute(); + } + SecondaryAttribute::Tag(custom_attribute) => { + self.write_and_skip_span_without_formatting(custom_attribute.span); + } + SecondaryAttribute::Meta(meta_attribute) => { + self.format_meta_attribute(meta_attribute); + } + } + + self.write_line(); + } + + fn format_deprecated_attribute(&mut self, message: Option) { + self.write_current_token_and_bump(); // #[ + self.skip_comments_and_whitespace(); + if message.is_some() { + self.write_current_token_and_bump(); // deprecated + self.write_left_paren(); // ( + self.skip_comments_and_whitespace(); // message + self.write_current_token_and_bump(); // ) + self.write_right_paren(); + } else { + self.write_current_token_and_bump(); + } + self.write_right_bracket(); // ] + } + + fn format_test_attribute(&mut self, test_scope: TestScope) { + self.write_current_token_and_bump(); // #[ + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // test + + match test_scope { + TestScope::None => (), + TestScope::ShouldFailWith { reason: None } => { + self.write_left_paren(); // ( + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // should_fail + self.write_right_paren(); // ) + } + TestScope::ShouldFailWith { reason: Some(..) } => { + self.write_left_paren(); // ( + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // should_fail_with + self.write_space(); + self.write_token(Token::Assign); + self.write_space(); + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // "reason" + self.write_right_paren(); // ) + } + } + + self.write_right_bracket(); // ] + } + + fn format_meta_attribute(&mut self, meta_attribute: MetaAttribute) { + self.write_current_token_and_bump(); // #[ + self.skip_comments_and_whitespace(); + self.format_path(meta_attribute.name); + self.skip_comments_and_whitespace(); + if self.is_at(Token::LeftParen) { + let comments_count_before_arguments = self.written_comments_count; + let has_arguments = !meta_attribute.arguments.is_empty(); + + let mut chunk_formatter = self.chunk_formatter(); + let mut group = ChunkGroup::new(); + group.text(chunk_formatter.chunk(|formatter| { + formatter.write_left_paren(); + })); + chunk_formatter.format_expressions_separated_by_comma( + meta_attribute.arguments, + false, // force trailing comma + &mut group, + ); + group.text(chunk_formatter.chunk(|formatter| { + formatter.write_right_paren(); + })); + if has_arguments || self.written_comments_count > comments_count_before_arguments { + self.format_chunk_group(group); + } + } + self.write_right_bracket(); + } + + fn format_no_args_attribute(&mut self) { + self.write_current_token_and_bump(); // #[ + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // name + self.write_right_bracket(); // ] + } + + fn format_one_arg_attribute(&mut self) { + self.write_current_token_and_bump(); // #[ + self.skip_comments_and_whitespace(); + self.write_current_token_and_bump(); // name + self.write_left_paren(); // ( + loop { + self.skip_comments_and_whitespace(); + if self.is_at(Token::RightParen) { + self.write_right_paren(); + break; + } else { + self.write_current_token_and_bump(); + } + } + self.write_right_bracket(); // ] + } +} + +#[cfg(test)] +mod tests { + use crate::assert_format; + + fn assert_format_attribute(src: &str, expected: &str) { + let src = format!(" {src} fn foo() {{}}"); + let expected = format!("{expected}\nfn foo() {{}}\n"); + assert_format(&src, &expected); + } + + #[test] + fn format_inner_tag_attribute() { + let src = " #!['foo] "; + let expected = "#!['foo]\n"; + assert_format(src, expected); + } + + #[test] + fn format_deprecated_attribute() { + let src = " #[ deprecated ] "; + let expected = "#[deprecated]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_deprecated_attribute_with_message() { + let src = " #[ deprecated ( \"use something else\" ) ] "; + let expected = "#[deprecated(\"use something else\")]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_contract_library_method() { + let src = " #[ contract_library_method ] "; + let expected = "#[contract_library_method]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_export() { + let src = " #[ export ] "; + let expected = "#[export]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_varargs() { + let src = " #[ varargs ] "; + let expected = "#[varargs]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_use_callers_scope() { + let src = " #[ use_callers_scope ] "; + let expected = "#[use_callers_scope]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_field_attribute() { + let src = " #[ field ( bn256 ) ] "; + let expected = "#[field(bn256)]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_abi_attribute() { + let src = " #[ abi ( foo ) ] "; + let expected = "#[abi(foo)]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_allow_attribute() { + let src = " #[ allow ( unused_vars ) ] "; + let expected = "#[allow(unused_vars)]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_meta_attribute_without_arguments() { + let src = " #[ custom ] "; + let expected = "#[custom]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_meta_attribute_without_arguments_removes_parentheses() { + let src = " #[ custom ( ) ] "; + let expected = "#[custom]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_meta_attribute_without_arguments_but_comment() { + let src = " #[ custom ( /* nothing */ ) ] "; + let expected = "#[custom( /* nothing */ )]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_meta_attribute_with_arguments() { + let src = " #[ custom ( 1 , 2, [ 3, 4 ], ) ] "; + let expected = "#[custom(1, 2, [3, 4])]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_foreign_attribute() { + let src = " #[ foreign ( foo ) ] "; + let expected = "#[foreign(foo)]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_recursive_attribute() { + let src = " #[ recursive ] "; + let expected = "#[recursive]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_test_attribute() { + let src = " #[ test ] "; + let expected = "#[test]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_test_should_fail_attribute() { + let src = " #[ test ( should_fail )] "; + let expected = "#[test(should_fail)]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_test_should_fail_with_reason_attribute() { + let src = " #[ test ( should_fail_with=\"reason\" )] "; + let expected = "#[test(should_fail_with = \"reason\")]"; + assert_format_attribute(src, expected); + } + + #[test] + fn format_multiple_function_attributes() { + let src = " #[foo] #[test] #[bar] "; + let expected = "#[foo]\n#[test]\n#[bar]"; + assert_format_attribute(src, expected); } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/buffer.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/buffer.rs index e4740311bf63..3e4bebef6081 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/buffer.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/buffer.rs @@ -38,9 +38,10 @@ impl Buffer { } /// Trim spaces from the end of the buffer. - pub(super) fn trim_spaces(&mut self) { + pub(crate) fn trim_spaces(&mut self) { while self.buffer.ends_with(' ') { self.buffer.truncate(self.buffer.len() - 1); + self.current_line_width -= 1; } } @@ -48,6 +49,7 @@ impl Buffer { pub(super) fn trim_comma(&mut self) -> bool { if self.buffer.ends_with(',') { self.buffer.truncate(self.buffer.len() - 1); + self.current_line_width -= 1; true } else { false diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/comments_and_whitespace.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/comments_and_whitespace.rs index 547d33348b85..e20eb4291d18 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/comments_and_whitespace.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/comments_and_whitespace.rs @@ -162,8 +162,7 @@ impl<'a> Formatter<'a> { // will never write two consecutive spaces. self.write_space_without_skipping_whitespace_and_comments(); } - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); passed_whitespace = false; last_was_block_comment = true; self.written_comments_count += 1; diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs index bff1799a2983..0ac4c98bb955 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs @@ -1133,11 +1133,15 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { if count > 0 { // If newlines follow, we first add a line, then add the comment chunk group.lines(count > 1); - group.leading_comment(self.skip_comments_and_whitespace_chunk()); + group.leading_comment(self.chunk(|formatter| { + formatter.skip_comments_and_whitespace_writing_multiple_lines_if_found(); + })); ignore_next = self.ignore_next; } else { // Otherwise, add the comment first as it's a trailing comment - group.trailing_comment(self.skip_comments_and_whitespace_chunk()); + group.trailing_comment(self.chunk(|formatter| { + formatter.skip_comments_and_whitespace_writing_multiple_lines_if_found(); + })); ignore_next = self.ignore_next; group.line(); } @@ -1146,6 +1150,20 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { self.format_statement(statement, group, ignore_next); } + // See how many newlines follow the last statement + let count = self.following_newlines_count(); + + group.text(self.chunk(|formatter| { + formatter.skip_whitespace(); + })); + + // After skipping whitespace we check if there's a comment. If so, we respect + // how many lines were before that comment. + if count > 0 && matches!(self.token, Token::LineComment(..) | Token::BlockComment(..)) { + group.lines(count > 1); + } + + // Finally format the comment, if any group.text(self.chunk(|formatter| { formatter.skip_comments_and_whitespace(); })); diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/function.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/function.rs index 1dc9ead42e04..fd6977df6135 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/function.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/function.rs @@ -3,13 +3,14 @@ use noirc_frontend::{ BlockExpression, FunctionReturnType, Ident, ItemVisibility, NoirFunction, Param, UnresolvedGenerics, UnresolvedTraitConstraint, Visibility, }, - token::{Keyword, Token}, + token::{Attributes, Keyword, Token}, }; use super::Formatter; use crate::chunks::{ChunkGroup, TextChunk}; pub(super) struct FunctionToFormat { + pub(super) attributes: Attributes, pub(super) visibility: ItemVisibility, pub(super) name: Ident, pub(super) generics: UnresolvedGenerics, @@ -23,6 +24,7 @@ pub(super) struct FunctionToFormat { impl<'a> Formatter<'a> { pub(super) fn format_function(&mut self, func: NoirFunction) { self.format_function_impl(FunctionToFormat { + attributes: func.def.attributes, visibility: func.def.visibility, name: func.def.name, generics: func.def.generics, @@ -37,7 +39,7 @@ impl<'a> Formatter<'a> { pub(super) fn format_function_impl(&mut self, func: FunctionToFormat) { let has_where_clause = !func.where_clause.is_empty(); - self.format_attributes(); + self.format_attributes(func.attributes); self.write_indentation(); self.format_function_modifiers(func.visibility); self.write_keyword(Keyword::Fn); @@ -278,16 +280,12 @@ impl<'a> Formatter<'a> { } pub(super) fn format_function_body(&mut self, body: BlockExpression) { - if body.is_empty() { - self.format_empty_block_contents(); - } else { - let mut group = ChunkGroup::new(); - self.chunk_formatter().format_non_empty_block_expression_contents( - body, true, // force multiple lines - &mut group, - ); - self.format_chunk_group(group); - } + let mut group = ChunkGroup::new(); + self.chunk_formatter().format_block_expression_contents( + body, true, // force multiple newlines + &mut group, + ); + self.format_chunk_group(group); } } @@ -535,4 +533,46 @@ fn baz() { let z = 3 ; "; assert_format(src, expected); } + + #[test] + fn comment_in_body_respects_newlines() { + let src = "fn foo() { + let x = 1; + + // comment + + let y = 2; +} +"; + let expected = src; + assert_format(src, expected); + } + + #[test] + fn final_comment_in_body_respects_newlines() { + let src = "fn foo() { + let x = 1; + + let y = 2; + + // comment +} +"; + let expected = src; + assert_format(src, expected); + } + + #[test] + fn initial_comment_in_body_respects_newlines() { + let src = "fn foo() { + // comment + + let x = 1; + + let y = 2; +} +"; + let expected = src; + assert_format(src, expected); + } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs index 77f1cd10cbc2..521e476fe715 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs @@ -73,7 +73,7 @@ impl<'a> Formatter<'a> { ItemKind::Submodules(parsed_sub_module) => { self.format_submodule(parsed_sub_module); } - ItemKind::InnerAttribute(..) => self.format_inner_attribute(), + ItemKind::InnerAttribute(attribute) => self.format_secondary_attribute(attribute), } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/module.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/module.rs index 3df9b7e0c902..e07d22c75863 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/module.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/module.rs @@ -6,9 +6,7 @@ use super::Formatter; impl<'a> Formatter<'a> { pub(super) fn format_module_declaration(&mut self, module_declaration: ModuleDeclaration) { - if !module_declaration.outer_attributes.is_empty() { - self.format_attributes(); - } + self.format_secondary_attributes(module_declaration.outer_attributes); self.write_indentation(); self.format_item_visibility(module_declaration.visibility); self.write_keyword(Keyword::Mod); @@ -18,9 +16,7 @@ impl<'a> Formatter<'a> { } pub(super) fn format_submodule(&mut self, submodule: ParsedSubModule) { - if !submodule.outer_attributes.is_empty() { - self.format_attributes(); - } + self.format_secondary_attributes(submodule.outer_attributes); self.write_indentation(); self.format_item_visibility(submodule.visibility); if submodule.is_contract { diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs index 28107294909c..50c286ff1617 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs @@ -16,7 +16,15 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { group: &mut ChunkGroup, mut ignore_next: bool, ) { - group.leading_comment(self.skip_comments_and_whitespace_chunk()); + // First skip any whitespace to avoid writing multiple lines + group.text(self.chunk(|formatter| { + formatter.skip_whitespace(); + })); + + // Now write any leading comment respecting multiple newlines after them + group.leading_comment(self.chunk(|formatter| { + formatter.skip_comments_and_whitespace_writing_multiple_lines_if_found(); + })); ignore_next |= self.ignore_next; @@ -102,9 +110,7 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { let mut group = ChunkGroup::new(); group.text(self.chunk(|formatter| { - if !attributes.is_empty() { - formatter.format_attributes(); - } + formatter.format_secondary_attributes(attributes); formatter.write_keyword(keyword); formatter.write_space(); formatter.format_pattern(pattern); @@ -692,4 +698,16 @@ mod tests { "; assert_format_with_max_width(src, expected, " a_long_variable = foo(1, 2);".len() - 1); } + + #[test] + fn long_let_preceded_by_two_newlines() { + let src = "fn foo() { + let y = 0; + + let x = 123456; +} +"; + let expected = src; + assert_format_with_max_width(src, expected, " let x = 123456;".len()); + } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/structs.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/structs.rs index 54bfc88264d8..c26ab552f30c 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/structs.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/structs.rs @@ -8,9 +8,7 @@ use crate::chunks::ChunkGroup; impl<'a> Formatter<'a> { pub(super) fn format_struct(&mut self, noir_struct: NoirStruct) { - if !noir_struct.attributes.is_empty() { - self.format_attributes(); - } + self.format_secondary_attributes(noir_struct.attributes); self.write_indentation(); self.format_item_visibility(noir_struct.visibility); self.write_keyword(Keyword::Struct); diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/traits.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/traits.rs index 1379596b4836..9a6b84c6537d 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/traits.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/traits.rs @@ -1,15 +1,13 @@ use noirc_frontend::{ ast::{NoirTrait, Param, Pattern, TraitItem, Visibility}, - token::{Keyword, Token}, + token::{Attributes, Keyword, Token}, }; use super::{function::FunctionToFormat, Formatter}; impl<'a> Formatter<'a> { pub(super) fn format_trait(&mut self, noir_trait: NoirTrait) { - if !noir_trait.attributes.is_empty() { - self.format_attributes(); - } + self.format_secondary_attributes(noir_trait.attributes); self.write_indentation(); self.format_item_visibility(noir_trait.visibility); self.write_keyword(Keyword::Trait); @@ -91,6 +89,7 @@ impl<'a> Formatter<'a> { .collect(); let func = FunctionToFormat { + attributes: Attributes::empty(), visibility, name, generics, diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/type_expression.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/type_expression.rs index 87ba1430f106..95b0c0451566 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/type_expression.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/type_expression.rs @@ -14,14 +14,12 @@ impl<'a> Formatter<'a> { match type_expr { UnresolvedTypeExpression::Variable(path) => self.format_path(path), UnresolvedTypeExpression::Constant(..) => { - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); } UnresolvedTypeExpression::BinaryOperation(lhs, _operator, rhs, _span) => { self.format_type_expression(*lhs); self.write_space(); - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); self.write_space(); self.format_type_expression(*rhs); } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/types.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/types.rs index d2b5c4ab7932..e52704ddaa74 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/types.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/types.rs @@ -18,8 +18,7 @@ impl<'a> Formatter<'a> { self.write_keyword(Keyword::Bool); } UnresolvedTypeData::Integer(..) | UnresolvedTypeData::FieldElement => { - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); } UnresolvedTypeData::Array(type_expr, typ) => { self.write_left_bracket(); @@ -145,8 +144,7 @@ impl<'a> Formatter<'a> { } } UnresolvedTypeData::Quoted(..) => { - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); } UnresolvedTypeData::AsTraitPath(as_trait_path) => { self.format_as_trait_path(*as_trait_path); diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/visibility.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/visibility.rs index d1068aa4d051..27441b977bb2 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/visibility.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/visibility.rs @@ -37,8 +37,7 @@ impl<'a> Formatter<'a> { self.write_keyword(Keyword::CallData); self.write_left_paren(); self.skip_comments_and_whitespace(); - self.write_current_token(); - self.bump(); + self.write_current_token_and_bump(); self.skip_comments_and_whitespace(); self.write_right_paren(); self.write_space(); diff --git a/noir/noir-repo/tooling/nargo_fmt/tests/expected/parens.nr b/noir/noir-repo/tooling/nargo_fmt/tests/expected/parens.nr index 5ff0acf73307..2eaf3838ed6e 100644 --- a/noir/noir-repo/tooling/nargo_fmt/tests/expected/parens.nr +++ b/noir/noir-repo/tooling/nargo_fmt/tests/expected/parens.nr @@ -25,6 +25,7 @@ fn main(x: u64, y: pub u64) { ( /*a*/ + ( // test 1 diff --git a/noir/noir-repo/tooling/noir_codegen/package.json b/noir/noir-repo/tooling/noir_codegen/package.json index 24bc63685722..7ec8ba3df649 100644 --- a/noir/noir-repo/tooling/noir_codegen/package.json +++ b/noir/noir-repo/tooling/noir_codegen/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.37.0", + "version": "0.38.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/noir-repo/tooling/noir_js/package.json b/noir/noir-repo/tooling/noir_js/package.json index 1d3da4e7a544..a3e5777c3d33 100644 --- a/noir/noir-repo/tooling/noir_js/package.json +++ b/noir/noir-repo/tooling/noir_js/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.37.0", + "version": "0.38.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/noir-repo/tooling/noir_js_types/package.json b/noir/noir-repo/tooling/noir_js_types/package.json index 5192a6cd02dc..0eeb900253a3 100644 --- a/noir/noir-repo/tooling/noir_js_types/package.json +++ b/noir/noir-repo/tooling/noir_js_types/package.json @@ -4,7 +4,7 @@ "The Noir Team " ], "packageManager": "yarn@3.5.1", - "version": "0.37.0", + "version": "0.38.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/noir-repo/tooling/noirc_abi_wasm/package.json b/noir/noir-repo/tooling/noirc_abi_wasm/package.json index 7e4500ec29b7..ff121326d1a8 100644 --- a/noir/noir-repo/tooling/noirc_abi_wasm/package.json +++ b/noir/noir-repo/tooling/noirc_abi_wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.37.0", + "version": "0.38.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/spartan/terraform/eks-cluster/main.tf b/spartan/terraform/eks-cluster/main.tf index 09ef171443ff..5dc2fe235114 100644 --- a/spartan/terraform/eks-cluster/main.tf +++ b/spartan/terraform/eks-cluster/main.tf @@ -1,8 +1,8 @@ terraform { backend "s3" { - bucket = "aztec-terraform" - key = "spartan/terraform.tfstate" - region = "eu-west-2" + bucket = "aztec-terraform" + key = "spartan/terraform.tfstate" + region = "eu-west-2" } required_providers { @@ -26,6 +26,54 @@ data "aws_availability_zones" "available" { } } +# Create security group for node traffic +resource "aws_security_group" "node_traffic" { + name_prefix = "eks-node-traffic" + description = "Security group for EKS node UDP and TCP traffic" + vpc_id = module.vpc.vpc_id + + # Ingress UDP rule + ingress { + from_port = 40400 + to_port = 40499 + protocol = "udp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow incoming UDP traffic" + } + + # Ingress TCP rule + ingress { + from_port = 40400 + to_port = 40499 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow incoming TCP traffic" + } + + # Egress UDP rule + egress { + from_port = 40400 + to_port = 40499 + protocol = "udp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow outgoing UDP traffic" + } + + # Egress TCP rule + egress { + from_port = 40400 + to_port = 40499 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow outgoing TCP traffic" + } + + tags = { + Name = "${var.cluster_name}-node-traffic" + Project = var.cluster_name + } +} + module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "5.8.1" @@ -33,14 +81,14 @@ module "vpc" { name = var.cluster_name cidr = "10.1.0.0/16" - azs = slice(data.aws_availability_zones.available.names, 0, 3) - private_subnets = ["10.1.1.0/24", "10.1.2.0/24"] - public_subnets = ["10.1.3.0/24", "10.1.4.0/24"] + azs = slice(data.aws_availability_zones.available.names, 0, 3) + private_subnets = ["10.1.1.0/24", "10.1.2.0/24"] + public_subnets = ["10.1.3.0/24", "10.1.4.0/24"] enable_nat_gateway = true single_nat_gateway = true enable_dns_hostnames = true - enable_vpn_gateway = true + enable_vpn_gateway = true public_subnet_tags = { "kubernetes.io/role/elb" = 1 @@ -51,7 +99,7 @@ module "vpc" { } tags = { - Project = var.cluster_name + Project = var.cluster_name } } @@ -83,17 +131,17 @@ module "eks" { eks_managed_node_groups = { default = { - name = "node-group-1" + name = "node-group-1" instance_types = ["m6a.2xlarge"] min_size = 1 - max_size = 2 - desired_size = 1 + max_size = 10 + desired_size = 10 } } tags = { - Project = var.cluster_name + Project = var.cluster_name } } diff --git a/spartan/terraform/gke-cluster/main.tf b/spartan/terraform/gke-cluster/main.tf new file mode 100644 index 000000000000..46c1a51dc6c2 --- /dev/null +++ b/spartan/terraform/gke-cluster/main.tf @@ -0,0 +1,173 @@ +terraform { + backend "s3" { + bucket = "aztec-terraform" + key = "spartan-gke-cluster/terraform.tfstate" + region = "eu-west-2" + } + required_providers { + google = { + source = "hashicorp/google" + version = "~> 5.0" + } + } +} + +# Configure the Google Cloud provider +provider "google" { + project = var.project + region = var.region +} + +# Create the service account +resource "google_service_account" "gke_sa" { + account_id = "gke-nodes-sa" + display_name = "GKE Nodes Service Account" + description = "Service account for GKE nodes" +} + +# Add IAM roles to the service account +resource "google_project_iam_member" "gke_sa_roles" { + for_each = toset([ + "roles/logging.logWriter", + "roles/monitoring.metricWriter", + "roles/monitoring.viewer", + "roles/artifactregistry.reader" + ]) + + project = var.project + role = each.key + member = "serviceAccount:${google_service_account.gke_sa.email}" +} + +# Create ingress firewall rule for UDP +resource "google_compute_firewall" "udp_ingress" { + name = "allow-udp-ingress-40400-40499" + network = "default" + + allow { + protocol = "udp" + ports = ["40400-40499"] + } + + direction = "INGRESS" + source_ranges = ["0.0.0.0/0"] + target_tags = ["gke-node"] +} + +# Create egress firewall rule for UDP +resource "google_compute_firewall" "udp_egress" { + name = "allow-udp-egress-40400-40499" + network = "default" + + allow { + protocol = "udp" + ports = ["40400-40499"] + } + + direction = "EGRESS" + destination_ranges = ["0.0.0.0/0"] + target_tags = ["gke-node"] +} + +# Create a GKE cluster +resource "google_container_cluster" "primary" { + name = "spartan-gke" + location = var.zone + initial_node_count = 1 + + # Remove default node pool after cluster creation + remove_default_node_pool = true + + # Kubernetes version + min_master_version = "latest" + + # Network configuration + network = "default" + subnetwork = "default" + + # Master auth configuration + master_auth { + client_certificate_config { + issue_client_certificate = false + } + } +} + +# Create primary node pool with autoscaling +resource "google_container_node_pool" "primary_nodes" { + name = "primary-node-pool" + location = var.zone + cluster = google_container_cluster.primary.name + + # Enable autoscaling + autoscaling { + min_node_count = 1 + max_node_count = 5 + } + + # Node configuration + node_config { + machine_type = "t2d-standard-16" + + service_account = google_service_account.gke_sa.email + oauth_scopes = [ + "https://www.googleapis.com/auth/cloud-platform" + ] + + labels = { + env = "production" + } + + tags = ["gke-node"] + } + + # Management configuration + management { + auto_repair = true + auto_upgrade = true + } +} + +# Create spot instance node pool with autoscaling +resource "google_container_node_pool" "spot_nodes" { + name = "spot-node-pool" + location = var.zone + cluster = google_container_cluster.primary.name + + # Enable autoscaling + autoscaling { + min_node_count = 0 + max_node_count = 10 + } + + # Node configuration + node_config { + machine_type = "t2d-standard-16" + spot = true + + service_account = google_service_account.gke_sa.email + oauth_scopes = [ + "https://www.googleapis.com/auth/cloud-platform" + ] + + labels = { + env = "production" + pool = "spot" + } + + tags = ["gke-node", "spot"] + + # Spot instance termination handler + taint { + key = "cloud.google.com/gke-spot" + value = "true" + effect = "NO_SCHEDULE" + } + } + + # Management configuration + management { + auto_repair = true + auto_upgrade = true + } +} diff --git a/spartan/terraform/gke-cluster/outputs.tf b/spartan/terraform/gke-cluster/outputs.tf new file mode 100644 index 000000000000..befaa28092e9 --- /dev/null +++ b/spartan/terraform/gke-cluster/outputs.tf @@ -0,0 +1,17 @@ +output "cluster_endpoint" { + value = google_container_cluster.primary.endpoint +} + +output "service_account_email" { + value = google_service_account.gke_sa.email +} + +output "region" { + description = "Google cloud region" + value = var.region +} + +output "kubernetes_cluster_name" { + description = "GKE Cluster Name" + value = google_container_cluster.primary.name +} diff --git a/spartan/terraform/gke-cluster/variables.tf b/spartan/terraform/gke-cluster/variables.tf new file mode 100644 index 000000000000..555458daa5d0 --- /dev/null +++ b/spartan/terraform/gke-cluster/variables.tf @@ -0,0 +1,11 @@ +variable "project" { + default = "testnet-440309" +} + +variable "region" { + default = "us-east4" +} + +variable "zone" { + default = "us-east4-a" +} diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 4338feb084c8..9d19fae994ad 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -201,6 +201,12 @@ describe('Archiver', () => { expect(totalNumUnencryptedLogs).toEqual(expectedTotalNumUnencryptedLogs); }); + blockNumbers.forEach(async x => { + const expectedTotalNumContractClassLogs = 4; + const contractClassLogs = await archiver.getContractClassLogs({ fromBlock: x, toBlock: x + 1 }); + expect(contractClassLogs.logs.length).toEqual(expectedTotalNumContractClassLogs); + }); + // Check last proven block number const provenBlockNumber = await archiver.getProvenBlockNumber(); expect(provenBlockNumber).toEqual(1); diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 4c8adef9a6f3..a2a10d8c7a26 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -1,4 +1,5 @@ import { + type EncryptedL2Log, type FromLogType, type GetUnencryptedLogsResponse, type InboxLeaf, @@ -14,7 +15,7 @@ import { type TxEffect, type TxHash, type TxReceipt, - type TxScopedEncryptedL2NoteLog, + type TxScopedL2Log, type UnencryptedL2Log, } from '@aztec/circuit-types'; import { @@ -638,7 +639,7 @@ export class Archiver implements ArchiveSource { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise { + getLogsByTags(tags: Fr[]): Promise { return this.store.getLogsByTags(tags); } @@ -651,6 +652,15 @@ export class Archiver implements ArchiveSource { return this.store.getUnencryptedLogs(filter); } + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise { + return this.store.getContractClassLogs(filter); + } + /** * Gets the number of the latest L2 block processed by the block source implementation. * @returns The number of the latest L2 block processed by the block source implementation. @@ -789,7 +799,7 @@ class ArchiverStoreHelper * Extracts and stores contract instances out of ContractInstanceDeployed events emitted by the canonical deployer contract. * @param allLogs - All logs emitted in a bunch of blocks. */ - async #updateDeployedContractInstances(allLogs: UnencryptedL2Log[], blockNum: number, operation: Operation) { + async #updateDeployedContractInstances(allLogs: EncryptedL2Log[], blockNum: number, operation: Operation) { const contractInstances = ContractInstanceDeployedEvent.fromLogs(allLogs).map(e => e.toContractInstance()); if (contractInstances.length > 0) { contractInstances.forEach(c => @@ -868,15 +878,18 @@ class ArchiverStoreHelper // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them ...(await Promise.all( blocks.map(async block => { - const blockLogs = block.data.body.txEffects - .flatMap(txEffect => (txEffect ? [txEffect.unencryptedLogs] : [])) + const contractClassLogs = block.data.body.txEffects + .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : [])) + .flatMap(txLog => txLog.unrollLogs()); + // ContractInstanceDeployed event logs are now broadcast in .encryptedLogs + const allEncryptedLogs = block.data.body.txEffects + .flatMap(txEffect => (txEffect ? [txEffect.encryptedLogs] : [])) .flatMap(txLog => txLog.unrollLogs()); - return ( await Promise.all([ - this.#updateRegisteredContractClasses(blockLogs, block.data.number, Operation.Store), - this.#updateDeployedContractInstances(blockLogs, block.data.number, Operation.Store), - this.#storeBroadcastedIndividualFunctions(blockLogs, block.data.number), + this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store), + this.#updateDeployedContractInstances(allEncryptedLogs, block.data.number, Operation.Store), + this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number), ]) ).every(Boolean); }), @@ -898,11 +911,15 @@ class ArchiverStoreHelper // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them ...(await Promise.all( blocks.map(async block => { - const blockLogs = block.data.body.txEffects - .flatMap(txEffect => (txEffect ? [txEffect.unencryptedLogs] : [])) + const contractClassLogs = block.data.body.txEffects + .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : [])) .flatMap(txLog => txLog.unrollLogs()); - await this.#updateRegisteredContractClasses(blockLogs, block.data.number, Operation.Delete); - await this.#updateDeployedContractInstances(blockLogs, block.data.number, Operation.Delete); + // ContractInstanceDeployed event logs are now broadcast in .encryptedLogs + const allEncryptedLogs = block.data.body.txEffects + .flatMap(txEffect => (txEffect ? [txEffect.encryptedLogs] : [])) + .flatMap(txLog => txLog.unrollLogs()); + await this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete); + await this.#updateDeployedContractInstances(allEncryptedLogs, block.data.number, Operation.Delete); }), )), this.store.deleteLogs(blocks.map(b => b.data)), @@ -938,12 +955,15 @@ class ArchiverStoreHelper ): Promise>[]> { return this.store.getLogs(from, limit, logType); } - getLogsByTags(tags: Fr[]): Promise { + getLogsByTags(tags: Fr[]): Promise { return this.store.getLogsByTags(tags); } getUnencryptedLogs(filter: LogFilter): Promise { return this.store.getUnencryptedLogs(filter); } + getContractClassLogs(filter: LogFilter): Promise { + return this.store.getContractClassLogs(filter); + } getSynchedL2BlockNumber(): Promise { return this.store.getSynchedL2BlockNumber(); } diff --git a/yarn-project/archiver/src/archiver/archiver_store.ts b/yarn-project/archiver/src/archiver/archiver_store.ts index 5038dd4afebb..4eb2c80ccc0a 100644 --- a/yarn-project/archiver/src/archiver/archiver_store.ts +++ b/yarn-project/archiver/src/archiver/archiver_store.ts @@ -9,7 +9,7 @@ import { type TxEffect, type TxHash, type TxReceipt, - type TxScopedEncryptedL2NoteLog, + type TxScopedL2Log, } from '@aztec/circuit-types'; import { type ContractClassPublic, @@ -142,7 +142,7 @@ export interface ArchiverDataStore { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise; + getLogsByTags(tags: Fr[]): Promise; /** * Gets unencrypted logs based on the provided filter. @@ -151,6 +151,13 @@ export interface ArchiverDataStore { */ getUnencryptedLogs(filter: LogFilter): Promise; + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise; + /** * Gets the number of the latest L2 block processed. * @returns The number of the latest L2 block processed. diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts index 1311c6ec03ee..cd30af56a78e 100644 --- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts +++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts @@ -344,14 +344,24 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch describe('getLogsByTags', () => { const txsPerBlock = 4; const numPrivateFunctionCalls = 3; - const numNoteEncryptedLogs = 2; + const numPublicFunctionCalls = 1; + const numEncryptedLogsPerFn = 2; + const numUnencryptedLogsPerFn = 1; const numBlocks = 10; let blocks: L1Published[]; - let tags: { [i: number]: { [j: number]: Buffer[] } } = {}; + let encryptedLogTags: { [i: number]: { [j: number]: Buffer[] } } = {}; + let unencryptedLogTags: { [i: number]: { [j: number]: Buffer[] } } = {}; beforeEach(async () => { blocks = times(numBlocks, (index: number) => ({ - data: L2Block.random(index + 1, txsPerBlock, numPrivateFunctionCalls, 2, numNoteEncryptedLogs, 2), + data: L2Block.random( + index + 1, + txsPerBlock, + numPrivateFunctionCalls, + numPublicFunctionCalls, + numEncryptedLogsPerFn, + numUnencryptedLogsPerFn, + ), l1: { blockNumber: BigInt(index), blockHash: `0x${index}`, timestamp: BigInt(index) }, })); // Last block has the note encrypted log tags of the first tx copied from the previous block @@ -373,47 +383,94 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch await store.addBlocks(blocks); await store.addLogs(blocks.map(b => b.data)); - tags = {}; + encryptedLogTags = {}; + unencryptedLogTags = {}; blocks.forEach((b, blockIndex) => { - if (!tags[blockIndex]) { - tags[blockIndex] = {}; + if (!encryptedLogTags[blockIndex]) { + encryptedLogTags[blockIndex] = {}; + } + if (!unencryptedLogTags[blockIndex]) { + unencryptedLogTags[blockIndex] = {}; } b.data.body.noteEncryptedLogs.txLogs.forEach((txLogs, txIndex) => { - if (!tags[blockIndex][txIndex]) { - tags[blockIndex][txIndex] = []; + if (!encryptedLogTags[blockIndex][txIndex]) { + encryptedLogTags[blockIndex][txIndex] = []; + } + encryptedLogTags[blockIndex][txIndex].push(...txLogs.unrollLogs().map(log => log.data.subarray(0, 32))); + }); + b.data.body.unencryptedLogs.txLogs.forEach((txLogs, txIndex) => { + if (!unencryptedLogTags[blockIndex][txIndex]) { + unencryptedLogTags[blockIndex][txIndex] = []; } - tags[blockIndex][txIndex].push(...txLogs.unrollLogs().map(log => log.data.subarray(0, 32))); + unencryptedLogTags[blockIndex][txIndex].push(...txLogs.unrollLogs().map(log => log.data.subarray(0, 32))); }); }); }); - it('is possible to batch request all logs of a tx via tags', async () => { + it('is possible to batch request encrypted logs of a tx via tags', async () => { // get random tx from any block that's not the last one const targetBlockIndex = randomInt(numBlocks - 2); const targetTxIndex = randomInt(txsPerBlock); const logsByTags = await store.getLogsByTags( - tags[targetBlockIndex][targetTxIndex].map(buffer => new Fr(buffer)), + encryptedLogTags[targetBlockIndex][targetTxIndex].map(buffer => new Fr(buffer)), ); - const expectedResponseSize = numPrivateFunctionCalls * numNoteEncryptedLogs; + const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn; expect(logsByTags.length).toEqual(expectedResponseSize); logsByTags.forEach((logsByTag, logIndex) => { expect(logsByTag).toHaveLength(1); const [scopedLog] = logsByTag; expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash); - expect(scopedLog.log).toEqual( - blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex], + expect(scopedLog.logData).toEqual( + blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data, ); }); }); - it('is possible to batch request all logs of different blocks via tags', async () => { + // TODO: Allow this test when #9835 is fixed and tags can be correctly decoded + it.skip('is possible to batch request all logs (encrypted and unencrypted) of a tx via tags', async () => { + // get random tx from any block that's not the last one + const targetBlockIndex = randomInt(numBlocks - 2); + const targetTxIndex = randomInt(txsPerBlock); + + const logsByTags = await store.getLogsByTags( + encryptedLogTags[targetBlockIndex][targetTxIndex] + .concat(unencryptedLogTags[targetBlockIndex][targetTxIndex]) + .map(buffer => new Fr(buffer)), + ); + + const expectedResponseSize = + numPrivateFunctionCalls * numEncryptedLogsPerFn + numPublicFunctionCalls * numUnencryptedLogsPerFn; + expect(logsByTags.length).toEqual(expectedResponseSize); + + const encryptedLogsByTags = logsByTags.slice(0, numPrivateFunctionCalls * numEncryptedLogsPerFn); + const unencryptedLogsByTags = logsByTags.slice(numPrivateFunctionCalls * numEncryptedLogsPerFn); + encryptedLogsByTags.forEach((logsByTag, logIndex) => { + expect(logsByTag).toHaveLength(1); + const [scopedLog] = logsByTag; + expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash); + expect(scopedLog.logData).toEqual( + blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data, + ); + }); + unencryptedLogsByTags.forEach((logsByTag, logIndex) => { + expect(logsByTag).toHaveLength(1); + const [scopedLog] = logsByTag; + expect(scopedLog.logData).toEqual( + blocks[targetBlockIndex].data.body.unencryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data, + ); + }); + }); + + it('is possible to batch request logs of different blocks via tags', async () => { // get first tx of first block and second tx of second block - const logsByTags = await store.getLogsByTags([...tags[0][0], ...tags[1][1]].map(buffer => new Fr(buffer))); + const logsByTags = await store.getLogsByTags( + [...encryptedLogTags[0][0], ...encryptedLogTags[1][1]].map(buffer => new Fr(buffer)), + ); - const expectedResponseSize = 2 * numPrivateFunctionCalls * numNoteEncryptedLogs; + const expectedResponseSize = 2 * numPrivateFunctionCalls * numEncryptedLogsPerFn; expect(logsByTags.length).toEqual(expectedResponseSize); logsByTags.forEach(logsByTag => expect(logsByTag).toHaveLength(1)); @@ -421,14 +478,14 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch it('is possible to batch request logs that have the same tag but different content', async () => { // get first tx of last block - const logsByTags = await store.getLogsByTags(tags[numBlocks - 1][0].map(buffer => new Fr(buffer))); + const logsByTags = await store.getLogsByTags(encryptedLogTags[numBlocks - 1][0].map(buffer => new Fr(buffer))); - const expectedResponseSize = numPrivateFunctionCalls * numNoteEncryptedLogs; + const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn; expect(logsByTags.length).toEqual(expectedResponseSize); logsByTags.forEach(logsByTag => { expect(logsByTag).toHaveLength(2); - const [tag0, tag1] = logsByTag.map(scopedLog => new Fr(scopedLog.log.data.subarray(0, 32))); + const [tag0, tag1] = logsByTag.map(scopedLog => new Fr(scopedLog.logData.subarray(0, 32))); expect(tag0).toEqual(tag1); }); }); @@ -440,10 +497,10 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch const logsByTags = await store.getLogsByTags([ Fr.random(), - ...tags[targetBlockIndex][targetTxIndex].slice(1).map(buffer => new Fr(buffer)), + ...encryptedLogTags[targetBlockIndex][targetTxIndex].slice(1).map(buffer => new Fr(buffer)), ]); - const expectedResponseSize = numPrivateFunctionCalls * numNoteEncryptedLogs; + const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn; expect(logsByTags.length).toEqual(expectedResponseSize); const [emptyLogsByTag, ...populatedLogsByTags] = logsByTags; @@ -453,8 +510,8 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch expect(logsByTag).toHaveLength(1); const [scopedLog] = logsByTag; expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash); - expect(scopedLog.log).toEqual( - blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex + 1], + expect(scopedLog.logData).toEqual( + blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex + 1].data, ); }); }); diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts index d7ff5f8c1d5e..8cbb627a5ce3 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts @@ -9,7 +9,7 @@ import { type TxEffect, type TxHash, type TxReceipt, - type TxScopedEncryptedL2NoteLog, + type TxScopedL2Log, } from '@aztec/circuit-types'; import { type ContractClassPublic, @@ -245,7 +245,7 @@ export class KVArchiverDataStore implements ArchiverDataStore { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise { + getLogsByTags(tags: Fr[]): Promise { try { return this.#logStore.getLogsByTags(tags); } catch (err) { @@ -266,6 +266,19 @@ export class KVArchiverDataStore implements ArchiverDataStore { } } + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise { + try { + return Promise.resolve(this.#logStore.getContractClassLogs(filter)); + } catch (err) { + return Promise.reject(err); + } + } + /** * Gets the number of the latest L2 block processed. * @returns The number of the latest L2 block processed. diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts index d50c63402845..f6c0abbc3273 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts @@ -1,5 +1,6 @@ import { type Body, + ContractClass2BlockL2Logs, EncryptedL2BlockL2Logs, EncryptedNoteL2BlockL2Logs, ExtendedUnencryptedL2Log, @@ -10,7 +11,7 @@ import { type LogFilter, LogId, LogType, - TxScopedEncryptedL2NoteLog, + TxScopedL2Log, UnencryptedL2BlockL2Logs, type UnencryptedL2Log, } from '@aztec/circuit-types'; @@ -30,6 +31,7 @@ export class LogStore { #logTagsByBlock: AztecMap; #encryptedLogsByBlock: AztecMap; #unencryptedLogsByBlock: AztecMap; + #contractClassLogsByBlock: AztecMap; #logsMaxPageSize: number; #log = createDebugLogger('aztec:archiver:log_store'); @@ -39,6 +41,8 @@ export class LogStore { this.#logTagsByBlock = db.openMap('archiver_log_tags_by_block'); this.#encryptedLogsByBlock = db.openMap('archiver_encrypted_logs_by_block'); this.#unencryptedLogsByBlock = db.openMap('archiver_unencrypted_logs_by_block'); + this.#contractClassLogsByBlock = db.openMap('archiver_contract_class_logs_by_block'); + this.#logsMaxPageSize = logsMaxPageSize; } @@ -80,7 +84,15 @@ export class LogStore { } this.#log.verbose(`Found tagged (${logType}) log with tag ${tag.toString()} in block ${block.number}`); const currentLogs = taggedLogs.get(tag.toString()) ?? []; - currentLogs.push(new TxScopedEncryptedL2NoteLog(txHash, dataStartIndexForTx, log).toBuffer()); + currentLogs.push( + new TxScopedL2Log( + txHash, + dataStartIndexForTx, + block.number, + logType === 'unencryptedLogs', + log.data, + ).toBuffer(), + ); taggedLogs.set(tag.toString(), currentLogs); } catch (err) { this.#log.warn(`Failed to add tagged log to store: ${err}`); @@ -99,8 +111,7 @@ export class LogStore { const taggedLogsToAdd = blocks .flatMap(block => [ this.#extractTaggedLogs(block, 'noteEncryptedLogs'), - // TODO: process unencrypted logs in #9794 - // this.#extractTaggedLogs(block, 'unencryptedLogs'), + this.#extractTaggedLogs(block, 'unencryptedLogs'), ]) .reduce((acc, val) => { for (const [tag, logs] of val.entries()) { @@ -132,6 +143,7 @@ export class LogStore { void this.#noteEncryptedLogsByBlock.set(block.number, block.body.noteEncryptedLogs.toBuffer()); void this.#encryptedLogsByBlock.set(block.number, block.body.encryptedLogs.toBuffer()); void this.#unencryptedLogsByBlock.set(block.number, block.body.unencryptedLogs.toBuffer()); + void this.#contractClassLogsByBlock.set(block.number, block.body.contractClassLogs.toBuffer()); }); return true; @@ -204,14 +216,11 @@ export class LogStore { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise { + getLogsByTags(tags: Fr[]): Promise { return this.db.transaction(() => tags .map(tag => this.#logsByTag.get(tag.toString())) - .map( - noteLogBuffers => - noteLogBuffers?.map(noteLogBuffer => TxScopedEncryptedL2NoteLog.fromBuffer(noteLogBuffer)) ?? [], - ), + .map(noteLogBuffers => noteLogBuffers?.map(noteLogBuffer => TxScopedL2Log.fromBuffer(noteLogBuffer)) ?? []), ); } @@ -279,6 +288,72 @@ export class LogStore { return { logs, maxLogsHit }; } + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): GetUnencryptedLogsResponse { + if (filter.afterLog) { + return this.#filterContractClassLogsBetweenBlocks(filter); + } else if (filter.txHash) { + return this.#filterContractClassLogsOfTx(filter); + } else { + return this.#filterContractClassLogsBetweenBlocks(filter); + } + } + + #filterContractClassLogsOfTx(filter: LogFilter): GetUnencryptedLogsResponse { + if (!filter.txHash) { + throw new Error('Missing txHash'); + } + + const [blockNumber, txIndex] = this.blockStore.getTxLocation(filter.txHash) ?? []; + if (typeof blockNumber !== 'number' || typeof txIndex !== 'number') { + return { logs: [], maxLogsHit: false }; + } + const contractClassLogsBuffer = this.#contractClassLogsByBlock.get(blockNumber); + const contractClassLogsInBlock = contractClassLogsBuffer + ? ContractClass2BlockL2Logs.fromBuffer(contractClassLogsBuffer) + : new ContractClass2BlockL2Logs([]); + const txLogs = contractClassLogsInBlock.txLogs[txIndex].unrollLogs(); + + const logs: ExtendedUnencryptedL2Log[] = []; + const maxLogsHit = this.#accumulateLogs(logs, blockNumber, txIndex, txLogs, filter); + + return { logs, maxLogsHit }; + } + + #filterContractClassLogsBetweenBlocks(filter: LogFilter): GetUnencryptedLogsResponse { + const start = + filter.afterLog?.blockNumber ?? Math.max(filter.fromBlock ?? INITIAL_L2_BLOCK_NUM, INITIAL_L2_BLOCK_NUM); + const end = filter.toBlock; + + if (typeof end === 'number' && end < start) { + return { + logs: [], + maxLogsHit: true, + }; + } + + const logs: ExtendedUnencryptedL2Log[] = []; + + let maxLogsHit = false; + loopOverBlocks: for (const [blockNumber, logBuffer] of this.#contractClassLogsByBlock.entries({ start, end })) { + const contractClassLogsInBlock = ContractClass2BlockL2Logs.fromBuffer(logBuffer); + for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < contractClassLogsInBlock.txLogs.length; txIndex++) { + const txLogs = contractClassLogsInBlock.txLogs[txIndex].unrollLogs(); + maxLogsHit = this.#accumulateLogs(logs, blockNumber, txIndex, txLogs, filter); + if (maxLogsHit) { + this.#log.debug(`Max logs hit at block ${blockNumber}`); + break loopOverBlocks; + } + } + } + + return { logs, maxLogsHit }; + } + #accumulateLogs( results: ExtendedUnencryptedL2Log[], blockNumber: number, diff --git a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts index 14637a80a108..e49ab8eccc27 100644 --- a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts @@ -1,4 +1,6 @@ import { + type Body, + type ContractClass2BlockL2Logs, type EncryptedL2BlockL2Logs, type EncryptedNoteL2BlockL2Logs, ExtendedUnencryptedL2Log, @@ -13,7 +15,7 @@ import { type TxEffect, type TxHash, TxReceipt, - TxScopedEncryptedL2NoteLog, + TxScopedL2Log, type UnencryptedL2BlockL2Logs, } from '@aztec/circuit-types'; import { @@ -52,14 +54,16 @@ export class MemoryArchiverStore implements ArchiverDataStore { private noteEncryptedLogsPerBlock: Map = new Map(); - private taggedNoteEncryptedLogs: Map = new Map(); + private taggedLogs: Map = new Map(); - private noteEncryptedLogTagsPerBlock: Map = new Map(); + private logTagsPerBlock: Map = new Map(); private encryptedLogsPerBlock: Map = new Map(); private unencryptedLogsPerBlock: Map = new Map(); + private contractClassLogsPerBlock: Map = new Map(); + /** * Contains all L1 to L2 messages. */ @@ -207,6 +211,56 @@ export class MemoryArchiverStore implements ArchiverDataStore { return Promise.resolve(true); } + #storeTaggedLogs(block: L2Block, logType: keyof Pick): void { + const dataStartIndexForBlock = + block.header.state.partial.noteHashTree.nextAvailableLeafIndex - + block.body.numberOfTxsIncludingPadded * MAX_NOTE_HASHES_PER_TX; + block.body[logType].txLogs.forEach((txLogs, txIndex) => { + const txHash = block.body.txEffects[txIndex].txHash; + const dataStartIndexForTx = dataStartIndexForBlock + txIndex * MAX_NOTE_HASHES_PER_TX; + const logs = txLogs.unrollLogs(); + logs.forEach(log => { + if ( + (logType == 'noteEncryptedLogs' && log.data.length < 32) || + // TODO remove when #9835 and #9836 are fixed + (logType === 'unencryptedLogs' && log.data.length < 32 * 33) + ) { + this.#log.warn(`Skipping log (${logType}) with invalid data length: ${log.data.length}`); + return; + } + try { + let tag = Fr.ZERO; + // TODO remove when #9835 and #9836 are fixed. The partial note logs are emitted as bytes, but encoded as Fields. + // This means that for every 32 bytes of payload, we only have 1 byte of data. + // Also, the tag is not stored in the first 32 bytes of the log, (that's the length of public fields now) but in the next 32. + if (logType === 'unencryptedLogs') { + const correctedBuffer = Buffer.alloc(32); + const initialOffset = 32; + for (let i = 0; i < 32; i++) { + const byte = Fr.fromBuffer( + log.data.subarray(i * 32 + initialOffset, i * 32 + 32 + initialOffset), + ).toNumber(); + correctedBuffer.writeUInt8(byte, i); + } + tag = new Fr(correctedBuffer); + } else { + tag = new Fr(log.data.subarray(0, 32)); + } + this.#log.verbose(`Storing tagged (${logType}) log with tag ${tag.toString()} in block ${block.number}`); + const currentLogs = this.taggedLogs.get(tag.toString()) || []; + this.taggedLogs.set(tag.toString(), [ + ...currentLogs, + new TxScopedL2Log(txHash, dataStartIndexForTx, block.number, logType === 'unencryptedLogs', log.data), + ]); + const currentTagsInBlock = this.logTagsPerBlock.get(block.number) || []; + this.logTagsPerBlock.set(block.number, [...currentTagsInBlock, tag]); + } catch (err) { + this.#log.warn(`Failed to add tagged log to store: ${err}`); + } + }); + }); + } + /** * Append new logs to the store's list. * @param block - The block for which to add the logs. @@ -214,52 +268,30 @@ export class MemoryArchiverStore implements ArchiverDataStore { */ addLogs(blocks: L2Block[]): Promise { blocks.forEach(block => { - const dataStartIndexForBlock = - block.header.state.partial.noteHashTree.nextAvailableLeafIndex - - block.body.numberOfTxsIncludingPadded * MAX_NOTE_HASHES_PER_TX; + void this.#storeTaggedLogs(block, 'noteEncryptedLogs'); + void this.#storeTaggedLogs(block, 'unencryptedLogs'); this.noteEncryptedLogsPerBlock.set(block.number, block.body.noteEncryptedLogs); - block.body.noteEncryptedLogs.txLogs.forEach((txLogs, txIndex) => { - const txHash = block.body.txEffects[txIndex].txHash; - const dataStartIndexForTx = dataStartIndexForBlock + txIndex * MAX_NOTE_HASHES_PER_TX; - const noteLogs = txLogs.unrollLogs(); - noteLogs.forEach(noteLog => { - if (noteLog.data.length < 32) { - this.#log.warn(`Skipping note log with invalid data length: ${noteLog.data.length}`); - return; - } - try { - const tag = new Fr(noteLog.data.subarray(0, 32)); - const currentNoteLogs = this.taggedNoteEncryptedLogs.get(tag.toString()) || []; - this.taggedNoteEncryptedLogs.set(tag.toString(), [ - ...currentNoteLogs, - new TxScopedEncryptedL2NoteLog(txHash, dataStartIndexForTx, noteLog), - ]); - const currentTagsInBlock = this.noteEncryptedLogTagsPerBlock.get(block.number) || []; - this.noteEncryptedLogTagsPerBlock.set(block.number, [...currentTagsInBlock, tag]); - } catch (err) { - this.#log.warn(`Failed to add tagged note log to store: ${err}`); - } - }); - }); this.encryptedLogsPerBlock.set(block.number, block.body.encryptedLogs); this.unencryptedLogsPerBlock.set(block.number, block.body.unencryptedLogs); + this.contractClassLogsPerBlock.set(block.number, block.body.contractClassLogs); }); return Promise.resolve(true); } deleteLogs(blocks: L2Block[]): Promise { - const noteTagsToDelete = blocks.flatMap(block => this.noteEncryptedLogTagsPerBlock.get(block.number)); - noteTagsToDelete + const tagsToDelete = blocks.flatMap(block => this.logTagsPerBlock.get(block.number)); + tagsToDelete .filter(tag => tag != undefined) .forEach(tag => { - this.taggedNoteEncryptedLogs.delete(tag!.toString()); + this.taggedLogs.delete(tag!.toString()); }); blocks.forEach(block => { this.encryptedLogsPerBlock.delete(block.number); this.noteEncryptedLogsPerBlock.delete(block.number); this.unencryptedLogsPerBlock.delete(block.number); - this.noteEncryptedLogTagsPerBlock.delete(block.number); + this.logTagsPerBlock.delete(block.number); + this.contractClassLogsPerBlock.delete(block.number); }); return Promise.resolve(true); @@ -428,8 +460,8 @@ export class MemoryArchiverStore implements ArchiverDataStore { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise { - const noteLogs = tags.map(tag => this.taggedNoteEncryptedLogs.get(tag.toString()) || []); + getLogsByTags(tags: Fr[]): Promise { + const noteLogs = tags.map(tag => this.taggedLogs.get(tag.toString()) || []); return Promise.resolve(noteLogs); } @@ -516,6 +548,90 @@ export class MemoryArchiverStore implements ArchiverDataStore { }); } + /** + * Gets contract class logs based on the provided filter. + * NB: clone of the above fn, but for contract class logs + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + * @remarks Works by doing an intersection of all params in the filter. + */ + getContractClassLogs(filter: LogFilter): Promise { + let txHash: TxHash | undefined; + let fromBlock = 0; + let toBlock = this.l2Blocks.length + INITIAL_L2_BLOCK_NUM; + let txIndexInBlock = 0; + let logIndexInTx = 0; + + if (filter.afterLog) { + // Continuation parameter is set --> tx hash is ignored + if (filter.fromBlock == undefined || filter.fromBlock <= filter.afterLog.blockNumber) { + fromBlock = filter.afterLog.blockNumber; + txIndexInBlock = filter.afterLog.txIndex; + logIndexInTx = filter.afterLog.logIndex + 1; // We want to start from the next log + } else { + fromBlock = filter.fromBlock; + } + } else { + txHash = filter.txHash; + + if (filter.fromBlock !== undefined) { + fromBlock = filter.fromBlock; + } + } + + if (filter.toBlock !== undefined) { + toBlock = filter.toBlock; + } + + // Ensure the indices are within block array bounds + fromBlock = Math.max(fromBlock, INITIAL_L2_BLOCK_NUM); + toBlock = Math.min(toBlock, this.l2Blocks.length + INITIAL_L2_BLOCK_NUM); + + if (fromBlock > this.l2Blocks.length || toBlock < fromBlock || toBlock <= 0) { + return Promise.resolve({ + logs: [], + maxLogsHit: false, + }); + } + + const contractAddress = filter.contractAddress; + + const logs: ExtendedUnencryptedL2Log[] = []; + + for (; fromBlock < toBlock; fromBlock++) { + const block = this.l2Blocks[fromBlock - INITIAL_L2_BLOCK_NUM]; + const blockLogs = this.contractClassLogsPerBlock.get(fromBlock); + + if (blockLogs) { + for (; txIndexInBlock < blockLogs.txLogs.length; txIndexInBlock++) { + const txLogs = blockLogs.txLogs[txIndexInBlock].unrollLogs(); + for (; logIndexInTx < txLogs.length; logIndexInTx++) { + const log = txLogs[logIndexInTx]; + if ( + (!txHash || block.data.body.txEffects[txIndexInBlock].txHash.equals(txHash)) && + (!contractAddress || log.contractAddress.equals(contractAddress)) + ) { + logs.push(new ExtendedUnencryptedL2Log(new LogId(block.data.number, txIndexInBlock, logIndexInTx), log)); + if (logs.length === this.maxLogs) { + return Promise.resolve({ + logs, + maxLogsHit: true, + }); + } + } + } + logIndexInTx = 0; + } + } + txIndexInBlock = 0; + } + + return Promise.resolve({ + logs, + maxLogsHit: false, + }); + } + /** * Gets the number of the latest L2 block processed. * @returns The number of the latest L2 block processed. diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 0f8e30f584dd..eec371b96fbf 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -27,7 +27,7 @@ import { type TxEffect, type TxHash, TxReceipt, - type TxScopedEncryptedL2NoteLog, + type TxScopedL2Log, TxStatus, type TxValidator, type WorldStateSynchronizer, @@ -315,7 +315,7 @@ export class AztecNodeService implements AztecNode { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - public getLogsByTags(tags: Fr[]): Promise { + public getLogsByTags(tags: Fr[]): Promise { return this.encryptedLogsSource.getLogsByTags(tags); } @@ -328,6 +328,15 @@ export class AztecNodeService implements AztecNode { return this.unencryptedLogsSource.getUnencryptedLogs(filter); } + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise { + return this.unencryptedLogsSource.getContractClassLogs(filter); + } + /** * Method to submit a transaction to the p2p pool. * @param tx - The transaction to be submitted. @@ -402,19 +411,19 @@ export class AztecNodeService implements AztecNode { } /** - * Find the index of the given leaf in the given tree. - * @param blockNumber - The block number at which to get the data + * Find the indexes of the given leaves in the given tree. + * @param blockNumber - The block number at which to get the data or 'latest' for latest data * @param treeId - The tree to search in. - * @param leafValue - The value to search for - * @returns The index of the given leaf in the given tree or undefined if not found. + * @param leafValue - The values to search for + * @returns The indexes of the given leaves in the given tree or undefined if not found. */ - public async findLeafIndex( + public async findLeavesIndexes( blockNumber: L2BlockNumber, treeId: MerkleTreeId, - leafValue: Fr, - ): Promise { + leafValues: Fr[], + ): Promise<(bigint | undefined)[]> { const committedDb = await this.#getWorldState(blockNumber); - return committedDb.findLeafIndex(treeId, leafValue.toBuffer()); + return await Promise.all(leafValues.map(leafValue => committedDb.findLeafIndex(treeId, leafValue.toBuffer()))); } /** diff --git a/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts b/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts index fe96e478c387..3ffdfe4ebaaf 100644 --- a/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts +++ b/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts @@ -3,7 +3,6 @@ import { type FieldsOf } from '@aztec/foundation/types'; import { type Wallet } from '../account/index.js'; import { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js'; -import { waitForAccountSynch } from '../utils/account.js'; /** Extends a transaction receipt with a wallet instance for the newly deployed contract. */ export type DeployAccountTxReceipt = FieldsOf & { @@ -37,7 +36,6 @@ export class DeployAccountSentTx extends SentTx { public override async wait(opts: WaitOpts = DefaultWaitOpts): Promise { const receipt = await super.wait(opts); const wallet = await this.getWalletPromise; - await waitForAccountSynch(this.pxe, wallet.getCompleteAddress(), opts); return { ...receipt, wallet }; } } diff --git a/yarn-project/aztec.js/src/account_manager/index.ts b/yarn-project/aztec.js/src/account_manager/index.ts index 4ea49a571036..e4e3316a6dba 100644 --- a/yarn-project/aztec.js/src/account_manager/index.ts +++ b/yarn-project/aztec.js/src/account_manager/index.ts @@ -8,7 +8,6 @@ import { type AccountInterface } from '../account/interface.js'; import { type DeployOptions } from '../contract/deploy_method.js'; import { DefaultWaitOpts, type WaitOpts } from '../contract/sent_tx.js'; import { DefaultMultiCallEntrypoint } from '../entrypoint/default_multi_call_entrypoint.js'; -import { waitForAccountSynch } from '../utils/account.js'; import { AccountWalletWithSecretKey, SignerlessWallet } from '../wallet/index.js'; import { DeployAccountMethod } from './deploy_account_method.js'; import { DeployAccountSentTx } from './deploy_account_sent_tx.js'; @@ -105,7 +104,7 @@ export class AccountManager { * @param opts - Options to wait for the account to be synched. * @returns A Wallet instance. */ - public async register(opts: WaitOpts = DefaultWaitOpts): Promise { + public async register(): Promise { await this.pxe.registerContract({ artifact: this.accountContract.getContractArtifact(), instance: this.getInstance(), @@ -113,7 +112,6 @@ export class AccountManager { await this.pxe.registerAccount(this.secretKey, this.getCompleteAddress().partialAddress); - await waitForAccountSynch(this.pxe, this.getCompleteAddress(), opts); return this.getWallet(); } diff --git a/yarn-project/aztec.js/src/contract/proven_tx.ts b/yarn-project/aztec.js/src/contract/proven_tx.ts index 05c8defd7458..a02eb0c28d32 100644 --- a/yarn-project/aztec.js/src/contract/proven_tx.ts +++ b/yarn-project/aztec.js/src/contract/proven_tx.ts @@ -14,6 +14,7 @@ export class ProvenTx extends Tx { tx.noteEncryptedLogs, tx.encryptedLogs, tx.unencryptedLogs, + tx.contractClassLogs, tx.enqueuedPublicFunctionCalls, tx.publicTeardownFunctionCall, ); @@ -27,6 +28,7 @@ export class ProvenTx extends Tx { this.noteEncryptedLogs, this.encryptedLogs, this.unencryptedLogs, + this.contractClassLogs, this.enqueuedPublicFunctionCalls, this.publicTeardownFunctionCall, ); diff --git a/yarn-project/aztec.js/src/contract/sent_tx.test.ts b/yarn-project/aztec.js/src/contract/sent_tx.test.ts index d7125dd47558..13a2def98cd1 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.test.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.test.ts @@ -23,34 +23,27 @@ describe('SentTx', () => { pxe.getTxReceipt.mockResolvedValue(txReceipt); }); - it('waits for all notes accounts to be synced', async () => { - pxe.getSyncStatus - .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } }) - .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 20, '0x2': 20 } }); + it('waits for all notes of the accounts to be available', async () => { + pxe.getSyncStatus.mockResolvedValueOnce({ blocks: 25 }).mockResolvedValueOnce({ blocks: 25 }); const actual = await sentTx.wait({ timeout: 1, interval: 0.4 }); expect(actual).toEqual(txReceipt); }); - it('fails if an account is not synced', async () => { - pxe.getSyncStatus.mockResolvedValue({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } }); - await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrow(/timeout/i); - }); - it('does not wait for notes sync', async () => { - pxe.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); - const actual = await sentTx.wait({ timeout: 1, interval: 0.4, waitForNotesSync: false }); + pxe.getSyncStatus.mockResolvedValue({ blocks: 19 }); + const actual = await sentTx.wait({ timeout: 1, interval: 0.4, waitForNotesAvailable: false }); expect(actual).toEqual(txReceipt); }); it('throws if tx is dropped', async () => { pxe.getTxReceipt.mockResolvedValue({ ...txReceipt, status: TxStatus.DROPPED } as TxReceipt); - pxe.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); + pxe.getSyncStatus.mockResolvedValue({ blocks: 19 }); await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrow(/dropped/); }); it('waits for the tx to be proven', async () => { - const waitOpts = { timeout: 1, interval: 0.4, waitForNotesSync: false, proven: true, provenTimeout: 2 }; + const waitOpts = { timeout: 1, interval: 0.4, waitForNotesAvailable: false, proven: true, provenTimeout: 2 }; pxe.getProvenBlockNumber.mockResolvedValue(10); await expect(sentTx.wait(waitOpts)).rejects.toThrow(/timeout/i); diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index 91b0f5ea2c0f..7b85b3fd8538 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -1,11 +1,4 @@ -import { - type ExtendedNote, - type GetUnencryptedLogsResponse, - type PXE, - type TxHash, - type TxReceipt, - TxStatus, -} from '@aztec/circuit-types'; +import { type GetUnencryptedLogsResponse, type PXE, type TxHash, type TxReceipt, TxStatus } from '@aztec/circuit-types'; import { retryUntil } from '@aztec/foundation/retry'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -20,10 +13,10 @@ export type WaitOpts = { /** Whether to wait for the tx to be proven. */ proven?: boolean; /** - * Whether to wait for the PXE Service to sync all notes up to the block in which this tx was mined. + * Whether to wait for the node to notify that the block in which this tx was mined is available to fetch notes from. * If false, then any queries that depend on state set by this transaction may return stale data. Defaults to true. **/ - waitForNotesSync?: boolean; + waitForNotesAvailable?: boolean; /** Whether to include information useful for debugging/testing in the receipt. */ debug?: boolean; /** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */ @@ -34,8 +27,8 @@ export const DefaultWaitOpts: WaitOpts = { timeout: 60, provenTimeout: 600, interval: 1, - waitForNotesSync: true, debug: false, + waitForNotesAvailable: true, }; /** @@ -74,9 +67,6 @@ export class SentTx { * @returns The transaction receipt. */ public async wait(opts?: WaitOpts): Promise> { - if (opts?.debug && opts.waitForNotesSync === false) { - throw new Error('Cannot set debug to true if waitForNotesSync is false'); - } const receipt = await this.waitForReceipt(opts); if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) { throw new Error( @@ -89,15 +79,11 @@ export class SentTx { if (opts?.debug) { const txHash = await this.getTxHash(); const tx = (await this.pxe.getTxEffect(txHash))!; - const visibleIncomingNotes = await this.pxe.getIncomingNotes({ txHash }); - const visibleOutgoingNotes = await this.pxe.getOutgoingNotes({ txHash }); receipt.debugInfo = { noteHashes: tx.noteHashes, nullifiers: tx.nullifiers, publicDataWrites: tx.publicDataWrites, l2ToL1Msgs: tx.l2ToL1Msgs, - visibleIncomingNotes, - visibleOutgoingNotes, }; } return receipt; @@ -113,16 +99,6 @@ export class SentTx { return this.pxe.getUnencryptedLogs({ txHash: await this.getTxHash() }); } - /** - * Get notes of accounts registered in the provided PXE/Wallet created in this tx. - * @remarks This function will wait for the tx to be mined if it hasn't been already. - * @returns The requested notes. - */ - public async getVisibleNotes(): Promise { - await this.wait(); - return this.pxe.getIncomingNotes({ txHash: await this.getTxHash() }); - } - protected async waitForReceipt(opts?: WaitOpts): Promise { const txHash = await this.getTxHash(); return await retryUntil( @@ -137,15 +113,15 @@ export class SentTx { return txReceipt; } // If we don't care about waiting for notes to be synced, return the receipt - const waitForNotesSync = opts?.waitForNotesSync ?? DefaultWaitOpts.waitForNotesSync; - if (!waitForNotesSync) { + const waitForNotesAvailable = opts?.waitForNotesAvailable ?? DefaultWaitOpts.waitForNotesAvailable; + if (!waitForNotesAvailable) { return txReceipt; } // Check if all sync blocks on the PXE Service are greater or equal than the block in which the tx was mined - const { blocks, notes } = await this.pxe.getSyncStatus(); + const { blocks } = await this.pxe.getSyncStatus(); const targetBlock = txReceipt.blockNumber!; - const areNotesSynced = blocks >= targetBlock && Object.values(notes).every(block => block >= targetBlock); - return areNotesSynced ? txReceipt : undefined; + const areNotesAvailable = blocks >= targetBlock; + return areNotesAvailable ? txReceipt : undefined; }, 'isMined', opts?.timeout ?? DefaultWaitOpts.timeout, diff --git a/yarn-project/aztec.js/src/fee/public_fee_payment_method.ts b/yarn-project/aztec.js/src/fee/public_fee_payment_method.ts index 13842e361318..144e307d7ea4 100644 --- a/yarn-project/aztec.js/src/fee/public_fee_payment_method.ts +++ b/yarn-project/aztec.js/src/fee/public_fee_payment_method.ts @@ -53,9 +53,9 @@ export class PublicFeePaymentMethod implements FeePaymentMethod { { caller: this.paymentContract, action: { - name: 'transfer_public', + name: 'transfer_in_public', args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce], - selector: FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'), + selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'), type: FunctionType.PUBLIC, isStatic: false, to: this.asset, diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index 79b4fc59c26c..5adffcba01f0 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -53,7 +53,6 @@ export { generateClaimSecret, generatePublicKey, readFieldCompressedString, - waitForAccountSynch, waitForPXE, type AztecAddressLike, type EthAddressLike, @@ -112,6 +111,7 @@ export { Body, Comparator, CompleteAddress, + ContractClass2BlockL2Logs, EncryptedL2BlockL2Logs, EncryptedLogPayload, EncryptedNoteL2BlockL2Logs, diff --git a/yarn-project/aztec.js/src/utils/account.ts b/yarn-project/aztec.js/src/utils/account.ts deleted file mode 100644 index 5f11c192ede9..000000000000 --- a/yarn-project/aztec.js/src/utils/account.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { type PXE } from '@aztec/circuit-types'; -import { type CompleteAddress } from '@aztec/circuits.js'; -import { retryUntil } from '@aztec/foundation/retry'; - -import { DefaultWaitOpts, type WaitOpts } from '../contract/sent_tx.js'; - -/** - * Waits for the account to finish synchronizing with the PXE Service. - * @param pxe - PXE instance - * @param address - Address to wait for synch - * @param opts - Wait options - */ -export async function waitForAccountSynch( - pxe: PXE, - address: CompleteAddress, - { interval, timeout }: WaitOpts = DefaultWaitOpts, -): Promise { - const accountAddress = address.address.toString(); - await retryUntil( - async () => { - const status = await pxe.getSyncStatus(); - const accountSynchedToBlock = status.notes[accountAddress]; - if (typeof accountSynchedToBlock === 'undefined') { - return false; - } else { - return accountSynchedToBlock >= status.blocks; - } - }, - 'waitForAccountSynch', - timeout, - interval, - ); -} diff --git a/yarn-project/aztec.js/src/utils/index.ts b/yarn-project/aztec.js/src/utils/index.ts index 4d9c7dc39694..7a980b6ca681 100644 --- a/yarn-project/aztec.js/src/utils/index.ts +++ b/yarn-project/aztec.js/src/utils/index.ts @@ -4,7 +4,6 @@ export * from './abi_types.js'; export * from './cheat_codes.js'; export * from './authwit.js'; export * from './pxe.js'; -export * from './account.js'; export * from './anvil_test_watcher.js'; export * from './field_compressed_string.js'; export * from './portal_manager.js'; diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index 9e5156f01d22..00cc9127a389 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -21,7 +21,6 @@ import { type TxSimulationResult, type UniqueNote, } from '@aztec/circuit-types'; -import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; import { type AztecAddress, type CompleteAddress, @@ -158,6 +157,9 @@ export abstract class BaseWallet implements Wallet { getUnencryptedLogs(filter: LogFilter): Promise { return this.pxe.getUnencryptedLogs(filter); } + getContractClassLogs(filter: LogFilter): Promise { + return this.pxe.getContractClassLogs(filter); + } getBlockNumber(): Promise { return this.pxe.getBlockNumber(); } @@ -170,15 +172,9 @@ export abstract class BaseWallet implements Wallet { isGlobalStateSynchronized() { return this.pxe.isGlobalStateSynchronized(); } - isAccountStateSynchronized(account: AztecAddress) { - return this.pxe.isAccountStateSynchronized(account); - } getSyncStatus(): Promise { return this.pxe.getSyncStatus(); } - getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }> { - return this.pxe.getSyncStats(); - } addAuthWitness(authWitness: AuthWitness) { return this.pxe.addAuthWitness(authWitness); } diff --git a/yarn-project/bb-prover/package.json b/yarn-project/bb-prover/package.json index 9081ad3164e0..d0951ac373f6 100644 --- a/yarn-project/bb-prover/package.json +++ b/yarn-project/bb-prover/package.json @@ -71,6 +71,7 @@ "@aztec/noir-protocol-circuits-types": "workspace:^", "@aztec/simulator": "workspace:^", "@aztec/telemetry-client": "workspace:^", + "@aztec/world-state": "workspace:^", "@msgpack/msgpack": "^3.0.0-beta2", "@noir-lang/noirc_abi": "portal:../../noir/packages/noirc_abi", "@noir-lang/types": "portal:../../noir/packages/types", @@ -80,6 +81,7 @@ }, "devDependencies": { "@aztec/ethereum": "workspace:^", + "@aztec/kv-store": "workspace:^", "@aztec/types": "workspace:^", "@jest/globals": "^29.5.0", "@types/jest": "^29.5.0", diff --git a/yarn-project/bb-prover/src/avm_proving.test.ts b/yarn-project/bb-prover/src/avm_proving.test.ts index 60ab14974dd7..e3d7607fc820 100644 --- a/yarn-project/bb-prover/src/avm_proving.test.ts +++ b/yarn-project/bb-prover/src/avm_proving.test.ts @@ -12,6 +12,7 @@ import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr, Point } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; +import { openTmpStore } from '@aztec/kv-store/utils'; import { AvmSimulator, PublicSideEffectTrace, type WorldStateDB } from '@aztec/simulator'; import { getAvmTestContractBytecode, @@ -21,6 +22,8 @@ import { initPersistableStateManager, resolveAvmTestContractAssertionMessage, } from '@aztec/simulator/avm/fixtures'; +import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; +import { MerkleTrees } from '@aztec/world-state'; import { mock } from 'jest-mock-extended'; import fs from 'node:fs/promises'; @@ -103,7 +106,10 @@ const proveAndVerifyAvmTestContract = async ( worldStateDB.storageRead.mockResolvedValue(Promise.resolve(storageValue)); const trace = new PublicSideEffectTrace(startSideEffectCounter); - const persistableState = initPersistableStateManager({ worldStateDB, trace }); + const telemetry = new NoopTelemetryClient(); + const merkleTrees = await (await MerkleTrees.new(openTmpStore(), telemetry)).fork(); + worldStateDB.getMerkleInterface.mockReturnValue(merkleTrees); + const persistableState = initPersistableStateManager({ worldStateDB, trace, merkleTrees, doMerkleOperations: true }); const environment = initExecutionEnvironment({ functionSelector, calldata, diff --git a/yarn-project/bb-prover/tsconfig.json b/yarn-project/bb-prover/tsconfig.json index d3b184f38333..ff5ee7e225c4 100644 --- a/yarn-project/bb-prover/tsconfig.json +++ b/yarn-project/bb-prover/tsconfig.json @@ -24,12 +24,20 @@ { "path": "../telemetry-client" }, + { + "path": "../world-state" + }, { "path": "../ethereum" }, + { + "path": "../kv-store" + }, { "path": "../types" } ], - "include": ["src"] + "include": [ + "src" + ] } diff --git a/yarn-project/bot/src/bot.ts b/yarn-project/bot/src/bot.ts index f0eefb75daa4..8f3f2d659422 100644 --- a/yarn-project/bot/src/bot.ts +++ b/yarn-project/bot/src/bot.ts @@ -59,7 +59,7 @@ export class Bot { calls.push(...times(privateTransfersPerTx, () => token.methods.transfer(recipient, TRANSFER_AMOUNT).request())); calls.push( ...times(publicTransfersPerTx, () => - token.methods.transfer_public(sender, recipient, TRANSFER_AMOUNT, 0).request(), + token.methods.transfer_in_public(sender, recipient, TRANSFER_AMOUNT, 0).request(), ), ); } else { @@ -72,10 +72,8 @@ export class Bot { const opts = this.getSendMethodOpts(); const batch = new BatchCall(wallet, calls); - this.log.verbose(`Creating batch execution request with ${calls.length} calls`, logCtx); - await batch.create(opts); - this.log.verbose(`Simulating transaction`, logCtx); + this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx); await batch.simulate(); this.log.verbose(`Proving transaction`, logCtx); diff --git a/yarn-project/bot/src/factory.ts b/yarn-project/bot/src/factory.ts index e59910700e5d..b05e840fdb29 100644 --- a/yarn-project/bot/src/factory.ts +++ b/yarn-project/bot/src/factory.ts @@ -156,7 +156,7 @@ export class BotFactory { } if (isStandardToken && publicBalance < MIN_BALANCE) { this.log.info(`Minting public tokens for ${sender.toString()}`); - calls.push(token.methods.mint_public(sender, MINT_BALANCE).request()); + calls.push(token.methods.mint_to_public(sender, MINT_BALANCE).request()); } if (calls.length === 0) { this.log.info(`Skipping minting as ${sender.toString()} has enough tokens`); diff --git a/yarn-project/bot/src/utils.ts b/yarn-project/bot/src/utils.ts index 4c90afa8fba8..0bc402c6a340 100644 --- a/yarn-project/bot/src/utils.ts +++ b/yarn-project/bot/src/utils.ts @@ -23,5 +23,5 @@ export async function getPrivateBalance(token: EasyPrivateTokenContract, who: Az } export function isStandardTokenContract(token: TokenContract | EasyPrivateTokenContract): token is TokenContract { - return 'mint_public' in token.methods; + return 'mint_to_public' in token.methods; } diff --git a/yarn-project/circuit-types/src/body.ts b/yarn-project/circuit-types/src/body.ts index 283060a1af46..48617fa20161 100644 --- a/yarn-project/circuit-types/src/body.ts +++ b/yarn-project/circuit-types/src/body.ts @@ -4,7 +4,12 @@ import { computeUnbalancedMerkleRoot } from '@aztec/foundation/trees'; import { inspect } from 'util'; import { z } from 'zod'; -import { EncryptedL2BlockL2Logs, EncryptedNoteL2BlockL2Logs, UnencryptedL2BlockL2Logs } from './logs/index.js'; +import { + ContractClass2BlockL2Logs, + EncryptedL2BlockL2Logs, + EncryptedNoteL2BlockL2Logs, + UnencryptedL2BlockL2Logs, +} from './logs/index.js'; import { TxEffect } from './tx_effect.js'; export class Body { @@ -84,6 +89,12 @@ export class Body { return new UnencryptedL2BlockL2Logs(logs); } + get contractClassLogs(): ContractClass2BlockL2Logs { + const logs = this.txEffects.map(txEffect => txEffect.contractClassLogs); + + return new ContractClass2BlockL2Logs(logs); + } + /** * Computes the number of transactions in the block including padding transactions. * @dev Modified code from TxsDecoder.computeNumTxEffectsToPad diff --git a/yarn-project/circuit-types/src/interfaces/archiver.test.ts b/yarn-project/circuit-types/src/interfaces/archiver.test.ts index b0c8c4ab2b62..b6b411c31770 100644 --- a/yarn-project/circuit-types/src/interfaces/archiver.test.ts +++ b/yarn-project/circuit-types/src/interfaces/archiver.test.ts @@ -23,7 +23,7 @@ import { resolve } from 'path'; import { L2Block } from '../l2_block.js'; import { type L2Tips } from '../l2_block_source.js'; import { ExtendedUnencryptedL2Log } from '../logs/extended_unencrypted_l2_log.js'; -import { type GetUnencryptedLogsResponse, TxScopedEncryptedL2NoteLog } from '../logs/get_logs_response.js'; +import { type GetUnencryptedLogsResponse, TxScopedL2Log } from '../logs/get_logs_response.js'; import { EncryptedL2BlockL2Logs, EncryptedNoteL2BlockL2Logs, @@ -160,7 +160,7 @@ describe('ArchiverApiSchema', () => { it('getLogsByTags', async () => { const result = await context.client.getLogsByTags([Fr.random()]); - expect(result).toEqual([[expect.any(TxScopedEncryptedL2NoteLog)]]); + expect(result).toEqual([[expect.any(TxScopedL2Log)]]); }); it('getUnencryptedLogs', async () => { @@ -171,6 +171,14 @@ describe('ArchiverApiSchema', () => { expect(result).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); }); + it('getContractClassLogs', async () => { + const result = await context.client.getContractClassLogs({ + txHash: TxHash.random(), + contractAddress: AztecAddress.random(), + }); + expect(result).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); + }); + it('getPublicFunction', async () => { const selector = FunctionSelector.random(); const result = await context.client.getPublicFunction(AztecAddress.random(), selector); @@ -298,15 +306,20 @@ class MockArchiver implements ArchiverApi { throw new Error(`Unexpected log type: ${logType}`); } } - getLogsByTags(tags: Fr[]): Promise { + getLogsByTags(tags: Fr[]): Promise { expect(tags[0]).toBeInstanceOf(Fr); - return Promise.resolve([Array.from({ length: tags.length }, () => TxScopedEncryptedL2NoteLog.random())]); + return Promise.resolve([Array.from({ length: tags.length }, () => TxScopedL2Log.random())]); } getUnencryptedLogs(filter: LogFilter): Promise { expect(filter.txHash).toBeInstanceOf(TxHash); expect(filter.contractAddress).toBeInstanceOf(AztecAddress); return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); } + getContractClassLogs(filter: LogFilter): Promise { + expect(filter.txHash).toBeInstanceOf(TxHash); + expect(filter.contractAddress).toBeInstanceOf(AztecAddress); + return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); + } getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise { expect(address).toBeInstanceOf(AztecAddress); expect(selector).toBeInstanceOf(FunctionSelector); diff --git a/yarn-project/circuit-types/src/interfaces/archiver.ts b/yarn-project/circuit-types/src/interfaces/archiver.ts index b4def4dfb2bf..0dc118875aa7 100644 --- a/yarn-project/circuit-types/src/interfaces/archiver.ts +++ b/yarn-project/circuit-types/src/interfaces/archiver.ts @@ -12,7 +12,7 @@ import { z } from 'zod'; import { L2Block } from '../l2_block.js'; import { type L2BlockSource, L2TipsSchema } from '../l2_block_source.js'; -import { GetUnencryptedLogsResponseSchema, TxScopedEncryptedL2NoteLog } from '../logs/get_logs_response.js'; +import { GetUnencryptedLogsResponseSchema, TxScopedL2Log } from '../logs/get_logs_response.js'; import { L2BlockL2Logs } from '../logs/l2_block_l2_logs.js'; import { type L2LogsSource } from '../logs/l2_logs_source.js'; import { LogFilterSchema } from '../logs/log_filter.js'; @@ -56,8 +56,9 @@ export const ArchiverApiSchema: ApiSchemaFor = { getLogsByTags: z .function() .args(z.array(schemas.Fr)) - .returns(z.array(z.array(TxScopedEncryptedL2NoteLog.schema))), + .returns(z.array(z.array(TxScopedL2Log.schema))), getUnencryptedLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), + getContractClassLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), getPublicFunction: z .function() .args(schemas.AztecAddress, schemas.FunctionSelector) diff --git a/yarn-project/circuit-types/src/interfaces/aztec-node.test.ts b/yarn-project/circuit-types/src/interfaces/aztec-node.test.ts index 569ff2ae75f4..d415249c3f4b 100644 --- a/yarn-project/circuit-types/src/interfaces/aztec-node.test.ts +++ b/yarn-project/circuit-types/src/interfaces/aztec-node.test.ts @@ -30,7 +30,7 @@ import { resolve } from 'path'; import { L2Block } from '../l2_block.js'; import { ExtendedUnencryptedL2Log } from '../logs/extended_unencrypted_l2_log.js'; -import { type GetUnencryptedLogsResponse, TxScopedEncryptedL2NoteLog } from '../logs/get_logs_response.js'; +import { type GetUnencryptedLogsResponse, TxScopedL2Log } from '../logs/get_logs_response.js'; import { EncryptedL2BlockL2Logs, EncryptedNoteL2BlockL2Logs, @@ -80,9 +80,9 @@ describe('AztecNodeApiSchema', () => { expect([...tested].sort()).toEqual(all.sort()); }); - it('findLeafIndex', async () => { - const response = await context.client.findLeafIndex(1, MerkleTreeId.ARCHIVE, Fr.random()); - expect(response).toBe(1n); + it('findLeavesIndexes', async () => { + const response = await context.client.findLeavesIndexes(1, MerkleTreeId.ARCHIVE, [Fr.random(), Fr.random()]); + expect(response).toEqual([1n, undefined]); }); it('getNullifierSiblingPath', async () => { @@ -210,9 +210,14 @@ describe('AztecNodeApiSchema', () => { expect(response).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); }); + it('getContractClassLogs', async () => { + const response = await context.client.getContractClassLogs({ contractAddress: AztecAddress.random() }); + expect(response).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); + }); + it('getLogsByTags', async () => { const response = await context.client.getLogsByTags([Fr.random()]); - expect(response).toEqual([[expect.any(TxScopedEncryptedL2NoteLog)]]); + expect(response).toEqual([[expect.any(TxScopedL2Log)]]); }); it('sendTx', async () => { @@ -313,9 +318,15 @@ describe('AztecNodeApiSchema', () => { class MockAztecNode implements AztecNode { constructor(private artifact: ContractArtifact) {} - findLeafIndex(blockNumber: number | 'latest', treeId: MerkleTreeId, leafValue: Fr): Promise { - expect(leafValue).toBeInstanceOf(Fr); - return Promise.resolve(1n); + findLeavesIndexes( + blockNumber: number | 'latest', + treeId: MerkleTreeId, + leafValues: Fr[], + ): Promise<(bigint | undefined)[]> { + expect(leafValues).toHaveLength(2); + expect(leafValues[0]).toBeInstanceOf(Fr); + expect(leafValues[1]).toBeInstanceOf(Fr); + return Promise.resolve([1n, undefined]); } getNullifierSiblingPath( blockNumber: number | 'latest', @@ -444,10 +455,14 @@ class MockAztecNode implements AztecNode { expect(filter.contractAddress).toBeInstanceOf(AztecAddress); return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); } - getLogsByTags(tags: Fr[]): Promise { + getContractClassLogs(filter: LogFilter): Promise { + expect(filter.contractAddress).toBeInstanceOf(AztecAddress); + return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); + } + getLogsByTags(tags: Fr[]): Promise { expect(tags).toHaveLength(1); expect(tags[0]).toBeInstanceOf(Fr); - return Promise.resolve([[TxScopedEncryptedL2NoteLog.random()]]); + return Promise.resolve([[TxScopedL2Log.random()]]); } sendTx(tx: Tx): Promise { expect(tx).toBeInstanceOf(Tx); diff --git a/yarn-project/circuit-types/src/interfaces/aztec-node.ts b/yarn-project/circuit-types/src/interfaces/aztec-node.ts index 26c1ad731831..91b7dd8d0ca8 100644 --- a/yarn-project/circuit-types/src/interfaces/aztec-node.ts +++ b/yarn-project/circuit-types/src/interfaces/aztec-node.ts @@ -30,7 +30,7 @@ import { type LogFilter, LogFilterSchema, LogType, - TxScopedEncryptedL2NoteLog, + TxScopedL2Log, } from '../logs/index.js'; import { MerkleTreeId } from '../merkle_tree_id.js'; import { EpochProofQuote } from '../prover_coordination/epoch_proof_quote.js'; @@ -50,13 +50,17 @@ import { type ProverCoordination, ProverCoordinationApiSchema } from './prover-c */ export interface AztecNode extends ProverCoordination { /** - * Find the index of the given leaf in the given tree. + * Find the indexes of the given leaves in the given tree. * @param blockNumber - The block number at which to get the data or 'latest' for latest data * @param treeId - The tree to search in. - * @param leafValue - The value to search for - * @returns The index of the given leaf in the given tree or undefined if not found. + * @param leafValue - The values to search for + * @returns The indexes of the given leaves in the given tree or undefined if not found. */ - findLeafIndex(blockNumber: L2BlockNumber, treeId: MerkleTreeId, leafValue: Fr): Promise; + findLeavesIndexes( + blockNumber: L2BlockNumber, + treeId: MerkleTreeId, + leafValues: Fr[], + ): Promise<(bigint | undefined)[]>; /** * Returns a sibling path for the given index in the nullifier tree. @@ -257,13 +261,20 @@ export interface AztecNode extends ProverCoordination { */ getUnencryptedLogs(filter: LogFilter): Promise; + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise; + /** * Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag). * @param tags - The tags to filter the logs by. * @returns For each received tag, an array of matching logs and metadata (e.g. tx hash) is returned. An empty array implies no logs match that tag. */ - getLogsByTags(tags: Fr[]): Promise; + getLogsByTags(tags: Fr[]): Promise; /** * Method to submit a transaction to the p2p pool. @@ -385,10 +396,10 @@ export interface AztecNode extends ProverCoordination { export const AztecNodeApiSchema: ApiSchemaFor = { ...ProverCoordinationApiSchema, - findLeafIndex: z + findLeavesIndexes: z .function() - .args(L2BlockNumberSchema, z.nativeEnum(MerkleTreeId), schemas.Fr) - .returns(schemas.BigInt.optional()), + .args(L2BlockNumberSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.Fr)) + .returns(z.array(optional(schemas.BigInt))), getNullifierSiblingPath: z .function() @@ -463,10 +474,12 @@ export const AztecNodeApiSchema: ApiSchemaFor = { getUnencryptedLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), + getContractClassLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), + getLogsByTags: z .function() .args(z.array(schemas.Fr)) - .returns(z.array(z.array(TxScopedEncryptedL2NoteLog.schema))), + .returns(z.array(z.array(TxScopedL2Log.schema))), sendTx: z.function().args(Tx.schema).returns(z.void()), diff --git a/yarn-project/circuit-types/src/interfaces/pxe.test.ts b/yarn-project/circuit-types/src/interfaces/pxe.test.ts index 797c183df2f3..8aefa059edb3 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.test.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.test.ts @@ -22,6 +22,7 @@ import { type JsonRpcTestContext, createJsonRpcTestSetup } from '@aztec/foundati import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; +import { jest } from '@jest/globals'; import { deepStrictEqual } from 'assert'; import { readFileSync } from 'fs'; import omit from 'lodash.omit'; @@ -36,13 +37,14 @@ import { ExtendedNote, type OutgoingNotesFilter, UniqueNote } from '../notes/ind import { PrivateExecutionResult } from '../private_execution_result.js'; import { type EpochProofQuote } from '../prover_coordination/epoch_proof_quote.js'; import { SiblingPath } from '../sibling_path/sibling_path.js'; -import { type NoteProcessorStats } from '../stats/stats.js'; import { Tx, TxHash, TxProvingResult, TxReceipt, TxSimulationResult } from '../tx/index.js'; import { TxEffect } from '../tx_effect.js'; import { TxExecutionRequest } from '../tx_execution_request.js'; import { type EventMetadataDefinition, type PXE, type PXEInfo, PXESchema } from './pxe.js'; import { type SyncStatus } from './sync-status.js'; +jest.setTimeout(12_000); + describe('PXESchema', () => { let handler: MockPXE; let context: JsonRpcTestContext; @@ -223,6 +225,11 @@ describe('PXESchema', () => { expect(result).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); }); + it('getContractClassLogs', async () => { + const result = await context.client.getContractClassLogs({ contractAddress: address }); + expect(result).toEqual({ logs: [expect.any(ExtendedUnencryptedL2Log)], maxLogsHit: true }); + }); + it('getBlockNumber', async () => { const result = await context.client.getBlockNumber(); expect(result).toBe(1); @@ -248,21 +255,11 @@ describe('PXESchema', () => { expect(result).toBe(true); }); - it('isAccountStateSynchronized', async () => { - const result = await context.client.isAccountStateSynchronized(address); - expect(result).toBe(true); - }); - it('getSyncStatus', async () => { const result = await context.client.getSyncStatus(); expect(result).toEqual(await handler.getSyncStatus()); }); - it('getSyncStats', async () => { - const result = await context.client.getSyncStats(); - expect(result).toEqual(await handler.getSyncStats()); - }); - it('getContractInstance', async () => { const result = await context.client.getContractInstance(address); expect(result).toEqual(instance); @@ -459,6 +456,10 @@ class MockPXE implements PXE { expect(filter.contractAddress).toEqual(this.address); return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); } + getContractClassLogs(filter: LogFilter): Promise { + expect(filter.contractAddress).toEqual(this.address); + return Promise.resolve({ logs: [ExtendedUnencryptedL2Log.random()], maxLogsHit: true }); + } getBlockNumber(): Promise { return Promise.resolve(1); } @@ -492,28 +493,9 @@ class MockPXE implements PXE { isGlobalStateSynchronized(): Promise { return Promise.resolve(true); } - isAccountStateSynchronized(account: AztecAddress): Promise { - expect(account).toEqual(this.address); - return Promise.resolve(true); - } getSyncStatus(): Promise { return Promise.resolve({ blocks: 1, - notes: { [this.address.toString()]: 1 }, - }); - } - getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }> { - return Promise.resolve({ - [this.address.toString()]: { - seen: 1, - deferredIncoming: 1, - deferredOutgoing: 1, - decryptedIncoming: 1, - decryptedOutgoing: 1, - failed: 1, - blocks: 1, - txs: 1, - }, }); } getContractInstance(address: AztecAddress): Promise { diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 98554237072a..4bfa62f74bbd 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -38,7 +38,6 @@ import { type IncomingNotesFilter, IncomingNotesFilterSchema } from '../notes/in import { ExtendedNote, type OutgoingNotesFilter, OutgoingNotesFilterSchema, UniqueNote } from '../notes/index.js'; import { PrivateExecutionResult } from '../private_execution_result.js'; import { SiblingPath } from '../sibling_path/sibling_path.js'; -import { type NoteProcessorStats, NoteProcessorStatsSchema } from '../stats/stats.js'; import { Tx, TxHash, TxProvingResult, TxReceipt, TxSimulationResult } from '../tx/index.js'; import { TxEffect } from '../tx_effect.js'; import { TxExecutionRequest } from '../tx_execution_request.js'; @@ -313,6 +312,13 @@ export interface PXE { */ getUnencryptedLogs(filter: LogFilter): Promise; + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise; + /** * Fetches the current block number. * @returns The block number. @@ -345,17 +351,6 @@ export interface PXE { */ isGlobalStateSynchronized(): Promise; - /** - * Checks if the specified account is synchronized. - * @param account - The aztec address for which to query the sync status. - * @returns True if the account is fully synched, false otherwise. - * @deprecated Use `getSyncStatus` instead. - * @remarks Checks whether all the notes from all the blocks have been processed. If it is not the case, the - * retrieved information from contracts might be old/stale (e.g. old token balance). - * @throws If checking a sync status of account which is not registered. - */ - isAccountStateSynchronized(account: AztecAddress): Promise; - /** * Returns the latest block that has been synchronized globally and for each account. The global block number * indicates whether global state has been updated up to that block, whereas each address indicates up to which @@ -364,12 +359,6 @@ export interface PXE { */ getSyncStatus(): Promise; - /** - * Returns the note processor stats. - * @returns The note processor stats for notes for each public key being tracked. - */ - getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }>; - /** * Returns a Contract Instance given its address, which includes the contract class identifier, * initialization hash, deployment salt, and public keys hash. @@ -536,14 +525,13 @@ export const PXESchema: ApiSchemaFor = { ) .returns(AbiDecodedSchema), getUnencryptedLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), + getContractClassLogs: z.function().args(LogFilterSchema).returns(GetUnencryptedLogsResponseSchema), getBlockNumber: z.function().returns(z.number()), getProvenBlockNumber: z.function().returns(z.number()), getNodeInfo: z.function().returns(NodeInfoSchema), getPXEInfo: z.function().returns(PXEInfoSchema), isGlobalStateSynchronized: z.function().returns(z.boolean()), - isAccountStateSynchronized: z.function().args(schemas.AztecAddress).returns(z.boolean()), getSyncStatus: z.function().returns(SyncStatusSchema), - getSyncStats: z.function().returns(z.record(NoteProcessorStatsSchema)), getContractInstance: z .function() .args(schemas.AztecAddress) diff --git a/yarn-project/circuit-types/src/interfaces/sync-status.ts b/yarn-project/circuit-types/src/interfaces/sync-status.ts index 59696232b5d6..b85a13620d6b 100644 --- a/yarn-project/circuit-types/src/interfaces/sync-status.ts +++ b/yarn-project/circuit-types/src/interfaces/sync-status.ts @@ -6,11 +6,8 @@ import { z } from 'zod'; export type SyncStatus = { /** Up to which block has been synched for blocks and txs. */ blocks: number; - /** Up to which block has been synched for notes, indexed by each account address being monitored. */ - notes: Record; }; export const SyncStatusSchema = z.object({ blocks: z.number(), - notes: z.record(z.number()), }) satisfies ZodFor; diff --git a/yarn-project/circuit-types/src/l2_block.ts b/yarn-project/circuit-types/src/l2_block.ts index f889a0148cb8..bf5f8bffe330 100644 --- a/yarn-project/circuit-types/src/l2_block.ts +++ b/yarn-project/circuit-types/src/l2_block.ts @@ -224,6 +224,14 @@ export class L2Block { (logCount, txEffect) => logCount + txEffect.unencryptedLogs.getSerializedLength(), 0, ), + contractClassLogCount: this.body.txEffects.reduce( + (logCount, txEffect) => logCount + txEffect.contractClassLogs.getTotalLogCount(), + 0, + ), + contractClassLogSize: this.body.txEffects.reduce( + (logCount, txEffect) => logCount + txEffect.contractClassLogs.getSerializedLength(), + 0, + ), }; return { diff --git a/yarn-project/circuit-types/src/logs/get_logs_response.test.ts b/yarn-project/circuit-types/src/logs/get_logs_response.test.ts new file mode 100644 index 000000000000..8ec54978a648 --- /dev/null +++ b/yarn-project/circuit-types/src/logs/get_logs_response.test.ts @@ -0,0 +1,10 @@ +import { jsonStringify } from '@aztec/foundation/json-rpc'; + +import { TxScopedL2Log } from './get_logs_response.js'; + +describe('TxScopedL2Log', () => { + it('serializes to JSON', () => { + const log = TxScopedL2Log.random(); + expect(TxScopedL2Log.schema.parse(JSON.parse(jsonStringify(log)))).toEqual(log); + }); +}); diff --git a/yarn-project/circuit-types/src/logs/get_logs_response.ts b/yarn-project/circuit-types/src/logs/get_logs_response.ts index 61df2d208bb8..c62b5af965c2 100644 --- a/yarn-project/circuit-types/src/logs/get_logs_response.ts +++ b/yarn-project/circuit-types/src/logs/get_logs_response.ts @@ -1,11 +1,10 @@ import { Fr } from '@aztec/circuits.js'; -import { type ZodFor } from '@aztec/foundation/schemas'; -import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize'; +import { type ZodFor, schemas } from '@aztec/foundation/schemas'; +import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize'; import { z } from 'zod'; import { TxHash } from '../tx/tx_hash.js'; -import { EncryptedL2NoteLog } from './encrypted_l2_note_log.js'; import { ExtendedUnencryptedL2Log } from './extended_unencrypted_l2_log.js'; /** Response for the getUnencryptedLogs archiver call. */ @@ -21,7 +20,7 @@ export const GetUnencryptedLogsResponseSchema = z.object({ maxLogsHit: z.boolean(), }) satisfies ZodFor; -export class TxScopedEncryptedL2NoteLog { +export class TxScopedL2Log { constructor( /* * Hash of the tx where the log is included @@ -33,9 +32,17 @@ export class TxScopedEncryptedL2NoteLog { */ public dataStartIndexForTx: number, /* - * The encrypted note log + * The block this log is included in */ - public log: EncryptedL2NoteLog, + public blockNumber: number, + /* + * Indicates if the log comes from the unencrypted logs stream (partial note) + */ + public isFromPublic: boolean, + /* + * The log data + */ + public logData: Buffer, ) {} static get schema() { @@ -43,27 +50,38 @@ export class TxScopedEncryptedL2NoteLog { .object({ txHash: TxHash.schema, dataStartIndexForTx: z.number(), - log: EncryptedL2NoteLog.schema, + blockNumber: z.number(), + isFromPublic: z.boolean(), + logData: schemas.BufferB64, }) .transform( - ({ txHash, dataStartIndexForTx, log }) => new TxScopedEncryptedL2NoteLog(txHash, dataStartIndexForTx, log), + ({ txHash, dataStartIndexForTx, blockNumber, isFromPublic, logData }) => + new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, isFromPublic, logData), ); } toBuffer() { - return Buffer.concat([this.txHash.toBuffer(), numToUInt32BE(this.dataStartIndexForTx), this.log.toBuffer()]); + return Buffer.concat([ + this.txHash.toBuffer(), + numToUInt32BE(this.dataStartIndexForTx), + numToUInt32BE(this.blockNumber), + boolToBuffer(this.isFromPublic), + this.logData, + ]); } static fromBuffer(buffer: Buffer) { const reader = BufferReader.asReader(buffer); - return new TxScopedEncryptedL2NoteLog( + return new TxScopedL2Log( TxHash.fromField(reader.readObject(Fr)), reader.readNumber(), - EncryptedL2NoteLog.fromBuffer(reader.readToEnd()), + reader.readNumber(), + reader.readBoolean(), + reader.readToEnd(), ); } static random() { - return new TxScopedEncryptedL2NoteLog(TxHash.random(), 1, EncryptedL2NoteLog.random()); + return new TxScopedL2Log(TxHash.random(), 1, 1, false, Fr.random().toBuffer()); } } diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts index 7a34d2062214..9560fb54ddde 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts @@ -115,17 +115,15 @@ describe('EncryptedLogPayload', () => { ); // We set a random secret, as it is simply the result of an oracle call, and we are not actually computing this in nr. - const logTag = new IndexedTaggingSecret( - new Fr(69420), + const logTag = new IndexedTaggingSecret(new Fr(69420), 1337).computeTag( AztecAddress.fromBigInt(0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70cn), - 1337, - ).computeTag(); + ); const tagString = logTag.toString().slice(2); let byteArrayString = `[${tagString.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))}]`; updateInlineTestData( 'noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr', - 'tag_from_typescript', + 'encrypted_log_from_typescript', byteArrayString, ); diff --git a/yarn-project/circuit-types/src/logs/l2_block_l2_logs.test.ts b/yarn-project/circuit-types/src/logs/l2_block_l2_logs.test.ts index 540e118b99f3..41ea8c0eee84 100644 --- a/yarn-project/circuit-types/src/logs/l2_block_l2_logs.test.ts +++ b/yarn-project/circuit-types/src/logs/l2_block_l2_logs.test.ts @@ -2,17 +2,25 @@ import { jsonStringify } from '@aztec/foundation/json-rpc'; import { L2BlockL2Logs as BaseL2BlockL2Logs, + ContractClass2BlockL2Logs, EncryptedL2BlockL2Logs, EncryptedNoteL2BlockL2Logs, UnencryptedL2BlockL2Logs, } from './l2_block_l2_logs.js'; function shouldBehaveLikeL2BlockL2Logs( - L2BlockL2Logs: typeof EncryptedNoteL2BlockL2Logs | typeof UnencryptedL2BlockL2Logs | typeof EncryptedL2BlockL2Logs, + L2BlockL2Logs: + | typeof EncryptedNoteL2BlockL2Logs + | typeof UnencryptedL2BlockL2Logs + | typeof EncryptedL2BlockL2Logs + | typeof ContractClass2BlockL2Logs, ) { describe(L2BlockL2Logs.name, () => { it('can encode L2Logs to buffer and back', () => { - const l2Logs = L2BlockL2Logs.random(3, 4, 2); + const l2Logs = + L2BlockL2Logs.name == 'ContractClass2BlockL2Logs' + ? L2BlockL2Logs.random(3, 1, 1) + : L2BlockL2Logs.random(3, 4, 2); const buffer = l2Logs.toBuffer(); const recovered = L2BlockL2Logs.fromBuffer(buffer); @@ -21,7 +29,10 @@ function shouldBehaveLikeL2BlockL2Logs( }); it('getSerializedLength returns the correct length', () => { - const l2Logs = L2BlockL2Logs.random(3, 4, 2); + const l2Logs = + L2BlockL2Logs.name == 'ContractClass2BlockL2Logs' + ? L2BlockL2Logs.random(3, 1, 1) + : L2BlockL2Logs.random(3, 4, 2); const buffer = l2Logs.toBuffer(); const recovered = L2BlockL2Logs.fromBuffer(buffer); @@ -35,7 +46,10 @@ function shouldBehaveLikeL2BlockL2Logs( }); it('serializes to and from JSON via fromJSON', () => { - const l2Logs = L2BlockL2Logs.random(3, 4, 2); + const l2Logs = + L2BlockL2Logs.name == 'ContractClass2BlockL2Logs' + ? L2BlockL2Logs.random(3, 1, 1) + : L2BlockL2Logs.random(3, 4, 2); const json = jsonStringify(l2Logs); const recovered = L2BlockL2Logs.fromJSON(JSON.parse(json)); expect(recovered).toEqual(l2Logs); @@ -43,7 +57,10 @@ function shouldBehaveLikeL2BlockL2Logs( }); it('serializes to and from JSON via schema', () => { - const l2Logs = L2BlockL2Logs.random(3, 4, 2); + const l2Logs = + L2BlockL2Logs.name == 'ContractClass2BlockL2Logs' + ? L2BlockL2Logs.random(3, 1, 1) + : L2BlockL2Logs.random(3, 4, 2); const json = jsonStringify(l2Logs); const recovered = BaseL2BlockL2Logs.schema.parse(JSON.parse(json)); expect(recovered).toEqual(l2Logs); @@ -55,3 +72,4 @@ function shouldBehaveLikeL2BlockL2Logs( shouldBehaveLikeL2BlockL2Logs(EncryptedNoteL2BlockL2Logs); shouldBehaveLikeL2BlockL2Logs(UnencryptedL2BlockL2Logs); shouldBehaveLikeL2BlockL2Logs(EncryptedL2BlockL2Logs); +shouldBehaveLikeL2BlockL2Logs(ContractClass2BlockL2Logs); diff --git a/yarn-project/circuit-types/src/logs/l2_block_l2_logs.ts b/yarn-project/circuit-types/src/logs/l2_block_l2_logs.ts index 9d8580414606..2698fc2fc12b 100644 --- a/yarn-project/circuit-types/src/logs/l2_block_l2_logs.ts +++ b/yarn-project/circuit-types/src/logs/l2_block_l2_logs.ts @@ -6,7 +6,13 @@ import { z } from 'zod'; import { type EncryptedL2Log } from './encrypted_l2_log.js'; import { type EncryptedL2NoteLog } from './encrypted_l2_note_log.js'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, type TxL2Logs, UnencryptedTxL2Logs } from './tx_l2_logs.js'; +import { + ContractClassTxL2Logs, + EncryptedNoteTxL2Logs, + EncryptedTxL2Logs, + type TxL2Logs, + UnencryptedTxL2Logs, +} from './tx_l2_logs.js'; import { type UnencryptedL2Log } from './unencrypted_l2_log.js'; /** @@ -26,7 +32,12 @@ export abstract class L2BlockL2Logs | L2BlockL2Logs | L2BlockL2Logs > { // TODO(palla/schemas): This should be a discriminated union, but the compiler refuses - return z.union([EncryptedNoteL2BlockL2Logs.schema, EncryptedL2BlockL2Logs.schema, UnencryptedL2BlockL2Logs.schema]); + return z.union([ + EncryptedNoteL2BlockL2Logs.schema, + EncryptedL2BlockL2Logs.schema, + UnencryptedL2BlockL2Logs.schema, + ContractClass2BlockL2Logs.schema, + ]); } /** @@ -333,3 +344,86 @@ export class UnencryptedL2BlockL2Logs extends L2BlockL2Logs { return logs; } } + +export class ContractClass2BlockL2Logs extends L2BlockL2Logs { + // This class is identical in methods to UnencryptedL2BlockL2Logs, but its + // consistuent ContractClassTxL2Logs must be treated differently, hence new class. + static override get schema() { + return z + .object({ type: z.literal('ContractClass'), txLogs: z.array(ContractClassTxL2Logs.schema) }) + .transform(({ txLogs }) => new ContractClass2BlockL2Logs(txLogs)); + } + + public get type() { + return 'ContractClass'; + } + + /** + * Convert a plain JSON object to a L2BlockL2Logs class object. + * @param obj - A plain L2BlockL2Logs JSON object. + * @returns A L2BlockL2Logs class object. + */ + public static fromJSON(obj: any) { + const txLogs = obj.txLogs.map((log: any) => ContractClassTxL2Logs.fromJSON(log)); + return new ContractClass2BlockL2Logs(txLogs); + } + + /** + * Deserializes logs from a buffer. + * @param buffer - The buffer containing the serialized logs. + * @returns A new `L2BlockL2Logs` object. + */ + public static fromBuffer(buffer: Buffer | BufferReader): ContractClass2BlockL2Logs { + const reader = BufferReader.asReader(buffer); + + const logsBufLength = reader.readNumber(); + const serializedTxLogs = reader.readBufferArray(logsBufLength); + + const txLogs = serializedTxLogs.map(logs => ContractClassTxL2Logs.fromBuffer(logs, false)); + return new ContractClass2BlockL2Logs(txLogs); + } + + /** + * Deserializes logs from a string. + * @param data - The string containing the serialized logs. + * @returns A new `L2BlockL2Logs` object. + */ + public static fromString(data: string): ContractClass2BlockL2Logs { + const buffer = Buffer.from(data, 'hex'); + return ContractClass2BlockL2Logs.fromBuffer(buffer); + } + + /** + * Creates a new `L2BlockL2Logs` object with `numCalls` function logs and `numLogsPerCall` logs in each function + * call. + * @param numTxs - The number of txs in the block. + * @param numCalls - The number of function calls in the tx. + * @param numLogsPerCall - The number of logs emitted in each function call. + * @param logType - The type of logs to generate. + * @returns A new `L2BlockL2Logs` object. + */ + public static random(numTxs: number, numCalls: number, numLogsPerCall: number): ContractClass2BlockL2Logs { + const txLogs: ContractClassTxL2Logs[] = []; + for (let i = 0; i < numTxs; i++) { + txLogs.push(ContractClassTxL2Logs.random(numCalls, numLogsPerCall)); + } + return new ContractClass2BlockL2Logs(txLogs); + } + + /** + * Unrolls logs from a set of blocks. + * @param blockLogs - Input logs from a set of blocks. + * @returns Unrolled logs. + */ + public static unrollLogs(blockLogs: (ContractClass2BlockL2Logs | undefined)[]): UnencryptedL2Log[] { + const logs: UnencryptedL2Log[] = []; + for (const blockLog of blockLogs) { + if (blockLog) { + for (const txLog of blockLog.txLogs) { + logs.push(...txLog.unrollLogs()); + } + } + } + return logs; + } +} diff --git a/yarn-project/circuit-types/src/logs/l2_logs_source.ts b/yarn-project/circuit-types/src/logs/l2_logs_source.ts index 07ebcfd8eb72..804130711e48 100644 --- a/yarn-project/circuit-types/src/logs/l2_logs_source.ts +++ b/yarn-project/circuit-types/src/logs/l2_logs_source.ts @@ -1,6 +1,6 @@ import { type Fr } from '@aztec/circuits.js'; -import { type GetUnencryptedLogsResponse, type TxScopedEncryptedL2NoteLog } from './get_logs_response.js'; +import { type GetUnencryptedLogsResponse, type TxScopedL2Log } from './get_logs_response.js'; import { type L2BlockL2Logs } from './l2_block_l2_logs.js'; import { type LogFilter } from './log_filter.js'; import { type FromLogType, type LogType } from './log_type.js'; @@ -28,7 +28,7 @@ export interface L2LogsSource { * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match * that tag. */ - getLogsByTags(tags: Fr[]): Promise; + getLogsByTags(tags: Fr[]): Promise; /** * Gets unencrypted logs based on the provided filter. @@ -37,6 +37,13 @@ export interface L2LogsSource { */ getUnencryptedLogs(filter: LogFilter): Promise; + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + getContractClassLogs(filter: LogFilter): Promise; + /** * Gets the number of the latest L2 block processed by the implementation. * @returns The number of the latest L2 block processed by the implementation. diff --git a/yarn-project/circuit-types/src/logs/tx_l2_logs.test.ts b/yarn-project/circuit-types/src/logs/tx_l2_logs.test.ts index 61ea3137a8e1..5fd7831ebe5d 100644 --- a/yarn-project/circuit-types/src/logs/tx_l2_logs.test.ts +++ b/yarn-project/circuit-types/src/logs/tx_l2_logs.test.ts @@ -1,13 +1,17 @@ import { jsonStringify } from '@aztec/foundation/json-rpc'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from './tx_l2_logs.js'; +import { ContractClassTxL2Logs, EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from './tx_l2_logs.js'; function shouldBehaveLikeTxL2Logs( - TxL2Logs: typeof EncryptedNoteTxL2Logs | typeof UnencryptedTxL2Logs | typeof EncryptedTxL2Logs, + TxL2Logs: + | typeof EncryptedNoteTxL2Logs + | typeof UnencryptedTxL2Logs + | typeof EncryptedTxL2Logs + | typeof ContractClassTxL2Logs, ) { describe(TxL2Logs.name, () => { it('can encode TxL2Logs to buffer and back', () => { - const l2Logs = TxL2Logs.random(4, 2); + const l2Logs = TxL2Logs.name == 'ContractClassTxL2Logs' ? TxL2Logs.random(1, 1) : TxL2Logs.random(4, 2); const buffer = l2Logs.toBuffer(); const recovered = TxL2Logs.fromBuffer(buffer); @@ -16,7 +20,7 @@ function shouldBehaveLikeTxL2Logs( }); it('can encode TxL2Logs to JSON and back', () => { - const l2Logs = TxL2Logs.random(4, 2); + const l2Logs = TxL2Logs.name == 'ContractClassTxL2Logs' ? TxL2Logs.random(1, 1) : TxL2Logs.random(4, 2); const buffer = jsonStringify(l2Logs.toJSON()); const recovered = TxL2Logs.fromJSON(JSON.parse(buffer)); @@ -25,7 +29,7 @@ function shouldBehaveLikeTxL2Logs( }); it('getSerializedLength returns the correct length', () => { - const l2Logs = TxL2Logs.random(4, 2); + const l2Logs = TxL2Logs.name == 'ContractClassTxL2Logs' ? TxL2Logs.random(1, 1) : TxL2Logs.random(4, 2); const buffer = l2Logs.toBuffer(); const recovered = TxL2Logs.fromBuffer(buffer); @@ -39,7 +43,7 @@ function shouldBehaveLikeTxL2Logs( }); it('getKernelLength returns the correct length', () => { - const l2Logs = TxL2Logs.random(4, 2); + const l2Logs = TxL2Logs.name == 'ContractClassTxL2Logs' ? TxL2Logs.random(1, 1) : TxL2Logs.random(4, 2); const expectedLength = l2Logs.functionLogs.map(l => l.getKernelLength()).reduce((a, b) => a + b, 0); @@ -51,3 +55,4 @@ function shouldBehaveLikeTxL2Logs( shouldBehaveLikeTxL2Logs(EncryptedNoteTxL2Logs); shouldBehaveLikeTxL2Logs(UnencryptedTxL2Logs); shouldBehaveLikeTxL2Logs(EncryptedTxL2Logs); +shouldBehaveLikeTxL2Logs(ContractClassTxL2Logs); diff --git a/yarn-project/circuit-types/src/logs/tx_l2_logs.ts b/yarn-project/circuit-types/src/logs/tx_l2_logs.ts index 6ffd7cbc5dcb..afa1f7157528 100644 --- a/yarn-project/circuit-types/src/logs/tx_l2_logs.ts +++ b/yarn-project/circuit-types/src/logs/tx_l2_logs.ts @@ -1,6 +1,7 @@ import { Fr, type LogHash, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, @@ -135,7 +136,7 @@ export abstract class TxL2Logs { return sha256Trunc(allSiloedLogHashes); } } + +export class ContractClassTxL2Logs extends TxL2Logs { + static get schema() { + return z + .object({ functionLogs: z.array(UnencryptedFunctionL2Logs.schema) }) + .transform(({ functionLogs }) => new ContractClassTxL2Logs(functionLogs)); + } + + /** Creates an empty instance. */ + public static empty() { + return new ContractClassTxL2Logs([]); + } + + /** + * Deserializes logs from a buffer. + * @param buf - The buffer containing the serialized logs. + * @param isLengthPrefixed - Whether the buffer is prefixed with 4 bytes for its total length. + * @returns A new L2Logs object. + */ + public static fromBuffer(buf: Buffer | BufferReader, isLengthPrefixed = true): ContractClassTxL2Logs { + const reader = BufferReader.asReader(buf); + + // If the buffer is length prefixed use the length to read the array. Otherwise, the entire buffer is consumed. + const logsBufLength = isLengthPrefixed ? reader.readNumber() : -1; + const serializedFunctionLogs = reader.readBufferArray(logsBufLength); + + const functionLogs = serializedFunctionLogs.map(logs => UnencryptedFunctionL2Logs.fromBuffer(logs, false)); + return new ContractClassTxL2Logs(functionLogs); + } + + /** + * Creates a new `TxL2Logs` object with `numCalls` function logs and `numLogsPerCall` logs in each invocation. + * @param numCalls - The number of function calls in the tx. + * @param numLogsPerCall - The number of logs emitted in each function call. + * @param logType - The type of logs to generate. + * @returns A new `TxL2Logs` object. + */ + public static random(numCalls: number, numLogsPerCall: number): ContractClassTxL2Logs { + if (numCalls * numLogsPerCall > MAX_CONTRACT_CLASS_LOGS_PER_TX) { + throw new Error( + `Trying to create ${numCalls * numLogsPerCall} logs for one tx (max: ${MAX_CONTRACT_CLASS_LOGS_PER_TX})`, + ); + } + const functionLogs: UnencryptedFunctionL2Logs[] = []; + for (let i = 0; i < numCalls; i++) { + functionLogs.push(UnencryptedFunctionL2Logs.random(numLogsPerCall)); + } + return new ContractClassTxL2Logs(functionLogs); + } + + /** + * Convert a plain JSON object to a TxL2Logs class object. + * @param obj - A plain TxL2Logs JSON object. + * @returns A TxL2Logs class object. + */ + public static fromJSON(obj: any) { + const functionLogs = obj.functionLogs.map((log: any) => UnencryptedFunctionL2Logs.fromJSON(log)); + return new ContractClassTxL2Logs(functionLogs); + } + + /** + * @param logs - Logs to be hashed. + * @returns The hash of the logs. + * Note: This is a TS implementation of `computeKernelUnencryptedLogsHash` function in Decoder.sol. See that function documentation + * for more details. + */ + public override hash(): Buffer { + const unrolledLogs = this.unrollLogs(); + return ContractClassTxL2Logs.hashSiloedLogs(unrolledLogs.map(log => log.getSiloedHash())); + } + + /** + * Hashes siloed contract class logs as in the same way as the base rollup would. + * @param siloedLogHashes - The siloed log hashes + * @returns The hash of the logs. + */ + public static hashSiloedLogs(siloedLogHashes: Buffer[]): Buffer { + if (siloedLogHashes.length == 0) { + return Buffer.alloc(32); + } + + let allSiloedLogHashes = Buffer.alloc(0); + for (const siloedLogHash of siloedLogHashes) { + allSiloedLogHashes = Buffer.concat([allSiloedLogHashes, siloedLogHash]); + } + // pad the end of logs with 0s + for (let i = 0; i < MAX_CONTRACT_CLASS_LOGS_PER_TX - siloedLogHashes.length; i++) { + allSiloedLogHashes = Buffer.concat([allSiloedLogHashes, Buffer.alloc(32)]); + } + + return sha256Trunc(allSiloedLogHashes); + } +} diff --git a/yarn-project/circuit-types/src/messaging/l1_to_l2_message.ts b/yarn-project/circuit-types/src/messaging/l1_to_l2_message.ts index 6d8ada947b96..e68a73a83e8e 100644 --- a/yarn-project/circuit-types/src/messaging/l1_to_l2_message.ts +++ b/yarn-project/circuit-types/src/messaging/l1_to_l2_message.ts @@ -87,7 +87,7 @@ export async function getNonNullifiedL1ToL2MessageWitness( const messageNullifier = computeL1ToL2MessageNullifier(contractAddress, messageHash, secret); - const nullifierIndex = await node.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, messageNullifier); + const [nullifierIndex] = await node.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [messageNullifier]); if (nullifierIndex !== undefined) { throw new Error(`No non-nullified L1 to L2 message found for message hash ${messageHash.toString()}`); } diff --git a/yarn-project/circuit-types/src/mocks.ts b/yarn-project/circuit-types/src/mocks.ts index 92e56a2553d3..7b4a3f13ffdc 100644 --- a/yarn-project/circuit-types/src/mocks.ts +++ b/yarn-project/circuit-types/src/mocks.ts @@ -9,7 +9,6 @@ import { MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, Nullifier, PartialPrivateTailPublicInputsForPublic, PrivateCircuitPublicInputs, @@ -24,13 +23,18 @@ import { import { computeVarArgsHash } from '@aztec/circuits.js/hash'; import { makeCombinedConstantData, makeGas, makePublicCallRequest } from '@aztec/circuits.js/testing'; import { type ContractArtifact, NoteSelector } from '@aztec/foundation/abi'; -import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd, times } from '@aztec/foundation/collection'; import { randomBigInt, randomBytes, randomInt } from '@aztec/foundation/crypto'; import { Signature } from '@aztec/foundation/eth-signature'; import { Fr } from '@aztec/foundation/fields'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, Note, UnencryptedTxL2Logs } from './logs/index.js'; +import { + ContractClassTxL2Logs, + EncryptedNoteTxL2Logs, + EncryptedTxL2Logs, + Note, + UnencryptedTxL2Logs, +} from './logs/index.js'; import { ExtendedNote, UniqueNote } from './notes/index.js'; import { CountedLog, CountedPublicExecutionRequest, PrivateExecutionResult } from './private_execution_result.js'; import { EpochProofQuote } from './prover_coordination/epoch_proof_quote.js'; @@ -89,7 +93,7 @@ export const mockPrivateExecutionResult = ( .map((log, index) => new CountedLog(log, index)) : [], hasLogs - ? UnencryptedTxL2Logs.random(2, 3) + ? ContractClassTxL2Logs.random(1, 1) .unrollLogs() .map((log, index) => new CountedLog(log, index)) : [], @@ -121,7 +125,7 @@ export const mockTx = ( const firstNullifier = new Nullifier(new Fr(seed + 1), 0, Fr.ZERO); const noteEncryptedLogs = EncryptedNoteTxL2Logs.empty(); // Mock seems to have no new notes => no note logs const encryptedLogs = hasLogs ? EncryptedTxL2Logs.random(2, 3) : EncryptedTxL2Logs.empty(); // 2 priv function invocations creating 3 encrypted logs each - const unencryptedLogs = hasLogs ? UnencryptedTxL2Logs.random(2, 1) : UnencryptedTxL2Logs.empty(); // 2 priv function invocations creating 1 unencrypted log each + const contractClassLog = hasLogs ? ContractClassTxL2Logs.random(1, 1) : ContractClassTxL2Logs.empty(); data.constants.txContext.gasSettings = GasSettings.default(); data.feePayer = feePayer; @@ -186,31 +190,20 @@ export const mockTx = ( }); functionCount++; }); - nonRevertibleIndex = 0; - revertibleIndex = 0; - functionCount = 0; - unencryptedLogs.functionLogs.forEach(functionLog => { - functionLog.logs.forEach(log => { - if (data.forPublic) { - const hash = new ScopedLogHash( - new LogHash( - Fr.fromBuffer(log.hash()), - i++, - // +4 for encoding the length of the buffer - new Fr(log.length + 4), - ), - log.contractAddress, - ); - // make the first log non-revertible - if (functionCount === 0) { - data.forPublic.nonRevertibleAccumulatedData.unencryptedLogsHashes[nonRevertibleIndex++] = hash; - } else { - data.forPublic.revertibleAccumulatedData.unencryptedLogsHashes[revertibleIndex++] = hash; - } - } - }); - functionCount++; - }); + // We have a single contract class log + const contractClassUnencryptedLog = contractClassLog.functionLogs[0].logs[0]; + if (data.forPublic) { + const hash = new ScopedLogHash( + new LogHash( + Fr.fromBuffer(contractClassUnencryptedLog.hash()), + i++, + // +4 for encoding the length of the buffer + new Fr(contractClassUnencryptedLog.length + 4), + ), + contractClassUnencryptedLog.contractAddress, + ); + data.forPublic.nonRevertibleAccumulatedData.contractClassLogsHashes[0] = hash; + } } } else { data.forRollup!.end.nullifiers[0] = firstNullifier.value; @@ -232,13 +225,6 @@ export const mockTx = ( ScopedLogHash.empty(), MAX_ENCRYPTED_LOGS_PER_TX, ); - data.forRollup!.end.unencryptedLogsHashes = makeTuple(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty); - unencryptedLogs.unrollLogs().forEach((log, i) => { - data.forRollup!.end.unencryptedLogsHashes[i] = new ScopedLogHash( - new LogHash(Fr.fromBuffer(log.hash()), 0, new Fr(log.length)), - log.contractAddress, - ); - }); } const tx = new Tx( @@ -246,7 +232,8 @@ export const mockTx = ( ClientIvcProof.empty(), noteEncryptedLogs, encryptedLogs, - unencryptedLogs, + UnencryptedTxL2Logs.empty(), + contractClassLog, enqueuedPublicFunctionCalls, publicTeardownFunctionCall, ); diff --git a/yarn-project/circuit-types/src/private_execution_result.ts b/yarn-project/circuit-types/src/private_execution_result.ts index 8bb57866b843..588c4c44ab2b 100644 --- a/yarn-project/circuit-types/src/private_execution_result.ts +++ b/yarn-project/circuit-types/src/private_execution_result.ts @@ -211,10 +211,10 @@ export class PrivateExecutionResult { */ public encryptedLogs: CountedLog[], /** - * Unencrypted logs emitted during execution of this function call. - * Note: These are preimages to `unencryptedLogsHashes`. + * Contract class logs emitted during execution of this function call. + * Note: These are preimages to `contractClassLogsHashes`. */ - public unencryptedLogs: CountedLog[], + public contractClassLogs: CountedLog[], ) {} static get schema(): ZodFor { @@ -233,7 +233,7 @@ export class PrivateExecutionResult { publicTeardownFunctionCall: hexSchemaFor(PublicExecutionRequest), // TODO(palla/schema) Use PublicExecutionRequest.schema noteEncryptedLogs: z.array(CountedNoteLog.schema), encryptedLogs: z.array(CountedLog.schemaFor(EncryptedL2Log)), - unencryptedLogs: z.array(CountedLog.schemaFor(UnencryptedL2Log)), + contractClassLogs: z.array(CountedLog.schemaFor(UnencryptedL2Log)), }) .transform(PrivateExecutionResult.from); } @@ -253,7 +253,7 @@ export class PrivateExecutionResult { fields.publicTeardownFunctionCall, fields.noteEncryptedLogs, fields.encryptedLogs, - fields.unencryptedLogs, + fields.contractClassLogs, ); } @@ -278,7 +278,7 @@ export class PrivateExecutionResult { log: countedLog.log.toJSON(), counter: countedLog.counter, })), - unencryptedLogs: this.unencryptedLogs.map(countedLog => ({ + contractClassLogs: this.contractClassLogs.map(countedLog => ({ log: countedLog.log.toJSON(), counter: countedLog.counter, })), @@ -335,8 +335,8 @@ export class PrivateExecutionResult { (json: any) => new CountedLog(EncryptedL2Log.fromJSON(json.log), json.counter), ) : [], - Array.isArray(json.unencryptedLogs) - ? json.unencryptedLogs.map( + Array.isArray(json.contractClassLogs) + ? json.contractClassLogs.map( (json: any) => new CountedLog(UnencryptedL2Log.fromJSON(json.log), json.counter), ) : [], @@ -419,21 +419,21 @@ export function collectSortedEncryptedLogs(execResult: PrivateExecutionResult): } /** - * Collect all unencrypted logs across all nested executions. + * Collect all contract class logs across all nested executions. * @param execResult - The topmost execution result. - * @returns All unencrypted logs. + * @returns All contract class logs. */ -function collectUnencryptedLogs(execResult: PrivateExecutionResult): CountedLog[] { - return [execResult.unencryptedLogs, ...execResult.nestedExecutions.flatMap(collectUnencryptedLogs)].flat(); +function collectContractClassLogs(execResult: PrivateExecutionResult): CountedLog[] { + return [execResult.contractClassLogs, ...execResult.nestedExecutions.flatMap(collectContractClassLogs)].flat(); } /** - * Collect all unencrypted logs across all nested executions and sorts by counter. + * Collect all contract class logs across all nested executions and sorts by counter. * @param execResult - The topmost execution result. - * @returns All unencrypted logs. + * @returns All contract class logs. */ -export function collectSortedUnencryptedLogs(execResult: PrivateExecutionResult): UnencryptedFunctionL2Logs { - const allLogs = collectUnencryptedLogs(execResult); +export function collectSortedContractClassLogs(execResult: PrivateExecutionResult): UnencryptedFunctionL2Logs { + const allLogs = collectContractClassLogs(execResult); const sortedLogs = sortByCounter(allLogs); return new UnencryptedFunctionL2Logs(sortedLogs.map(l => l.log)); } diff --git a/yarn-project/circuit-types/src/stats/metrics.ts b/yarn-project/circuit-types/src/stats/metrics.ts index 8960a9dd9623..70d41f4a999f 100644 --- a/yarn-project/circuit-types/src/stats/metrics.ts +++ b/yarn-project/circuit-types/src/stats/metrics.ts @@ -109,19 +109,6 @@ export const Metrics = [ description: 'Time for the state synchronizer to process an L2 block that was not built by its own sequencer.', events: ['l2-block-handled'], }, - { - name: 'note_successful_decrypting_time_in_ms', - groupBy: 'block-size', - description: 'Time for the PXE to decrypt all notes in a block where they belong to a registered account.', - events: ['note-processor-caught-up'], - }, - { - name: 'note_trial_decrypting_time_in_ms', - groupBy: 'block-size', - description: - 'Time for the PXE to try decrypting all notes in a block where they do not belong to a registered account.', - events: ['note-processor-caught-up'], - }, { name: 'l2_block_building_time_in_ms', groupBy: 'block-size', @@ -146,31 +133,12 @@ export const Metrics = [ description: 'Time for a node without a sequencer to sync chain history', events: ['node-synced-chain-history'], }, - { - name: 'note_history_successful_decrypting_time_in_ms', - groupBy: 'chain-length', - description: 'Time for a PXE to decrypt all notes in the chain where they belong to a registered account.', - events: ['note-processor-caught-up'], - }, - { - name: 'note_history_trial_decrypting_time_in_ms', - groupBy: 'chain-length', - description: - 'Time for a PXE to try decrypting all notes in the chain where they do not belong to a registered account.', - events: ['note-processor-caught-up'], - }, { name: 'node_database_size_in_bytes', groupBy: 'chain-length', description: 'Size on disk of the leveldown database of a node after syncing all chain history.', events: ['node-synced-chain-history'], }, - { - name: 'pxe_database_size_in_bytes', - groupBy: 'chain-length', - description: 'Estimated size in memory of a PXE database after syncing all notes that belong to it in the chain.', - events: ['note-processor-caught-up'], - }, { name: 'protocol_circuit_simulation_time_in_ms', groupBy: 'protocol-circuit-name', diff --git a/yarn-project/circuit-types/src/stats/stats.ts b/yarn-project/circuit-types/src/stats/stats.ts index 185a846750b6..f9f947098454 100644 --- a/yarn-project/circuit-types/src/stats/stats.ts +++ b/yarn-project/circuit-types/src/stats/stats.ts @@ -1,7 +1,3 @@ -import { type ZodFor } from '@aztec/foundation/schemas'; - -import { z } from 'zod'; - /** Stats associated with an ACIR proof generation.*/ export type ProofConstructed = { /** Name of the event for metrics purposes */ @@ -207,49 +203,6 @@ export type L2BlockHandledStats = { oldestHistoricBlock: bigint; } & L2BlockStats; -/** Stats for a note processor that has caught up with the chain. */ -export type NoteProcessorCaughtUpStats = { - /** Name of the event. */ - eventName: 'note-processor-caught-up'; - /** Account the note processor belongs to. */ - account: string; - /** Total time to catch up with the tip of the chain from scratch in ms. */ - duration: number; - /** Size of the notes db. */ - dbSize: number; -} & NoteProcessorStats; - -/** Accumulated rolling stats for a note processor. */ -export type NoteProcessorStats = { - /** How many notes have been seen and trial-decrypted. */ - seen: number; - /** How many notes had decryption deferred due to a missing contract */ - deferredIncoming: number; - /** How many notes had decryption deferred due to a missing contract */ - deferredOutgoing: number; - /** How many incoming notes were successfully decrypted. */ - decryptedIncoming: number; - /** How many outgoing notes were successfully decrypted. */ - decryptedOutgoing: number; - /** How many notes failed processing. */ - failed: number; - /** How many blocks were spanned. */ - blocks: number; - /** How many txs were spanned. */ - txs: number; -}; - -export const NoteProcessorStatsSchema = z.object({ - seen: z.number(), - deferredIncoming: z.number(), - deferredOutgoing: z.number(), - decryptedIncoming: z.number(), - decryptedOutgoing: z.number(), - failed: z.number(), - blocks: z.number(), - txs: z.number(), -}) satisfies ZodFor; - /** Stats for a tx. */ export type TxStats = { /** Hash of the tx. */ @@ -276,6 +229,8 @@ export type TxStats = { newNullifierCount: number; /** How many classes were registered through the canonical class registerer. */ classRegisteredCount: number; + /** Serialized size of contract class logs. */ + contractClassLogSize: number; /** How this tx pays for its fee */ feePaymentMethod: 'none' | 'fee_juice' | 'fpc_public' | 'fpc_private'; }; @@ -320,7 +275,6 @@ export type Stats = | L2BlockBuiltStats | L2BlockHandledStats | NodeSyncedChainHistoryStats - | NoteProcessorCaughtUpStats | ProofConstructed | TreeInsertionStats | TxAddedToPoolStats; diff --git a/yarn-project/circuit-types/src/test/factories.ts b/yarn-project/circuit-types/src/test/factories.ts index b43f883bb7ec..41aeb67306ca 100644 --- a/yarn-project/circuit-types/src/test/factories.ts +++ b/yarn-project/circuit-types/src/test/factories.ts @@ -146,9 +146,11 @@ export function makeBloatedProcessedTx({ function clearLogs(data: { noteEncryptedLogsHashes: LogHash[]; encryptedLogsHashes: ScopedLogHash[]; - unencryptedLogsHashes: ScopedLogHash[]; + unencryptedLogsHashes?: ScopedLogHash[]; + contractClassLogsHashes: ScopedLogHash[]; }) { data.noteEncryptedLogsHashes.forEach((_, i) => (data.noteEncryptedLogsHashes[i] = LogHash.empty())); data.encryptedLogsHashes.forEach((_, i) => (data.encryptedLogsHashes[i] = ScopedLogHash.empty())); - data.unencryptedLogsHashes.forEach((_, i) => (data.unencryptedLogsHashes[i] = ScopedLogHash.empty())); + data.unencryptedLogsHashes?.forEach((_, i) => (data.unencryptedLogsHashes![i] = ScopedLogHash.empty())); + data.contractClassLogsHashes.forEach((_, i) => (data.contractClassLogsHashes[i] = ScopedLogHash.empty())); } diff --git a/yarn-project/circuit-types/src/tx/processed_tx.ts b/yarn-project/circuit-types/src/tx/processed_tx.ts index 05b3427ccbf4..58c129272875 100644 --- a/yarn-project/circuit-types/src/tx/processed_tx.ts +++ b/yarn-project/circuit-types/src/tx/processed_tx.ts @@ -168,9 +168,11 @@ export function makeProcessedTxFromPrivateOnlyTx( data.end.noteEncryptedLogPreimagesLength, data.end.encryptedLogPreimagesLength, data.end.unencryptedLogPreimagesLength, + data.end.contractClassLogPreimagesLength, tx.noteEncryptedLogs, tx.encryptedLogs, tx.unencryptedLogs, + tx.contractClassLogs, ); const gasUsed = { @@ -217,6 +219,7 @@ export function makeProcessedTxFromTxWithPublicCalls( const encryptedLogPreimagesLength = tx.encryptedLogs.getKernelLength(); // Unencrypted logs emitted from public functions are inserted to tx.unencryptedLogs directly :( const unencryptedLogPreimagesLength = tx.unencryptedLogs.getKernelLength(); + const contractClassLogPreimagesLength = tx.contractClassLogs.getKernelLength(); const txEffect = new TxEffect( revertCode, @@ -230,9 +233,11 @@ export function makeProcessedTxFromTxWithPublicCalls( new Fr(noteEncryptedLogPreimagesLength), new Fr(encryptedLogPreimagesLength), new Fr(unencryptedLogPreimagesLength), + new Fr(contractClassLogPreimagesLength), tx.noteEncryptedLogs, tx.encryptedLogs, tx.unencryptedLogs, + tx.contractClassLogs, ); return { diff --git a/yarn-project/circuit-types/src/tx/simulated_tx.ts b/yarn-project/circuit-types/src/tx/simulated_tx.ts index f3af028d0c5f..62c6270908c0 100644 --- a/yarn-project/circuit-types/src/tx/simulated_tx.ts +++ b/yarn-project/circuit-types/src/tx/simulated_tx.ts @@ -7,14 +7,19 @@ import { type PrivateKernelProverProfileResult, PrivateKernelProverProfileResultSchema, } from '../interfaces/private_kernel_prover.js'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from '../logs/tx_l2_logs.js'; +import { + ContractClassTxL2Logs, + EncryptedNoteTxL2Logs, + EncryptedTxL2Logs, + UnencryptedTxL2Logs, +} from '../logs/tx_l2_logs.js'; import { PrivateExecutionResult, collectEnqueuedPublicFunctionCalls, collectPublicTeardownFunctionCall, + collectSortedContractClassLogs, collectSortedEncryptedLogs, collectSortedNoteEncryptedLogs, - collectSortedUnencryptedLogs, } from '../private_execution_result.js'; import { type GasUsed } from './gas_used.js'; import { NestedProcessReturnValues, PublicSimulationOutput } from './public_simulation_output.js'; @@ -32,17 +37,19 @@ export class PrivateSimulationResult { toSimulatedTx(): Tx { const noteEncryptedLogs = new EncryptedNoteTxL2Logs([collectSortedNoteEncryptedLogs(this.privateExecutionResult)]); - const unencryptedLogs = new UnencryptedTxL2Logs([collectSortedUnencryptedLogs(this.privateExecutionResult)]); + const contractClassLogs = new ContractClassTxL2Logs([collectSortedContractClassLogs(this.privateExecutionResult)]); const encryptedLogs = new EncryptedTxL2Logs([collectSortedEncryptedLogs(this.privateExecutionResult)]); const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(this.privateExecutionResult); const teardownPublicFunction = collectPublicTeardownFunctionCall(this.privateExecutionResult); + // NB: no unencrypted logs* come from private, but we keep the property on Tx so enqueued_calls_processor.ts can accumulate public logs const tx = new Tx( this.publicInputs, ClientIvcProof.empty(), noteEncryptedLogs, encryptedLogs, - unencryptedLogs, + UnencryptedTxL2Logs.empty(), // *unencrypted logs + contractClassLogs, enqueuedPublicFunctions, teardownPublicFunction, ); @@ -146,17 +153,19 @@ export class TxProvingResult { toTx(): Tx { const noteEncryptedLogs = new EncryptedNoteTxL2Logs([collectSortedNoteEncryptedLogs(this.privateExecutionResult)]); - const unencryptedLogs = new UnencryptedTxL2Logs([collectSortedUnencryptedLogs(this.privateExecutionResult)]); + const contractClassLogs = new ContractClassTxL2Logs([collectSortedContractClassLogs(this.privateExecutionResult)]); const encryptedLogs = new EncryptedTxL2Logs([collectSortedEncryptedLogs(this.privateExecutionResult)]); const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(this.privateExecutionResult); const teardownPublicFunction = collectPublicTeardownFunctionCall(this.privateExecutionResult); + // NB: no unencrypted logs* come from private, but we keep the property on Tx so enqueued_calls_processor.ts can accumulate public logs const tx = new Tx( this.publicInputs, this.clientIvcProof, noteEncryptedLogs, encryptedLogs, - unencryptedLogs, + UnencryptedTxL2Logs.empty(), // *unencrypted logs + contractClassLogs, enqueuedPublicFunctions, teardownPublicFunction, ); diff --git a/yarn-project/circuit-types/src/tx/tx.ts b/yarn-project/circuit-types/src/tx/tx.ts index 9123fb2e6f6e..f53f70d7dccf 100644 --- a/yarn-project/circuit-types/src/tx/tx.ts +++ b/yarn-project/circuit-types/src/tx/tx.ts @@ -13,7 +13,12 @@ import { z } from 'zod'; import { type GetUnencryptedLogsResponse } from '../logs/get_logs_response.js'; import { type L2LogsSource } from '../logs/l2_logs_source.js'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from '../logs/tx_l2_logs.js'; +import { + ContractClassTxL2Logs, + EncryptedNoteTxL2Logs, + EncryptedTxL2Logs, + UnencryptedTxL2Logs, +} from '../logs/tx_l2_logs.js'; import { Gossipable } from '../p2p/gossipable.js'; import { TopicType, createTopicString } from '../p2p/topic_type.js'; import { PublicExecutionRequest } from '../public_execution_request.js'; @@ -47,8 +52,13 @@ export class Tx extends Gossipable { public encryptedLogs: EncryptedTxL2Logs, /** * Unencrypted logs generated by the tx. + * NOTE: These do not get filled, but remain here so enqueued_calls_processor.ts can accumulate public logs */ public unencryptedLogs: UnencryptedTxL2Logs, + /** + * Contract class logs generated by the tx. + */ + public contractClassLogs: ContractClassTxL2Logs, /** * Enqueued public functions from the private circuit to be run by the sequencer. */ @@ -102,6 +112,7 @@ export class Tx extends Gossipable { reader.readObject(EncryptedNoteTxL2Logs), reader.readObject(EncryptedTxL2Logs), reader.readObject(UnencryptedTxL2Logs), + reader.readObject(ContractClassTxL2Logs), reader.readArray(reader.readNumber(), PublicExecutionRequest), reader.readObject(PublicExecutionRequest), ); @@ -118,6 +129,7 @@ export class Tx extends Gossipable { this.noteEncryptedLogs, this.encryptedLogs, this.unencryptedLogs, + this.contractClassLogs, this.enqueuedPublicFunctionCalls.length, this.enqueuedPublicFunctionCalls, this.publicTeardownFunctionCall, @@ -133,6 +145,7 @@ export class Tx extends Gossipable { noteEncryptedLogs: hexSchema, // EncryptedNoteTxL2Logs.schema, encryptedLogs: hexSchema, // EncryptedTxL2Logs.schema, unencryptedLogs: hexSchema, // UnencryptedTxL2Logs.schema, + contractClassLogs: hexSchema, // ContractClassTxL2Logs.schema, enqueuedPublicFunctionCalls: z.array(hexSchema), // z.array(PublicExecutionRequest.schema), publicTeardownFunctionCall: hexSchema, // PublicExecutionRequest.schema, }) @@ -149,6 +162,7 @@ export class Tx extends Gossipable { noteEncryptedLogs: this.noteEncryptedLogs.toBuffer().toString('hex'), encryptedLogs: this.encryptedLogs.toBuffer().toString('hex'), unencryptedLogs: this.unencryptedLogs.toBuffer().toString('hex'), + contractClassLogs: this.contractClassLogs.toBuffer().toString('hex'), clientIvcProof: this.clientIvcProof.toBuffer().toString('hex'), enqueuedPublicFunctionCalls: this.enqueuedPublicFunctionCalls.map(f => f.toBuffer().toString('hex')) ?? [], publicTeardownFunctionCall: this.publicTeardownFunctionCall.toBuffer().toString('hex'), @@ -165,6 +179,7 @@ export class Tx extends Gossipable { const noteEncryptedLogs = EncryptedNoteTxL2Logs.fromBuffer(Buffer.from(obj.noteEncryptedLogs, 'hex')); const encryptedLogs = EncryptedTxL2Logs.fromBuffer(Buffer.from(obj.encryptedLogs, 'hex')); const unencryptedLogs = UnencryptedTxL2Logs.fromBuffer(Buffer.from(obj.unencryptedLogs, 'hex')); + const contractClassLogs = ContractClassTxL2Logs.fromBuffer(Buffer.from(obj.contractClassLogs, 'hex')); const clientIvcProof = ClientIvcProof.fromBuffer(Buffer.from(obj.clientIvcProof, 'hex')); const enqueuedPublicFunctionCalls = obj.enqueuedPublicFunctionCalls ? obj.enqueuedPublicFunctionCalls.map((x: string) => PublicExecutionRequest.fromBuffer(Buffer.from(x, 'hex'))) @@ -178,6 +193,7 @@ export class Tx extends Gossipable { noteEncryptedLogs, encryptedLogs, unencryptedLogs, + contractClassLogs, enqueuedPublicFunctionCalls, publicTeardownFunctionCall, ); @@ -234,9 +250,11 @@ export class Tx extends Gossipable { : 'fpc_private' : 'fee_juice' : 'none', - classRegisteredCount: this.unencryptedLogs + classRegisteredCount: this.contractClassLogs .unrollLogs() + // all contract class logs should pass the below check, but just in case: .filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log.data)).length, + contractClassLogSize: this.contractClassLogs.getSerializedLength(), }; } @@ -247,6 +265,7 @@ export class Tx extends Gossipable { this.noteEncryptedLogs.getSerializedLength() + this.encryptedLogs.getSerializedLength() + this.unencryptedLogs.getSerializedLength() + + this.contractClassLogs.getSerializedLength() + arraySerializedSizeOfNonEmpty(this.enqueuedPublicFunctionCalls) + arraySerializedSizeOfNonEmpty([this.publicTeardownFunctionCall]) ); @@ -281,6 +300,7 @@ export class Tx extends Gossipable { const noteEncryptedLogs = EncryptedNoteTxL2Logs.fromBuffer(Buffer.from(tx.noteEncryptedLogs.toBuffer())); const encryptedLogs = EncryptedTxL2Logs.fromBuffer(tx.encryptedLogs.toBuffer()); const unencryptedLogs = UnencryptedTxL2Logs.fromBuffer(tx.unencryptedLogs.toBuffer()); + const contractClassLogs = ContractClassTxL2Logs.fromBuffer(tx.contractClassLogs.toBuffer()); const enqueuedPublicFunctionCalls = tx.enqueuedPublicFunctionCalls.map(x => PublicExecutionRequest.fromBuffer(x.toBuffer()), ); @@ -291,6 +311,7 @@ export class Tx extends Gossipable { noteEncryptedLogs, encryptedLogs, unencryptedLogs, + contractClassLogs, enqueuedPublicFunctionCalls, publicTeardownFunctionCall, ); @@ -303,6 +324,7 @@ export class Tx extends Gossipable { EncryptedNoteTxL2Logs.random(1, 1), EncryptedTxL2Logs.random(1, 1), UnencryptedTxL2Logs.random(1, 1), + ContractClassTxL2Logs.random(1, 1), [PublicExecutionRequest.random()], PublicExecutionRequest.random(), ); @@ -337,6 +359,14 @@ export class Tx extends Gossipable { kernelOutput.endNonRevertibleData.noteEncryptedLogsHashes, EncryptedNoteTxL2Logs.empty(), ); + + // See comment in enqueued_calls_processor.ts -> tx.filterRevertedLogs() + if (this.data.forPublic) { + this.contractClassLogs = this.contractClassLogs.filterScoped( + this.data.forPublic?.nonRevertibleAccumulatedData.contractClassLogsHashes, + ContractClassTxL2Logs.empty(), + ); + } } } diff --git a/yarn-project/circuit-types/src/tx/tx_receipt.ts b/yarn-project/circuit-types/src/tx/tx_receipt.ts index 3d92c79adf64..280dae346b76 100644 --- a/yarn-project/circuit-types/src/tx/tx_receipt.ts +++ b/yarn-project/circuit-types/src/tx/tx_receipt.ts @@ -5,7 +5,6 @@ import { type FieldsOf } from '@aztec/foundation/types'; import { z } from 'zod'; -import { UniqueNote } from '../notes/extended_note.js'; import { TxHash } from './tx_hash.js'; /** @@ -141,18 +140,6 @@ interface DebugInfo { * New L2 to L1 messages created by the transaction. */ l2ToL1Msgs: Fr[]; - /** - * Notes created in this tx which were successfully decoded with the incoming keys of accounts which are registered - * in the PXE which was used to submit the tx. You will not get notes of accounts which are not registered in - * the PXE here even though they were created in this tx. - */ - visibleIncomingNotes: UniqueNote[]; - /** - * Notes created in this tx which were successfully decoded with the outgoing keys of accounts which are registered - * in the PXE which was used to submit the tx. You will not get notes of accounts which are not registered in - * the PXE here even though they were created in this tx. - */ - visibleOutgoingNotes: UniqueNote[]; } const DebugInfoSchema = z.object({ @@ -160,6 +147,4 @@ const DebugInfoSchema = z.object({ nullifiers: z.array(schemas.Fr), publicDataWrites: z.array(PublicDataWrite.schema), l2ToL1Msgs: z.array(schemas.Fr), - visibleIncomingNotes: z.array(UniqueNote.schema), - visibleOutgoingNotes: z.array(UniqueNote.schema), }); diff --git a/yarn-project/circuit-types/src/tx_effect.test.ts b/yarn-project/circuit-types/src/tx_effect.test.ts index a006d8c9f982..18df05d6dc48 100644 --- a/yarn-project/circuit-types/src/tx_effect.test.ts +++ b/yarn-project/circuit-types/src/tx_effect.test.ts @@ -10,6 +10,6 @@ describe('TxEffect', () => { it('hash of empty tx effect matches snapshot', () => { const txEffectHash = TxEffect.empty().hash().toString('hex'); // If you change this you have to change the hardcoded value in TxsDecoder.sol! - expect(txEffectHash).toMatchInlineSnapshot(`"00f0aa51fc81f8242316fcf2cb3b28196241ed3fa26dd320a959bce6c529b270"`); + expect(txEffectHash).toMatchInlineSnapshot(`"00c2dece9c9f14c67b8aafabdcb80793f1cffe95a801e15d648fd214a0522ee8"`); }); }); diff --git a/yarn-project/circuit-types/src/tx_effect.ts b/yarn-project/circuit-types/src/tx_effect.ts index 59939e32183b..8a06a7fb09bf 100644 --- a/yarn-project/circuit-types/src/tx_effect.ts +++ b/yarn-project/circuit-types/src/tx_effect.ts @@ -15,7 +15,7 @@ import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } f import { inspect } from 'util'; -import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from './logs/index.js'; +import { ContractClassTxL2Logs, EncryptedNoteTxL2Logs, EncryptedTxL2Logs, UnencryptedTxL2Logs } from './logs/index.js'; import { TxHash } from './tx/tx_hash.js'; export class TxEffect { @@ -51,9 +51,11 @@ export class TxEffect { public noteEncryptedLogsLength: Fr, public encryptedLogsLength: Fr, public unencryptedLogsLength: Fr, + public contractClassLogsLength: Fr, public noteEncryptedLogs: EncryptedNoteTxL2Logs, public encryptedLogs: EncryptedTxL2Logs, public unencryptedLogs: UnencryptedTxL2Logs, + public contractClassLogs: ContractClassTxL2Logs, ) { // TODO(#4638): Clean this up once we have isDefault() everywhere --> then we don't have to deal with 2 different // functions (isZero and isEmpty) @@ -107,9 +109,11 @@ export class TxEffect { this.noteEncryptedLogsLength, this.encryptedLogsLength, this.unencryptedLogsLength, + this.contractClassLogsLength, this.noteEncryptedLogs, this.encryptedLogs, this.unencryptedLogs, + this.contractClassLogs, ]); } @@ -131,9 +135,11 @@ export class TxEffect { Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader), + Fr.fromBuffer(reader), reader.readObject(EncryptedNoteTxL2Logs), reader.readObject(EncryptedTxL2Logs), reader.readObject(UnencryptedTxL2Logs), + reader.readObject(ContractClassTxL2Logs), ); } @@ -156,6 +162,7 @@ export class TxEffect { const noteEncryptedLogsHashKernel0 = this.noteEncryptedLogs.hash(); const encryptedLogsHashKernel0 = this.encryptedLogs.hash(); const unencryptedLogsHashKernel0 = this.unencryptedLogs.hash(); + const contractClassLogsHashKernel0 = this.contractClassLogs.hash(); const inputValue = Buffer.concat([ this.revertCode.toHashPreimage(), @@ -167,9 +174,11 @@ export class TxEffect { this.noteEncryptedLogsLength.toBuffer(), this.encryptedLogsLength.toBuffer(), this.unencryptedLogsLength.toBuffer(), + this.contractClassLogsLength.toBuffer(), noteEncryptedLogsHashKernel0, encryptedLogsHashKernel0, unencryptedLogsHashKernel0, + contractClassLogsHashKernel0, ]); return sha256Trunc(inputValue); @@ -212,6 +221,7 @@ export class TxEffect { const noteEncryptedLogs = EncryptedNoteTxL2Logs.random(numPrivateCallsPerTx, numEncryptedLogsPerCall); const encryptedLogs = EncryptedTxL2Logs.random(numPrivateCallsPerTx, numEncryptedLogsPerCall); const unencryptedLogs = UnencryptedTxL2Logs.random(numPublicCallsPerTx, numUnencryptedLogsPerCall); + const contractClassLogs = ContractClassTxL2Logs.random(1, 1); return new TxEffect( RevertCode.random(), Fr.random(), @@ -222,9 +232,11 @@ export class TxEffect { new Fr(noteEncryptedLogs.getKernelLength()), new Fr(encryptedLogs.getKernelLength()), new Fr(unencryptedLogs.getKernelLength()), + new Fr(contractClassLogs.getKernelLength()), noteEncryptedLogs, encryptedLogs, unencryptedLogs, + contractClassLogs, ); } @@ -239,9 +251,11 @@ export class TxEffect { Fr.ZERO, Fr.ZERO, Fr.ZERO, + Fr.ZERO, EncryptedNoteTxL2Logs.empty(), EncryptedTxL2Logs.empty(), UnencryptedTxL2Logs.empty(), + ContractClassTxL2Logs.empty(), ); } @@ -275,9 +289,11 @@ export class TxEffect { noteEncryptedLogsLength: ${this.noteEncryptedLogsLength}, encryptedLogsLength: ${this.encryptedLogsLength}, unencryptedLogsLength: ${this.unencryptedLogsLength}, + contractClassLogsLength: ${this.contractClassLogsLength}, noteEncryptedLogs: ${JSON.stringify(this.noteEncryptedLogs.toJSON())}, encryptedLogs: ${JSON.stringify(this.encryptedLogs.toJSON())}, unencryptedLogs: ${JSON.stringify(this.unencryptedLogs.toJSON())} + contractClassLogs: ${JSON.stringify(this.contractClassLogs.toJSON())} }`; } diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 7aa3b32b4aab..c4c26d55c391 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -17,6 +17,7 @@ export const MAX_KEY_VALIDATION_REQUESTS_PER_CALL = 16; export const MAX_NOTE_ENCRYPTED_LOGS_PER_CALL = 16; export const MAX_ENCRYPTED_LOGS_PER_CALL = 4; export const MAX_UNENCRYPTED_LOGS_PER_CALL = 4; +export const MAX_CONTRACT_CLASS_LOGS_PER_CALL = 1; export const ARCHIVE_HEIGHT = 29; export const VK_TREE_HEIGHT = 6; export const PROTOCOL_CONTRACT_TREE_HEIGHT = 3; @@ -56,6 +57,7 @@ export const MAX_KEY_VALIDATION_REQUESTS_PER_TX = 64; export const MAX_NOTE_ENCRYPTED_LOGS_PER_TX = 64; export const MAX_ENCRYPTED_LOGS_PER_TX = 8; export const MAX_UNENCRYPTED_LOGS_PER_TX = 8; +export const MAX_CONTRACT_CLASS_LOGS_PER_TX = 1; export const MAX_PUBLIC_DATA_HINTS = 128; export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; export const EMPTY_NESTED_INDEX = 0; @@ -83,7 +85,7 @@ export const PRIVATE_LOG_SIZE_IN_BYTES = 576; export const BLOB_SIZE_IN_BYTES = 126976; export const AZTEC_MAX_EPOCH_DURATION = 32; export const GENESIS_ARCHIVE_ROOT = 19007378675971183768036762391356802220352606103602592933942074152320327194720n; -export const FEE_JUICE_INITIAL_MINT = 20000000000; +export const FEE_JUICE_INITIAL_MINT = 200000000000000; export const PUBLIC_DISPATCH_SELECTOR = 3578010381; export const MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; @@ -180,7 +182,7 @@ export const TX_CONTEXT_LENGTH = 8; export const TX_REQUEST_LENGTH = 12; export const TOTAL_FEES_LENGTH = 1; export const HEADER_LENGTH = 24; -export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 499; +export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 490; export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 866; export const PRIVATE_CONTEXT_INPUTS_LENGTH = 37; export const PUBLIC_CONTEXT_INPUTS_LENGTH = 41; @@ -192,21 +194,22 @@ export const PRIVATE_VALIDATION_REQUESTS_LENGTH = 772; export const NUM_PUBLIC_VALIDATION_REQUEST_ARRAYS = 5; export const PUBLIC_VALIDATION_REQUESTS_LENGTH = 834; export const PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; -export const COMBINED_ACCUMULATED_DATA_LENGTH = 545; +export const COMBINED_ACCUMULATED_DATA_LENGTH = 550; export const TX_CONSTANT_DATA_LENGTH = 34; export const COMBINED_CONSTANT_DATA_LENGTH = 43; -export const PRIVATE_ACCUMULATED_DATA_LENGTH = 1064; -export const PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1877; +export const PRIVATE_ACCUMULATED_DATA_LENGTH = 1036; +export const PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1849; export const PUBLIC_ACCUMULATED_DATA_LENGTH = 1023; export const NUM_PUBLIC_ACCUMULATED_DATA_ARRAYS = 8; -export const PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 576; +export const PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 548; export const PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH = 160; export const NUM_PRIVATE_TO_AVM_ACCUMULATED_DATA_ARRAYS = 3; export const AVM_ACCUMULATED_DATA_LENGTH = 318; -export const PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1196; +export const PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1140; export const PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2931; export const VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2340; -export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 600; +export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 605; +export const AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1006; export const CONSTANT_ROLLUP_DATA_LENGTH = 13; export const BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 30; export const BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 90; @@ -228,7 +231,7 @@ export const TUBE_PROOF_LENGTH = 463; export const HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS = 128; export const CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS = 143; export const AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 86; -export const AVM_PROOF_LENGTH_IN_FIELDS = 4266; +export const AVM_PROOF_LENGTH_IN_FIELDS = 4291; export const AVM_PUBLIC_COLUMN_MAX_SIZE = 1024; export const AVM_PUBLIC_INPUTS_FLATTENED_SIZE = 2914; export const MEM_TAG_FF = 0; diff --git a/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts b/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts index 8938f8422a2e..9f58f13f0594 100644 --- a/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts +++ b/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts @@ -23,10 +23,15 @@ export class ContractInstanceDeployedEvent { return toBigIntBE(log.subarray(0, 32)) == DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE; } - static fromLogs(logs: { contractAddress: AztecAddress; data: Buffer }[]) { + // We store the contract instance deployed event log in enc logs, contract_instance_deployer_contract/src/main.nr + static fromLogs(logs: { maskedContractAddress: Fr; data: Buffer }[]) { return logs .filter(log => ContractInstanceDeployedEvent.isContractInstanceDeployedEvent(log.data)) - .filter(log => log.contractAddress.equals(AztecAddress.fromBigInt(BigInt(DEPLOYER_CONTRACT_ADDRESS)))) + .filter(log => + AztecAddress.fromField(log.maskedContractAddress).equals( + AztecAddress.fromBigInt(BigInt(DEPLOYER_CONTRACT_ADDRESS)), + ), + ) .map(log => ContractInstanceDeployedEvent.fromLogData(log.data)); } diff --git a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts index 03ee47322c31..57495f78aea3 100644 --- a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts +++ b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts @@ -40,6 +40,8 @@ describe('unconstrained_function_membership_proof', () => { expect(artifact.functions.filter(isUnconstrained).length).toBe(1); const unconstrainedFunction = unconstrainedFns[0]; + const selector = FunctionSelector.fromNameAndParameters(unconstrainedFunction); + const proof = createUnconstrainedFunctionMembershipProof(selector, artifact); expect(proof.artifactTreeSiblingPath.length).toBe(0); diff --git a/yarn-project/circuits.js/src/structs/avm/avm.ts b/yarn-project/circuits.js/src/structs/avm/avm.ts index e2979b507457..b4020f365118 100644 --- a/yarn-project/circuits.js/src/structs/avm/avm.ts +++ b/yarn-project/circuits.js/src/structs/avm/avm.ts @@ -1,3 +1,4 @@ +import { PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { hexSchemaFor } from '@aztec/foundation/schemas'; @@ -9,6 +10,7 @@ import { PublicKeys } from '../../types/public_keys.js'; import { Gas } from '../gas.js'; import { PublicCircuitPublicInputs } from '../public_circuit_public_inputs.js'; import { Vector } from '../shared.js'; +import { NullifierLeafPreimage } from '../trees/nullifier_leaf.js'; import { AvmCircuitPublicInputs } from './avm_circuit_public_inputs.js'; export class AvmEnqueuedCallHint { @@ -436,16 +438,426 @@ export class AvmContractBytecodeHints { } } +export class AvmAppendTreeHint { + readonly siblingPath: Vector; + /* + * @param bytecode the contract bytecode + * @param contractInstance the contract instance of the nested call, used to derive the contract address + * @param contractClassPreimage the contract class preimage of the nested call, used to derive the class id + * */ + constructor(public readonly leafIndex: Fr, public readonly value: Fr, readonly _siblingPath: Fr[]) { + this.siblingPath = new Vector(_siblingPath); + } + + /** + * Serializes the inputs to a buffer. + * @returns - The inputs serialized to a buffer. + */ + toBuffer() { + return serializeToBuffer(...AvmAppendTreeHint.getFields(this)); + } + + /** + * Serializes the inputs to a hex string. + * @returns The instance serialized to a hex string. + */ + toString() { + return this.toBuffer().toString('hex'); + } + + /** + * Is the struct empty? + * @returns whether all members are empty. + */ + isEmpty(): boolean { + return this.value.isZero() && this.siblingPath.items.length == 0; + } + + /** + * Creates a new instance from fields. + * @param fields - Fields to create the instance from. + * @returns A new AvmHint instance. + */ + static from(fields: FieldsOf): AvmAppendTreeHint { + return new AvmAppendTreeHint(fields.leafIndex, fields.value, fields.siblingPath.items); + } + + /** + * Extracts fields from an instance. + * @param fields - Fields to create the instance from. + * @returns An array of fields. + */ + static getFields(fields: FieldsOf) { + return [fields.leafIndex, fields.value, fields.siblingPath] as const; + } + + /** + * Deserializes from a buffer or reader. + * @param buffer - Buffer or reader to read from. + * @returns The deserialized instance. + */ + static fromBuffer(buff: Buffer | BufferReader): AvmAppendTreeHint { + return new AvmAppendTreeHint(Fr.fromBuffer(buff), Fr.fromBuffer(buff), BufferReader.asReader(buff).readVector(Fr)); + } + + /** + * Deserializes from a hex string. + * @param str - Hex string to read from. + * @returns The deserialized instance. + */ + static fromString(str: string): AvmAppendTreeHint { + return AvmAppendTreeHint.fromBuffer(Buffer.from(str, 'hex')); + } +} + +export class AvmNullifierWriteTreeHint { + readonly insertionPath: Vector; + /* + * @param bytecode the contract bytecode + * @param contractInstance the contract instance of the nested call, used to derive the contract address + * @param contractClassPreimage the contract class preimage of the nested call, used to derive the class id + * */ + constructor(public lowLeafRead: AvmNullifierReadTreeHint, public _insertionPath: Fr[]) { + this.insertionPath = new Vector(_insertionPath); + } + + /** + * Serializes the inputs to a buffer. + * @returns - The inputs serialized to a buffer. + */ + toBuffer() { + return serializeToBuffer(...AvmNullifierWriteTreeHint.getFields(this)); + } + + /** + * Serializes the inputs to a hex string. + * @returns The instance serialized to a hex string. + */ + toString() { + return this.toBuffer().toString('hex'); + } + + /** + * Is the struct empty? + * @returns whether all members are empty. + */ + isEmpty(): boolean { + return this.insertionPath.items.length == 0; + } + + /** + * Creates a new instance from fields. + * @param fields - Fields to create the instance from. + * @returns A new AvmHint instance. + */ + static from(fields: FieldsOf): AvmNullifierWriteTreeHint { + return new AvmNullifierWriteTreeHint(fields.lowLeafRead, fields.insertionPath.items); + } + + /** + * Extracts fields from an instance. + * @param fields - Fields to create the instance from. + * @returns An array of fields. + */ + static getFields(fields: FieldsOf) { + return [...AvmNullifierReadTreeHint.getFields(fields.lowLeafRead), fields.insertionPath] as const; + } + + /** + * Deserializes from a buffer or reader. + * @param buffer - Buffer or reader to read from. + * @returns The deserialized instance. + */ + static fromBuffer(buff: Buffer | BufferReader): AvmNullifierWriteTreeHint { + const reader = BufferReader.asReader(buff); + const lowLeafRead = AvmNullifierReadTreeHint.fromBuffer(reader); + const insertionPath = reader.readVector(Fr); + return new AvmNullifierWriteTreeHint(lowLeafRead, insertionPath); + } + + /** + * Deserializes from a hex string. + * @param str - Hex string to read from. + * @returns The deserialized instance. + */ + static fromString(str: string): AvmNullifierWriteTreeHint { + return AvmNullifierWriteTreeHint.fromBuffer(Buffer.from(str, 'hex')); + } +} + +export class AvmNullifierReadTreeHint { + readonly lowLeafSiblingPath: Vector; + + constructor( + public readonly lowLeafPreimage: NullifierLeafPreimage, + public readonly lowLeafIndex: Fr, + public readonly _lowLeafSiblingPath: Fr[], + ) { + this.lowLeafSiblingPath = new Vector(_lowLeafSiblingPath); + } + + /** + * Serializes the inputs to a buffer. + * @returns - The inputs serialized to a buffer. + */ + toBuffer() { + return serializeToBuffer(...AvmNullifierReadTreeHint.getFields(this)); + } + + /** + * Serializes the inputs to a hex string. + * @returns The instance serialized to a hex string. + */ + toString() { + return this.toBuffer().toString('hex'); + } + + /** + * Is the struct empty? + * @returns whether all members are empty. + */ + isEmpty(): boolean { + return this.lowLeafSiblingPath.items.length == 0; + } + + /** + * Creates a new instance from fields. + * @param fields - Fields to create the instance from. + * @returns A new AvmHint instance. + */ + static from(fields: FieldsOf): AvmNullifierReadTreeHint { + return new AvmNullifierReadTreeHint(fields.lowLeafPreimage, fields.lowLeafIndex, fields.lowLeafSiblingPath.items); + } + + /** + * Extracts fields from an instance. + * @param fields - Fields to create the instance from. + * @returns An array of fields. + */ + static getFields(fields: FieldsOf) { + return [ + fields.lowLeafPreimage.nullifier, + fields.lowLeafPreimage.nextNullifier, + new Fr(fields.lowLeafPreimage.nextIndex), + fields.lowLeafIndex, + fields.lowLeafSiblingPath, + ] as const; + } + + /** + * Deserializes from a buffer or reader. + * @param buffer - Buffer or reader to read from. + * @returns The deserialized instance. + */ + static fromBuffer(buff: Buffer | BufferReader): AvmNullifierReadTreeHint { + const reader = BufferReader.asReader(buff); + const lowLeafPreimage = reader.readObject(NullifierLeafPreimage); + const lowLeafIndex = Fr.fromBuffer(reader); + const lowSiblingPath = reader.readVector(Fr); + + return new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowSiblingPath); + } + + /** + * Deserializes from a hex string. + * @param str - Hex string to read from. + * @returns The deserialized instance. + */ + static fromString(str: string): AvmNullifierReadTreeHint { + return AvmNullifierReadTreeHint.fromBuffer(Buffer.from(str, 'hex')); + } +} + +export class AvmPublicDataReadTreeHint { + siblingPath: Vector; + + constructor( + public readonly leafPreimage: PublicDataTreeLeafPreimage, + public readonly leafIndex: Fr, + public readonly _siblingPath: Fr[], + ) { + this.siblingPath = new Vector(_siblingPath); + } + + /** + * Serializes the inputs to a buffer. + * @returns - The inputs serialized to a buffer. + */ + toBuffer() { + return serializeToBuffer(...AvmPublicDataReadTreeHint.getFields(this)); + } + + /** + * Serializes the inputs to a hex string. + * @returns The instance serialized to a hex string. + */ + toString() { + return this.toBuffer().toString('hex'); + } + + /** + * Is the struct empty? + * @returns whether all members are empty. + */ + isEmpty(): boolean { + return this.siblingPath.items.length == 0; + } + + /** + * Creates a new instance from fields. + * @param fields - Fields to create the instance from. + * @returns A new AvmHint instance. + */ + static from(fields: FieldsOf): AvmPublicDataReadTreeHint { + return new AvmPublicDataReadTreeHint(fields.leafPreimage, fields.leafIndex, fields.siblingPath.items); + } + + /** + * Extracts fields from an instance. + * @param fields - Fields to create the instance from. + * @returns An array of fields. + */ + static getFields(fields: FieldsOf) { + return [ + fields.leafPreimage.slot, + fields.leafPreimage.value, + new Fr(fields.leafPreimage.nextIndex), + fields.leafPreimage.nextSlot, + fields.leafIndex, + fields.siblingPath, + ] as const; + } + + /** + * Deserializes from a buffer or reader. + * @param buffer - Buffer or reader to read from. + * @returns The deserialized instance. + */ + static fromBuffer(buff: Buffer | BufferReader): AvmPublicDataReadTreeHint { + const reader = BufferReader.asReader(buff); + const lowLeafPreimage = reader.readObject(PublicDataTreeLeafPreimage); + const lowLeafIndex = Fr.fromBuffer(reader); + const lowSiblingPath = reader.readVector(Fr); + + return new AvmPublicDataReadTreeHint(lowLeafPreimage, lowLeafIndex, lowSiblingPath); + } + + /** + * Deserializes from a hex string. + * @param str - Hex string to read from. + * @returns The deserialized instance. + */ + static fromString(str: string): AvmPublicDataReadTreeHint { + return AvmPublicDataReadTreeHint.fromBuffer(Buffer.from(str, 'hex')); + } +} + +export class AvmPublicDataWriteTreeHint { + insertionPath: Vector; + + constructor( + // To check the current slot has been written to + public readonly lowLeafRead: AvmPublicDataReadTreeHint, + public readonly newLeafPreimage: PublicDataTreeLeafPreimage, + public readonly _insertionPath: Fr[], + ) { + this.insertionPath = new Vector(_insertionPath); + } + + /** + * Serializes the inputs to a buffer. + * @returns - The inputs serialized to a buffer. + */ + toBuffer() { + return serializeToBuffer(...AvmPublicDataWriteTreeHint.getFields(this)); + } + + /** + * Serializes the inputs to a hex string. + * @returns The instance serialized to a hex string. + */ + toString() { + return this.toBuffer().toString('hex'); + } + + /** + * Is the struct empty? + * @returns whether all members are empty. + */ + isEmpty(): boolean { + return this.insertionPath.items.length == 0; + } + + /** + * Creates a new instance from fields. + * @param fields - Fields to create the instance from. + * @returns A new AvmHint instance. + */ + static from(fields: FieldsOf): AvmPublicDataWriteTreeHint { + return new AvmPublicDataWriteTreeHint(fields.lowLeafRead, fields.newLeafPreimage, fields.insertionPath.items); + } + + /** + * Extracts fields from an instance. + * @param fields - Fields to create the instance from. + * @returns An array of fields. + */ + static getFields(fields: FieldsOf) { + return [ + ...AvmPublicDataReadTreeHint.getFields(fields.lowLeafRead), + fields.newLeafPreimage.slot, + fields.newLeafPreimage.value, + new Fr(fields.newLeafPreimage.nextIndex), + fields.newLeafPreimage.nextSlot, + fields.insertionPath, + ] as const; + } + + /** + * Deserializes from a buffer or reader. + * @param buffer - Buffer or reader to read from. + * @returns The deserialized instance. + */ + static fromBuffer(buff: Buffer | BufferReader): AvmPublicDataWriteTreeHint { + const reader = BufferReader.asReader(buff); + const lowLeafPreimage = reader.readObject(AvmPublicDataReadTreeHint); + const newLeafPreimage = reader.readObject(PublicDataTreeLeafPreimage); + const lowSiblingPath = reader.readVector(Fr); + + return new AvmPublicDataWriteTreeHint(lowLeafPreimage, newLeafPreimage, lowSiblingPath); + } + + /** + * Deserializes from a hex string. + * @param str - Hex string to read from. + * @returns The deserialized instance. + */ + static fromString(str: string): AvmPublicDataWriteTreeHint { + return AvmPublicDataWriteTreeHint.fromBuffer(Buffer.from(str, 'hex')); + } +} + export class AvmExecutionHints { public readonly enqueuedCalls: Vector; + public readonly storageValues: Vector; public readonly noteHashExists: Vector; public readonly nullifierExists: Vector; public readonly l1ToL2MessageExists: Vector; + public readonly externalCalls: Vector; + public readonly contractInstances: Vector; public readonly contractBytecodeHints: Vector; + public readonly storageReadRequest: Vector; + public readonly storageUpdateRequest: Vector; + public readonly nullifierReadRequest: Vector; + public readonly nullifierWriteHints: Vector; + public readonly noteHashReadRequest: Vector; + public readonly noteHashWriteRequest: Vector; + public readonly l1ToL2MessageReadRequest: Vector; + constructor( enqueuedCalls: AvmEnqueuedCallHint[], storageValues: AvmKeyValueHint[], @@ -455,6 +867,13 @@ export class AvmExecutionHints { externalCalls: AvmExternalCallHint[], contractInstances: AvmContractInstanceHint[], contractBytecodeHints: AvmContractBytecodeHints[], + storageReadRequest: AvmPublicDataReadTreeHint[], + storageUpdateRequest: AvmPublicDataWriteTreeHint[], + nullifierReadRequest: AvmNullifierReadTreeHint[], + nullifierWriteHints: AvmNullifierWriteTreeHint[], + noteHashReadRequest: AvmAppendTreeHint[], + noteHashWriteRequest: AvmAppendTreeHint[], + l1ToL2MessageReadRequest: AvmAppendTreeHint[], ) { this.enqueuedCalls = new Vector(enqueuedCalls); this.storageValues = new Vector(storageValues); @@ -464,14 +883,22 @@ export class AvmExecutionHints { this.externalCalls = new Vector(externalCalls); this.contractInstances = new Vector(contractInstances); this.contractBytecodeHints = new Vector(contractBytecodeHints); + this.storageReadRequest = new Vector(storageReadRequest); + this.storageUpdateRequest = new Vector(storageUpdateRequest); + this.noteHashReadRequest = new Vector(noteHashReadRequest); + this.nullifierReadRequest = new Vector(nullifierReadRequest); + this.nullifierWriteHints = new Vector(nullifierWriteHints); + this.noteHashReadRequest = new Vector(noteHashReadRequest); + this.noteHashWriteRequest = new Vector(noteHashWriteRequest); + this.l1ToL2MessageReadRequest = new Vector(l1ToL2MessageReadRequest); } /** * Return an empty instance. * @returns an empty instance. */ - empty() { - return new AvmExecutionHints([], [], [], [], [], [], [], []); + static empty() { + return new AvmExecutionHints([], [], [], [], [], [], [], [], [], [], [], [], [], [], []); } /** @@ -503,7 +930,14 @@ export class AvmExecutionHints { this.l1ToL2MessageExists.items.length == 0 && this.externalCalls.items.length == 0 && this.contractInstances.items.length == 0 && - this.contractBytecodeHints.items.length == 0 + this.contractBytecodeHints.items.length == 0 && + this.storageReadRequest.items.length == 0 && + this.storageUpdateRequest.items.length == 0 && + this.nullifierReadRequest.items.length == 0 && + this.nullifierWriteHints.items.length == 0 && + this.noteHashReadRequest.items.length == 0 && + this.noteHashWriteRequest.items.length == 0 && + this.l1ToL2MessageReadRequest.items.length == 0 ); } @@ -523,6 +957,13 @@ export class AvmExecutionHints { fields.externalCalls.items, fields.contractInstances.items, fields.contractBytecodeHints.items, + fields.storageReadRequest.items, + fields.storageUpdateRequest.items, + fields.nullifierReadRequest.items, + fields.nullifierWriteHints.items, + fields.noteHashReadRequest.items, + fields.noteHashWriteRequest.items, + fields.l1ToL2MessageReadRequest.items, ); } @@ -542,6 +983,13 @@ export class AvmExecutionHints { fields.externalCalls, fields.contractInstances, fields.contractBytecodeHints, + fields.storageReadRequest, + fields.storageUpdateRequest, + fields.nullifierReadRequest, + fields.nullifierWriteHints, + fields.noteHashReadRequest, + fields.noteHashWriteRequest, + fields.l1ToL2MessageReadRequest, ] as const; } @@ -562,6 +1010,13 @@ export class AvmExecutionHints { reader.readVector(AvmExternalCallHint), reader.readVector(AvmContractInstanceHint), reader.readVector(AvmContractBytecodeHints), + reader.readVector(AvmPublicDataReadTreeHint), + reader.readVector(AvmPublicDataWriteTreeHint), + reader.readVector(AvmNullifierReadTreeHint), + reader.readVector(AvmNullifierWriteTreeHint), + reader.readVector(AvmAppendTreeHint), + reader.readVector(AvmAppendTreeHint), + reader.readVector(AvmAppendTreeHint), ); } @@ -573,14 +1028,6 @@ export class AvmExecutionHints { static fromString(str: string): AvmCircuitInputs { return AvmCircuitInputs.fromBuffer(Buffer.from(str, 'hex')); } - - /** - * Construct an empty instance. - * @returns The empty instance. - */ - static empty() { - return new AvmExecutionHints([], [], [], [], [], [], [], []); - } } export class AvmCircuitInputs { diff --git a/yarn-project/circuits.js/src/structs/avm/avm_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/avm/avm_circuit_public_inputs.ts index 6c68ce02a234..0ff41750b69c 100644 --- a/yarn-project/circuits.js/src/structs/avm/avm_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/avm/avm_circuit_public_inputs.ts @@ -30,6 +30,7 @@ export class AvmCircuitPublicInputs { public previousNonRevertibleAccumulatedData: PrivateToAvmAccumulatedData, public previousRevertibleAccumulatedData: PrivateToAvmAccumulatedData, public endTreeSnapshots: TreeSnapshots, + public endGasUsed: Gas, public accumulatedData: AvmAccumulatedData, public transactionFee: Fr, public reverted: boolean, @@ -50,6 +51,7 @@ export class AvmCircuitPublicInputs { reader.readObject(PrivateToAvmAccumulatedData), reader.readObject(PrivateToAvmAccumulatedData), reader.readObject(TreeSnapshots), + reader.readObject(Gas), reader.readObject(AvmAccumulatedData), reader.readObject(Fr), reader.readBoolean(), @@ -70,6 +72,7 @@ export class AvmCircuitPublicInputs { this.previousNonRevertibleAccumulatedData, this.previousRevertibleAccumulatedData, this.endTreeSnapshots, + this.endGasUsed, this.accumulatedData, this.transactionFee, this.reverted, @@ -99,6 +102,7 @@ export class AvmCircuitPublicInputs { PrivateToAvmAccumulatedData.fromFields(reader), PrivateToAvmAccumulatedData.fromFields(reader), TreeSnapshots.fromFields(reader), + Gas.fromFields(reader), AvmAccumulatedData.fromFields(reader), reader.readField(), reader.readBoolean(), @@ -119,6 +123,7 @@ export class AvmCircuitPublicInputs { PrivateToAvmAccumulatedData.empty(), PrivateToAvmAccumulatedData.empty(), TreeSnapshots.empty(), + Gas.empty(), AvmAccumulatedData.empty(), Fr.zero(), false, @@ -147,6 +152,7 @@ export class AvmCircuitPublicInputs { previousNonRevertibleAccumulatedData: ${inspect(this.previousNonRevertibleAccumulatedData)}, previousRevertibleAccumulatedData: ${inspect(this.previousRevertibleAccumulatedData)}, endTreeSnapshots: ${inspect(this.endTreeSnapshots)}, + endGasUsed: ${inspect(this.endGasUsed)}, accumulatedData: ${inspect(this.accumulatedData)}, transactionFee: ${inspect(this.transactionFee)}, reverted: ${this.reverted}, diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts index a66c8742fa10..16ba5e3b7b73 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts @@ -7,6 +7,7 @@ import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/s import { inspect } from 'util'; import { + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, @@ -49,6 +50,11 @@ export class CombinedAccumulatedData { * Note: Truncated to 31 bytes to fit in Fr. */ public unencryptedLogsHashes: Tuple, + /** + * Accumulated contract class logs hash from all the previous kernel iterations. + * Note: Truncated to 31 bytes to fit in Fr. + */ + public contractClassLogsHashes: Tuple, /** * Total accumulated length of the encrypted note log preimages emitted in all the previous kernel iterations */ @@ -61,6 +67,10 @@ export class CombinedAccumulatedData { * Total accumulated length of the unencrypted log preimages emitted in all the previous kernel iterations */ public unencryptedLogPreimagesLength: Fr, + /** + * Total accumulated length of the contract class log preimages emitted in all the previous kernel iterations + */ + public contractClassLogPreimagesLength: Fr, /** * All the public data update requests made in this transaction. */ @@ -75,9 +85,11 @@ export class CombinedAccumulatedData { arraySerializedSizeOfNonEmpty(this.noteEncryptedLogsHashes) + arraySerializedSizeOfNonEmpty(this.encryptedLogsHashes) + arraySerializedSizeOfNonEmpty(this.unencryptedLogsHashes) + + arraySerializedSizeOfNonEmpty(this.contractClassLogsHashes) + this.noteEncryptedLogPreimagesLength.size + this.encryptedLogPreimagesLength.size + this.unencryptedLogPreimagesLength.size + + this.contractClassLogPreimagesLength.size + arraySerializedSizeOfNonEmpty(this.publicDataWrites) ); } @@ -90,9 +102,11 @@ export class CombinedAccumulatedData { fields.noteEncryptedLogsHashes, fields.encryptedLogsHashes, fields.unencryptedLogsHashes, + fields.contractClassLogsHashes, fields.noteEncryptedLogPreimagesLength, fields.encryptedLogPreimagesLength, fields.unencryptedLogPreimagesLength, + fields.contractClassLogPreimagesLength, fields.publicDataWrites, ] as const; } @@ -131,6 +145,8 @@ export class CombinedAccumulatedData { reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, LogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_TX, ScopedLogHash), reader.readArray(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash), + Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader), @@ -155,6 +171,8 @@ export class CombinedAccumulatedData { makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, LogHash.empty), makeTuple(MAX_ENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty), makeTuple(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty), + makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash.empty), + Fr.zero(), Fr.zero(), Fr.zero(), Fr.zero(), @@ -188,9 +206,14 @@ export class CombinedAccumulatedData { .filter(x => !x.isEmpty()) .map(x => inspect(x)) .join(', ')}], + contractClassLogsHashes: : [${this.contractClassLogsHashes + .filter(x => !x.isEmpty()) + .map(x => inspect(x)) + .join(', ')}], noteEncryptedLogPreimagesLength: ${this.noteEncryptedLogPreimagesLength.toString()}, encryptedLogPreimagesLength: ${this.encryptedLogPreimagesLength.toString()}, unencryptedLogPreimagesLength: ${this.unencryptedLogPreimagesLength.toString()}, + contractClassLogPreimagesLength: ${this.contractClassLogPreimagesLength.toString()}, publicDataWrites: [${this.publicDataWrites .filter(x => !x.isEmpty()) .map(x => inspect(x)) diff --git a/yarn-project/circuits.js/src/structs/kernel/private_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/private_accumulated_data.ts index cc9a5aeab5f1..86b7a03ac7ff 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_accumulated_data.ts @@ -2,6 +2,7 @@ import { makeTuple } from '@aztec/foundation/array'; import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, @@ -9,7 +10,6 @@ import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, } from '../../constants.gen.js'; import { ScopedL2ToL1Message } from '../l2_to_l1_message.js'; import { NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash } from '../log_hash.js'; @@ -47,10 +47,10 @@ export class PrivateAccumulatedData { */ public encryptedLogsHashes: Tuple, /** - * Accumulated unencrypted logs hashes from all the previous kernel iterations. + * Accumulated contract class logs from all the previous kernel iterations. * Note: Truncated to 31 bytes to fit in Fr. */ - public unencryptedLogsHashes: Tuple, + public contractClassLogsHashes: Tuple, /** * Accumulated public call requests from all the previous kernel iterations. */ @@ -68,7 +68,7 @@ export class PrivateAccumulatedData { this.l2ToL1Msgs, this.noteEncryptedLogsHashes, this.encryptedLogsHashes, - this.unencryptedLogsHashes, + this.contractClassLogsHashes, this.publicCallRequests, this.privateCallStack, ); @@ -91,7 +91,7 @@ export class PrivateAccumulatedData { reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message), reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, NoteLogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_TX, ScopedEncryptedLogHash), - reader.readArray(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash), reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, CountedPublicCallRequest), reader.readArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, PrivateCallRequest), ); @@ -113,7 +113,7 @@ export class PrivateAccumulatedData { makeTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message.empty), makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, NoteLogHash.empty), makeTuple(MAX_ENCRYPTED_LOGS_PER_TX, ScopedEncryptedLogHash.empty), - makeTuple(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty), + makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash.empty), makeTuple(MAX_ENQUEUED_CALLS_PER_TX, CountedPublicCallRequest.empty), makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, PrivateCallRequest.empty), ); diff --git a/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data.ts index c23c188e1252..d460c78d2ca4 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data.ts @@ -6,13 +6,13 @@ import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec import { inspect } from 'util'; import { + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, } from '../../constants.gen.js'; import { ScopedL2ToL1Message } from '../l2_to_l1_message.js'; import { LogHash, ScopedLogHash } from '../log_hash.js'; @@ -25,7 +25,7 @@ export class PrivateToPublicAccumulatedData { public readonly l2ToL1Msgs: Tuple, public readonly noteEncryptedLogsHashes: Tuple, public readonly encryptedLogsHashes: Tuple, - public readonly unencryptedLogsHashes: Tuple, + public readonly contractClassLogsHashes: Tuple, public readonly publicCallRequests: Tuple, ) {} @@ -36,7 +36,7 @@ export class PrivateToPublicAccumulatedData { arraySerializedSizeOfNonEmpty(this.l2ToL1Msgs) + arraySerializedSizeOfNonEmpty(this.noteEncryptedLogsHashes) + arraySerializedSizeOfNonEmpty(this.encryptedLogsHashes) + - arraySerializedSizeOfNonEmpty(this.unencryptedLogsHashes) + + arraySerializedSizeOfNonEmpty(this.contractClassLogsHashes) + arraySerializedSizeOfNonEmpty(this.publicCallRequests) ); } @@ -48,7 +48,7 @@ export class PrivateToPublicAccumulatedData { fields.l2ToL1Msgs, fields.noteEncryptedLogsHashes, fields.encryptedLogsHashes, - fields.unencryptedLogsHashes, + fields.contractClassLogsHashes, fields.publicCallRequests, ] as const; } @@ -61,7 +61,7 @@ export class PrivateToPublicAccumulatedData { reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message), reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, LogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_TX, ScopedLogHash), - reader.readArray(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash), reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest), ); } @@ -78,7 +78,7 @@ export class PrivateToPublicAccumulatedData { reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message), reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, LogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_TX, ScopedLogHash), - reader.readArray(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash), reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest), ); } @@ -94,7 +94,7 @@ export class PrivateToPublicAccumulatedData { makeTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message.empty), makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, LogHash.empty), makeTuple(MAX_ENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty), - makeTuple(MAX_UNENCRYPTED_LOGS_PER_TX, ScopedLogHash.empty), + makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ScopedLogHash.empty), makeTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest.empty), ); } @@ -121,7 +121,7 @@ export class PrivateToPublicAccumulatedData { .filter(x => !x.isEmpty()) .map(h => inspect(h)) .join(', ')}], - unencryptedLogsHashes: [${this.unencryptedLogsHashes + contractClassLogsHashes: [${this.contractClassLogsHashes .filter(x => !x.isEmpty()) .map(h => inspect(h)) .join(', ')}], diff --git a/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data_builder.ts b/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data_builder.ts index 9ab560d782f7..dd734a3e8ff9 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data_builder.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_to_public_accumulated_data_builder.ts @@ -2,13 +2,13 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, } from '../../constants.gen.js'; import { ScopedL2ToL1Message } from '../l2_to_l1_message.js'; import { LogHash, ScopedLogHash } from '../log_hash.js'; @@ -27,7 +27,7 @@ export class PrivateToPublicAccumulatedDataBuilder { private l2ToL1Msgs: ScopedL2ToL1Message[] = []; private noteEncryptedLogsHashes: LogHash[] = []; private encryptedLogsHashes: ScopedLogHash[] = []; - private unencryptedLogsHashes: ScopedLogHash[] = []; + private contractClassLogsHashes: ScopedLogHash[] = []; private publicCallStack: PublicCallRequest[] = []; pushNoteHash(newNoteHash: Fr) { @@ -80,13 +80,13 @@ export class PrivateToPublicAccumulatedDataBuilder { return this; } - pushUnencryptedLogsHash(unencryptedLogsHash: ScopedLogHash) { - this.unencryptedLogsHashes.push(unencryptedLogsHash); + pushContractClassLogsHash(contractClassLogsHash: ScopedLogHash) { + this.contractClassLogsHashes.push(contractClassLogsHash); return this; } - withUnencryptedLogsHashes(unencryptedLogsHashes: ScopedLogHash[]) { - this.unencryptedLogsHashes = unencryptedLogsHashes; + withContractClassLogsHashes(contractClassLogsHashes: ScopedLogHash[]) { + this.contractClassLogsHashes = contractClassLogsHashes; return this; } @@ -107,7 +107,7 @@ export class PrivateToPublicAccumulatedDataBuilder { padArrayEnd(this.l2ToL1Msgs, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(this.noteEncryptedLogsHashes, LogHash.empty(), MAX_NOTE_ENCRYPTED_LOGS_PER_TX), padArrayEnd(this.encryptedLogsHashes, ScopedLogHash.empty(), MAX_ENCRYPTED_LOGS_PER_TX), - padArrayEnd(this.unencryptedLogsHashes, ScopedLogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_TX), + padArrayEnd(this.contractClassLogsHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(this.publicCallStack, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), ); } @@ -119,7 +119,7 @@ export class PrivateToPublicAccumulatedDataBuilder { .withL2ToL1Msgs(publicAccumulatedData.l2ToL1Msgs) .withNoteEncryptedLogsHashes(publicAccumulatedData.noteEncryptedLogsHashes) .withEncryptedLogsHashes(publicAccumulatedData.encryptedLogsHashes) - .withUnencryptedLogsHashes(publicAccumulatedData.unencryptedLogsHashes) + .withContractClassLogsHashes(publicAccumulatedData.contractClassLogsHashes) .withPublicCallStack(publicAccumulatedData.publicCallRequests); } } diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index fbd2ae245208..dfb3fa6d00f4 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -11,6 +11,7 @@ import { import { type FieldsOf } from '@aztec/foundation/types'; import { + MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, @@ -21,7 +22,6 @@ import { MAX_NULLIFIERS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, - MAX_UNENCRYPTED_LOGS_PER_CALL, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, } from '../constants.gen.js'; import { Header } from '../structs/header.js'; @@ -125,10 +125,10 @@ export class PrivateCircuitPublicInputs { */ public encryptedLogsHashes: Tuple, /** - * Hash of the unencrypted logs emitted in this function call. + * Hash of the contract class logs emitted in this function call. * Note: Truncated to 31 bytes to fit in Fr. */ - public unencryptedLogsHashes: Tuple, + public contractClassLogsHashes: Tuple, /** * Header of a block whose state is used during private execution (not the block the transaction is included in). */ @@ -179,7 +179,7 @@ export class PrivateCircuitPublicInputs { reader.readObject(Fr), reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, NoteLogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_CALL, EncryptedLogHash), - reader.readArray(MAX_UNENCRYPTED_LOGS_PER_CALL, LogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_CALL, LogHash), reader.readObject(Header), reader.readObject(TxContext), ); @@ -207,7 +207,7 @@ export class PrivateCircuitPublicInputs { reader.readField(), reader.readArray(MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, NoteLogHash), reader.readArray(MAX_ENCRYPTED_LOGS_PER_CALL, EncryptedLogHash), - reader.readArray(MAX_UNENCRYPTED_LOGS_PER_CALL, LogHash), + reader.readArray(MAX_CONTRACT_CLASS_LOGS_PER_CALL, LogHash), reader.readObject(Header), reader.readObject(TxContext), ); @@ -238,7 +238,7 @@ export class PrivateCircuitPublicInputs { Fr.ZERO, makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, NoteLogHash.empty), makeTuple(MAX_ENCRYPTED_LOGS_PER_CALL, EncryptedLogHash.empty), - makeTuple(MAX_UNENCRYPTED_LOGS_PER_CALL, LogHash.empty), + makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_CALL, LogHash.empty), Header.empty(), TxContext.empty(), ); @@ -263,7 +263,7 @@ export class PrivateCircuitPublicInputs { isEmptyArray(this.l2ToL1Msgs) && isEmptyArray(this.noteEncryptedLogsHashes) && isEmptyArray(this.encryptedLogsHashes) && - isEmptyArray(this.unencryptedLogsHashes) && + isEmptyArray(this.contractClassLogsHashes) && this.historicalHeader.isEmpty() && this.txContext.isEmpty() ); @@ -295,7 +295,7 @@ export class PrivateCircuitPublicInputs { fields.endSideEffectCounter, fields.noteEncryptedLogsHashes, fields.encryptedLogsHashes, - fields.unencryptedLogsHashes, + fields.contractClassLogsHashes, fields.historicalHeader, fields.txContext, ] as const; diff --git a/yarn-project/circuits.js/src/structs/tagging_secret.ts b/yarn-project/circuits.js/src/structs/tagging_secret.ts index 3275346cf1ac..0c5c7175d7fc 100644 --- a/yarn-project/circuits.js/src/structs/tagging_secret.ts +++ b/yarn-project/circuits.js/src/structs/tagging_secret.ts @@ -1,33 +1,19 @@ -import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { poseidon2Hash } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -export class TaggingSecret { - constructor(public secret: Fr, public recipient: AztecAddress) {} +export class IndexedTaggingSecret { + constructor(public secret: Fr, public index: number) {} toFields(): Fr[] { - return [this.secret, this.recipient.toField()]; - } -} - -export class IndexedTaggingSecret extends TaggingSecret { - constructor(secret: Fr, recipient: AztecAddress, public index: number) { - super(secret, recipient); - } - - override toFields(): Fr[] { - return [this.secret, this.recipient.toField(), new Fr(this.index)]; + return [this.secret, new Fr(this.index)]; } static fromFields(serialized: Fr[]) { - return new this(serialized[0], AztecAddress.fromField(serialized[1]), serialized[2].toNumber()); - } - - static fromTaggingSecret(directionalSecret: TaggingSecret, index: number) { - return new this(directionalSecret.secret, directionalSecret.recipient, index); + return new this(serialized[0], serialized[1].toNumber()); } - computeTag() { - return poseidon2Hash([this.secret, this.recipient, this.index]); + computeTag(recipient: AztecAddress) { + return poseidon2Hash([this.secret, recipient, this.index]); } } diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index fc8fc0977573..9c448588c3ba 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -46,6 +46,7 @@ import { L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, LogHash, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_CALL, @@ -151,10 +152,15 @@ import { GlobalVariables } from '../structs/global_variables.js'; import { Header } from '../structs/header.js'; import { AvmAccumulatedData, + AvmAppendTreeHint, AvmCircuitPublicInputs, AvmContractBytecodeHints, AvmEnqueuedCallHint, + AvmNullifierReadTreeHint, + AvmNullifierWriteTreeHint, AvmProofData, + AvmPublicDataReadTreeHint, + AvmPublicDataWriteTreeHint, BaseRollupHints, CountedPublicCallRequest, EnqueuedCallData, @@ -390,9 +396,11 @@ export function makeCombinedAccumulatedData(seed = 1, full = false): CombinedAcc tupleGenerator(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, makeLogHash, seed + 0x700, LogHash.empty), tupleGenerator(MAX_ENCRYPTED_LOGS_PER_TX, makeScopedLogHash, seed + 0x800, ScopedLogHash.empty), tupleGenerator(MAX_UNENCRYPTED_LOGS_PER_TX, makeScopedLogHash, seed + 0x900, ScopedLogHash.empty), // unencrypted logs - fr(seed + 0xa00), // note_encrypted_log_preimages_length - fr(seed + 0xb00), // encrypted_log_preimages_length - fr(seed + 0xc00), // unencrypted_log_preimages_length + tupleGenerator(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeScopedLogHash, seed + 0xa00, ScopedLogHash.empty), // contract class logs + fr(seed + 0xb00), // note_encrypted_log_preimages_length + fr(seed + 0xc00), // encrypted_log_preimages_length + fr(seed + 0xd00), // unencrypted_log_preimages_length + fr(seed + 0xe00), // contract_class_log_preimages_length tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makePublicDataWrite, seed + 0xd00, PublicDataWrite.empty), ); } @@ -404,7 +412,7 @@ export function makePrivateToPublicAccumulatedData(seed = 1) { makeTuple(MAX_L2_TO_L1_MSGS_PER_TX, makeScopedL2ToL1Message, seed + 0x200), makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_TX, makeLogHash, seed + 0x700), makeTuple(MAX_ENCRYPTED_LOGS_PER_TX, makeScopedLogHash, seed + 0x800), - makeTuple(MAX_UNENCRYPTED_LOGS_PER_TX, makeScopedLogHash, seed + 0x900), + makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeScopedLogHash, seed + 0x900), makeTuple(MAX_ENQUEUED_CALLS_PER_TX, makePublicCallRequest, seed + 0x500), ); } @@ -644,7 +652,7 @@ function makeAvmCircuitPublicInputs(seed = 1) { return new AvmCircuitPublicInputs( makeGlobalVariables(seed), makeTreeSnapshots(seed + 0x10), - makeGas(), + makeGas(seed + 0x20), makeGasSettings(), makeTuple(MAX_ENQUEUED_CALLS_PER_TX, makePublicCallRequest, seed + 0x100), makeTuple(MAX_ENQUEUED_CALLS_PER_TX, makePublicCallRequest, seed + 0x200), @@ -654,8 +662,9 @@ function makeAvmCircuitPublicInputs(seed = 1) { makePrivateToAvmAccumulatedData(seed + 0x500), makePrivateToAvmAccumulatedData(seed + 0x600), makeTreeSnapshots(seed + 0x700), + makeGas(seed + 0x750), makeAvmAccumulatedData(seed + 0x800), - fr(seed + 0x700), + fr(seed + 0x900), false, ); } @@ -849,7 +858,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn endSideEffectCounter: fr(seed + 0x850), noteEncryptedLogsHashes: makeTuple(MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, makeNoteLogHash, seed + 0x875), encryptedLogsHashes: makeTuple(MAX_ENCRYPTED_LOGS_PER_CALL, makeEncryptedLogHash, seed + 0x900), - unencryptedLogsHashes: makeTuple(MAX_UNENCRYPTED_LOGS_PER_CALL, makeLogHash, seed + 0xa00), + contractClassLogsHashes: makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeLogHash, seed + 0xa00), historicalHeader: makeHeader(seed + 0xd00, undefined), txContext: makeTxContext(seed + 0x1400), isFeePayer: false, @@ -1528,6 +1537,46 @@ export function makeAvmBytecodeHints(seed = 0): AvmContractBytecodeHints { }); } +export function makeAvmTreeHints(seed = 0): AvmAppendTreeHint { + return new AvmAppendTreeHint( + new Fr(seed), + new Fr(seed + 1), + makeArray(10, i => new Fr(i), seed + 0x1000), + ); +} + +export function makeAvmNullifierReadTreeHints(seed = 0): AvmNullifierReadTreeHint { + const lowNullifierPreimage = new NullifierLeafPreimage(new Fr(seed), new Fr(seed + 1), BigInt(seed + 2)); + return new AvmNullifierReadTreeHint( + lowNullifierPreimage, + new Fr(seed + 1), + makeArray(10, i => new Fr(i), seed + 0x1000), + ); +} + +export function makeAvmNullifierInsertionTreeHints(seed = 0): AvmNullifierWriteTreeHint { + return new AvmNullifierWriteTreeHint( + makeAvmNullifierReadTreeHints(seed), + makeArray(20, i => new Fr(i), seed + 0x1000), + ); +} + +export function makeAvmStorageReadTreeHints(seed = 0): AvmPublicDataReadTreeHint { + return new AvmPublicDataReadTreeHint( + new PublicDataTreeLeafPreimage(new Fr(seed), new Fr(seed + 1), new Fr(seed + 2), BigInt(seed + 3)), + new Fr(seed + 1), + makeArray(10, i => new Fr(i), seed + 0x1000), + ); +} + +export function makeAvmStorageUpdateTreeHints(seed = 0): AvmPublicDataWriteTreeHint { + return new AvmPublicDataWriteTreeHint( + makeAvmStorageReadTreeHints(seed), + new PublicDataTreeLeafPreimage(new Fr(seed), new Fr(seed + 1), new Fr(seed + 2), BigInt(seed + 3)), + makeArray(20, i => new Fr(i), seed + 0x1000), + ); +} + /** * Makes arbitrary AvmContractInstanceHint. * @param seed - The seed to use for generating the state reference. @@ -1572,13 +1621,20 @@ export function makeAvmExecutionHints( return AvmExecutionHints.from({ enqueuedCalls: makeVector(baseLength, makeAvmEnqueuedCallHint, seed + 0x4100), - storageValues: makeVector(baseLength + 1, makeAvmKeyValueHint, seed + 0x4200), - noteHashExists: makeVector(baseLength + 2, makeAvmKeyValueHint, seed + 0x4300), - nullifierExists: makeVector(baseLength + 3, makeAvmKeyValueHint, seed + 0x4400), - l1ToL2MessageExists: makeVector(baseLength + 4, makeAvmKeyValueHint, seed + 0x4500), - externalCalls: makeVector(baseLength + 5, makeAvmExternalCallHint, seed + 0x4600), - contractInstances: makeVector(baseLength + 6, makeAvmContractInstanceHint, seed + 0x4700), - contractBytecodeHints: makeVector(baseLength + 7, makeAvmBytecodeHints, seed + 0x4800), + storageValues: makeVector(baseLength, makeAvmKeyValueHint, seed + 0x4200), + noteHashExists: makeVector(baseLength + 1, makeAvmKeyValueHint, seed + 0x4300), + nullifierExists: makeVector(baseLength + 2, makeAvmKeyValueHint, seed + 0x4400), + l1ToL2MessageExists: makeVector(baseLength + 3, makeAvmKeyValueHint, seed + 0x4500), + externalCalls: makeVector(baseLength + 4, makeAvmExternalCallHint, seed + 0x4600), + contractInstances: makeVector(baseLength + 5, makeAvmContractInstanceHint, seed + 0x4700), + contractBytecodeHints: makeVector(baseLength + 6, makeAvmBytecodeHints, seed + 0x4800), + storageReadRequest: makeVector(baseLength + 7, makeAvmStorageReadTreeHints, seed + 0x4900), + storageUpdateRequest: makeVector(baseLength + 8, makeAvmStorageUpdateTreeHints, seed + 0x4a00), + nullifierReadRequest: makeVector(baseLength + 9, makeAvmNullifierReadTreeHints, seed + 0x4b00), + nullifierWriteHints: makeVector(baseLength + 10, makeAvmNullifierInsertionTreeHints, seed + 0x4c00), + noteHashReadRequest: makeVector(baseLength + 11, makeAvmTreeHints, seed + 0x4d00), + noteHashWriteRequest: makeVector(baseLength + 12, makeAvmTreeHints, seed + 0x4e00), + l1ToL2MessageReadRequest: makeVector(baseLength + 13, makeAvmTreeHints, seed + 0x4f00), ...overrides, }); } diff --git a/yarn-project/circuits.js/src/tests/fixtures.ts b/yarn-project/circuits.js/src/tests/fixtures.ts index 2ed6c3e784a9..ee8146a79fe1 100644 --- a/yarn-project/circuits.js/src/tests/fixtures.ts +++ b/yarn-project/circuits.js/src/tests/fixtures.ts @@ -13,9 +13,9 @@ export function getBenchmarkContractArtifact(): ContractArtifact { return loadContractArtifact(content); } -// Copied from the build output for the contract `Benchmarking` in noir-contracts +// Copied from the build output for the contract `Test` in noir-contracts export function getTestContractArtifact(): ContractArtifact { - const path = getPathToFixture('Benchmarking.test.json'); + const path = getPathToFixture('Test.test.json'); const content = JSON.parse(readFileSync(path).toString()) as NoirCompiledContract; return loadContractArtifact(content); } diff --git a/yarn-project/cli-wallet/test/flows/basic.sh b/yarn-project/cli-wallet/test/flows/basic.sh index 45f1053607ba..31a59ad5bcc6 100755 --- a/yarn-project/cli-wallet/test/flows/basic.sh +++ b/yarn-project/cli-wallet/test/flows/basic.sh @@ -8,7 +8,7 @@ AMOUNT=42 aztec-wallet create-account -a main aztec-wallet deploy token_contract@Token --args accounts:main Test TST 18 -f main -aztec-wallet send mint_public -ca last --args accounts:main $AMOUNT -f main +aztec-wallet send mint_to_public -ca last --args accounts:main $AMOUNT -f main RESULT=$(aztec-wallet simulate balance_of_public -ca last --args accounts:main -f main | grep "Simulation result:" | awk '{print $3}') section "Main account public balance is ${RESULT}" diff --git a/yarn-project/cli-wallet/test/flows/no_alias.sh b/yarn-project/cli-wallet/test/flows/no_alias.sh index 5925b115bafb..0466501315ef 100755 --- a/yarn-project/cli-wallet/test/flows/no_alias.sh +++ b/yarn-project/cli-wallet/test/flows/no_alias.sh @@ -8,7 +8,7 @@ AMOUNT=42 ACCOUNT_ADDRESS=$(aztec-wallet create-account -a main | grep "Address:" | awk '{print $2}') TOKEN_ADDRESS=$(aztec-wallet deploy ./target/token_contract-Token.json --args $ACCOUNT_ADDRESS Test TST 18 -f $ACCOUNT_ADDRESS | grep "Contract deployed at" | awk '{print $4}') -aztec-wallet send mint_public -c ./target/token_contract-Token.json -ca $TOKEN_ADDRESS --args $ACCOUNT_ADDRESS $AMOUNT -f $ACCOUNT_ADDRESS +aztec-wallet send mint_to_public -c ./target/token_contract-Token.json -ca $TOKEN_ADDRESS --args $ACCOUNT_ADDRESS $AMOUNT -f $ACCOUNT_ADDRESS RESULT=$(aztec-wallet simulate balance_of_public -c ./target/token_contract-Token.json -ca $TOKEN_ADDRESS --args $ACCOUNT_ADDRESS -f $ACCOUNT_ADDRESS | grep "Simulation result:" | awk '{print $3}') section "Main account public balance is ${RESULT}" diff --git a/yarn-project/cli-wallet/test/flows/private_authwit_transfer.sh b/yarn-project/cli-wallet/test/flows/private_authwit_transfer.sh index 693998b0925a..abcf7c09016e 100755 --- a/yarn-project/cli-wallet/test/flows/private_authwit_transfer.sh +++ b/yarn-project/cli-wallet/test/flows/private_authwit_transfer.sh @@ -7,15 +7,15 @@ test_title "Private transfer on behalf of other" MINT_AMOUNT=42 TRANSFER_AMOUNT=21 -source $TEST_FOLDER/token_utils/create_main_and_mint_private.sh $MINT_AMOUNT +source $TEST_FOLDER/token_utils/create_main_and_mint_to_private.sh $MINT_AMOUNT aztec-wallet create-account -a operator aztec-wallet create-secret -a auth_nonce -aztec-wallet create-authwit transfer_from operator -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f main +aztec-wallet create-authwit transfer_in_private operator -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f main aztec-wallet add-authwit authwits:last main -f operator -aztec-wallet send transfer_from -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f operator +aztec-wallet send transfer_in_private -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f operator RESULT_MAIN=$(aztec-wallet simulate balance_of_private -ca token --args accounts:main -f main | grep "Simulation result:" | awk '{print $3}') RESULT_RECIPIENT=$(aztec-wallet simulate balance_of_private -ca token --args accounts:operator -f operator | grep "Simulation result:" | awk '{print $3}') diff --git a/yarn-project/cli-wallet/test/flows/public_authwit_transfer.sh b/yarn-project/cli-wallet/test/flows/public_authwit_transfer.sh index 4d355bbca850..89634c47437f 100755 --- a/yarn-project/cli-wallet/test/flows/public_authwit_transfer.sh +++ b/yarn-project/cli-wallet/test/flows/public_authwit_transfer.sh @@ -7,14 +7,14 @@ test_title "Public transfer on behalf of other" MINT_AMOUNT=42 TRANSFER_AMOUNT=21 -source $TEST_FOLDER/token_utils/create_main_and_mint_public.sh $MINT_AMOUNT +source $TEST_FOLDER/token_utils/create_main_and_mint_to_public.sh $MINT_AMOUNT aztec-wallet create-account -a operator aztec-wallet create-secret -a auth_nonce -aztec-wallet authorize-action transfer_public operator -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f main +aztec-wallet authorize-action transfer_in_public operator -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f main -aztec-wallet send transfer_public -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f operator +aztec-wallet send transfer_in_public -ca token --args accounts:main accounts:operator $TRANSFER_AMOUNT secrets:auth_nonce -f operator RESULT_MAIN=$(aztec-wallet simulate balance_of_public -ca token --args accounts:main -f main | grep "Simulation result:" | awk '{print $3}') RESULT_RECIPIENT=$(aztec-wallet simulate balance_of_public -ca token --args accounts:operator -f operator | grep "Simulation result:" | awk '{print $3}') diff --git a/yarn-project/cli-wallet/test/flows/shield_and_transfer.sh b/yarn-project/cli-wallet/test/flows/shield_and_transfer.sh index 7e27e6eb7900..e54da2fa6498 100755 --- a/yarn-project/cli-wallet/test/flows/shield_and_transfer.sh +++ b/yarn-project/cli-wallet/test/flows/shield_and_transfer.sh @@ -7,7 +7,7 @@ test_title "Shield and private transfer" MINT_AMOUNT=42 TRANSFER_AMOUNT=21 -source $TEST_FOLDER/token_utils/create_main_and_mint_private.sh $MINT_AMOUNT +source $TEST_FOLDER/token_utils/create_main_and_mint_to_private.sh $MINT_AMOUNT aztec-wallet create-account -a recipient diff --git a/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_private.sh b/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_private.sh index a2c8d9cfbe76..6ae5143c52b3 100644 --- a/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_private.sh +++ b/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_private.sh @@ -2,10 +2,8 @@ section "Deploying contracts and minting tokens privately" aztec-wallet create-account -a main aztec-wallet deploy token_contract@Token --args accounts:main Test TST 18 -f main -a token -aztec-wallet create-secret -a shield -aztec-wallet send mint_private -ca token --args $1 secrets:shield:hash -f main -aztec-wallet add-note TransparentNote pending_shields -ca token -t last -a main -b $1 secrets:shield:hash -aztec-wallet send redeem_shield -ca token --args accounts:main $1 secrets:shield -f main +aztec-wallet send mint_to_private -ca token --args accounts:main accounts:main $1 -f main + RESULT_MAIN=$(aztec-wallet simulate balance_of_private -ca token --args accounts:main -f main | grep "Simulation result:" | awk '{print $3}') diff --git a/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_public.sh b/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_public.sh index 20d49f06817d..862b2d04fe9f 100644 --- a/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_public.sh +++ b/yarn-project/cli-wallet/test/flows/token_utils/create_main_and_mint_public.sh @@ -2,7 +2,7 @@ section "Deploying contracts and minting tokens publicly" aztec-wallet create-account -a main aztec-wallet deploy token_contract@Token --args accounts:main Test TST 18 -f main -a token -aztec-wallet send mint_public -ca token --args accounts:main $1 -f main +aztec-wallet send mint_to_public -ca token --args accounts:main $1 -f main RESULT_MAIN=$(aztec-wallet simulate balance_of_public -ca token --args accounts:main -f main | grep "Simulation result:" | awk '{print $3}') diff --git a/yarn-project/cli/src/cmds/pxe/get_block.ts b/yarn-project/cli/src/cmds/pxe/get_block.ts index c43d3633ef9f..efe47f4148e5 100644 --- a/yarn-project/cli/src/cmds/pxe/get_block.ts +++ b/yarn-project/cli/src/cmds/pxe/get_block.ts @@ -19,9 +19,8 @@ export async function getBlock( setInterval(async () => { const newBlock = await client.getBlockNumber(); if (newBlock > lastBlock) { - const { blocks, notes } = await client.getSyncStatus(); - const areNotesSynced = blocks >= newBlock && Object.values(notes).every(block => block >= newBlock); - if (areNotesSynced) { + const { blocks } = await client.getSyncStatus(); + if (blocks >= newBlock) { log(''); await inspectBlock(client, newBlock, log, { showTxs: true }); lastBlock = newBlock; diff --git a/yarn-project/end-to-end/src/benchmarks/bench_process_history.test.ts b/yarn-project/end-to-end/src/benchmarks/bench_process_history.test.ts index 68524a7c7434..adc29c28d637 100644 --- a/yarn-project/end-to-end/src/benchmarks/bench_process_history.test.ts +++ b/yarn-project/end-to-end/src/benchmarks/bench_process_history.test.ts @@ -9,14 +9,7 @@ import { type BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking import { type SequencerClient } from '@aztec/sequencer-client'; import { type EndToEndContext } from '../fixtures/utils.js'; -import { - benchmarkSetup, - getFolderSize, - makeDataDirectory, - sendTxs, - waitNewPXESynced, - waitRegisteredAccountSynced, -} from './utils.js'; +import { benchmarkSetup, getFolderSize, makeDataDirectory, sendTxs, waitNewPXESynced } from './utils.js'; const BLOCK_SIZE = BENCHMARK_HISTORY_BLOCK_SIZE; const CHAIN_LENGTHS = BENCHMARK_HISTORY_CHAIN_LENGTHS; @@ -82,11 +75,11 @@ describe('benchmarks/process_history', () => { context.logger.info(`Registering owner account on new pxe`); const partialAddress = context.wallet.getCompleteAddress().partialAddress; const secretKey = context.wallet.getSecretKey(); - await waitRegisteredAccountSynced(pxe, secretKey, partialAddress); + await pxe.registerAccount(secretKey, partialAddress); // Repeat for another account that didn't receive any notes for them, so we measure trial-decrypts context.logger.info(`Registering fresh account on new pxe`); - await waitRegisteredAccountSynced(pxe, Fr.random(), Fr.random()); + await pxe.registerAccount(Fr.random(), Fr.random()); // Stop the external node and pxe await pxe.stop(); diff --git a/yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts b/yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts index 7148d1be742b..5aa2b0c33fc1 100644 --- a/yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts +++ b/yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts @@ -115,7 +115,7 @@ describe('benchmarks/proving', () => { const from = initialSchnorrWallet.getAddress(); // we are setting from to initial schnorr wallet here because of TODO(#9887) await Promise.all([ initialGasContract.methods.claim(initialFpContract.address, 1e12, claimSecret, messageLeafIndex).send().wait(), - initialTokenContract.methods.mint_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(), + initialTokenContract.methods.mint_to_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(), initialTokenContract.methods.mint_to_private(from, initialSchnorrWallet.getAddress(), 1e12).send().wait(), ]); }); @@ -183,7 +183,7 @@ describe('benchmarks/proving', () => { ctx.logger.info('+----------------------+'); const fnCalls = [ - (await getTokenContract(0)).methods.transfer_public(schnorrWalletAddress.address, recipient.address, 1000, 0), + (await getTokenContract(0)).methods.transfer_in_public(schnorrWalletAddress.address, recipient.address, 1000, 0), (await getTokenContract(1)).methods.transfer(recipient.address, 1000), // (await getTestContractOnPXE(2)).methods.emit_unencrypted(43), // (await getTestContractOnPXE(3)).methods.create_l2_to_l1_message_public(45, 46, EthAddress.random()), diff --git a/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts b/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts index 0463c9c8ac97..21612ccbe85f 100644 --- a/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts +++ b/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts @@ -5,7 +5,7 @@ import { type BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking import { type SequencerClient } from '@aztec/sequencer-client'; import { type EndToEndContext } from '../fixtures/utils.js'; -import { benchmarkSetup, sendTxs, waitNewPXESynced, waitRegisteredAccountSynced } from './utils.js'; +import { benchmarkSetup, sendTxs, waitNewPXESynced } from './utils.js'; describe('benchmarks/publish_rollup', () => { let context: EndToEndContext; @@ -47,11 +47,11 @@ describe('benchmarks/publish_rollup', () => { context.logger.info(`Registering owner account on new pxe`); const partialAddress = context.wallet.getCompleteAddress().partialAddress; const secretKey = context.wallet.getSecretKey(); - await waitRegisteredAccountSynced(pxe, secretKey, partialAddress); + await pxe.registerAccount(secretKey, partialAddress); // Repeat for another account that didn't receive any notes for them, so we measure trial-decrypts context.logger.info(`Registering fresh account on new pxe`); - await waitRegisteredAccountSynced(pxe, Fr.random(), Fr.random()); + await pxe.registerAccount(Fr.random(), Fr.random()); // Stop the external node and pxe await pxe.stop(); diff --git a/yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts b/yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts index ab248cca5619..f831e265c376 100644 --- a/yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts +++ b/yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts @@ -73,7 +73,7 @@ describe('benchmarks/tx_size_fees', () => { ]); const from = aliceWallet.getAddress(); // we are setting from to Alice here because of TODO(#9887) await token.methods.mint_to_private(from, aliceWallet.getAddress(), 100e9).send().wait(); - await token.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait(); + await token.methods.mint_to_public(aliceWallet.getAddress(), 100e9).send().wait(); }); it.each<[string, () => FeePaymentMethod | undefined /*bigint*/]>([ diff --git a/yarn-project/end-to-end/src/benchmarks/utils.ts b/yarn-project/end-to-end/src/benchmarks/utils.ts index 36c5f1fed761..5432a7f67818 100644 --- a/yarn-project/end-to-end/src/benchmarks/utils.ts +++ b/yarn-project/end-to-end/src/benchmarks/utils.ts @@ -1,15 +1,5 @@ import { type AztecNodeConfig, type AztecNodeService } from '@aztec/aztec-node'; -import { - type AztecNode, - BatchCall, - type Fr, - INITIAL_L2_BLOCK_NUM, - type PXE, - type PartialAddress, - type SentTx, - retryUntil, - sleep, -} from '@aztec/aztec.js'; +import { type AztecNode, BatchCall, INITIAL_L2_BLOCK_NUM, type SentTx, retryUntil, sleep } from '@aztec/aztec.js'; import { times } from '@aztec/foundation/collection'; import { randomInt } from '@aztec/foundation/crypto'; import { BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking'; @@ -120,16 +110,3 @@ export async function waitNewPXESynced( await retryUntil(() => pxe.isGlobalStateSynchronized(), 'pxe-global-sync'); return pxe; } - -/** - * Registers a new account in a pxe and waits until it's synced all its notes. - * @param pxe - PXE where to register the account. - * @param secretKey - Secret key of the account to register. - * @param partialAddress - Partial address of the account to register. - */ -export async function waitRegisteredAccountSynced(pxe: PXE, secretKey: Fr, partialAddress: PartialAddress) { - const l2Block = await pxe.getBlockNumber(); - const accountAddress = (await pxe.registerAccount(secretKey, partialAddress)).address; - const isAccountSynced = async () => (await pxe.getSyncStatus()).notes[accountAddress.toString()] === l2Block; - await retryUntil(isAccountSynced, 'pxe-notes-sync'); -} diff --git a/yarn-project/end-to-end/src/composed/docs_examples.test.ts b/yarn-project/end-to-end/src/composed/docs_examples.test.ts index 129717f85049..e90135cb67cc 100644 --- a/yarn-project/end-to-end/src/composed/docs_examples.test.ts +++ b/yarn-project/end-to-end/src/composed/docs_examples.test.ts @@ -42,7 +42,7 @@ describe('docs_examples', () => { // docs:end:full_deploy // docs:start:send_transaction - const _tx = await contract.methods.mint_public(wallet.getAddress(), 1).send().wait(); + const _tx = await contract.methods.mint_to_public(wallet.getAddress(), 1).send().wait(); // docs:end:send_transaction // docs:start:simulate_function diff --git a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts index fbe36b3effc3..df8cbcc47b08 100644 --- a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts @@ -6,7 +6,6 @@ import { Note, type TxHash, computeSecretHash, - waitForAccountSynch, } from '@aztec/aztec.js'; import { type Salt } from '@aztec/aztec.js/account'; import { type AztecAddress, type CompleteAddress, Fr, deriveSigningKey } from '@aztec/circuits.js'; @@ -243,8 +242,6 @@ describe('Aztec persistence', () => { const ownerWallet = await ownerAccount.getWallet(); const contract = await TokenBlacklistContract.at(contractAddress, ownerWallet); - await waitForAccountSynch(context.pxe, ownerAddress, { interval: 1, timeout: 10 }); - // check that notes total more than 0 so that this test isn't dependent on run order await expect(contract.methods.balance_of_private(ownerAddress.address).simulate()).resolves.toBeGreaterThan(0n); }); @@ -297,8 +294,6 @@ describe('Aztec persistence', () => { const signingKey = deriveSigningKey(ownerSecretKey); ownerWallet = await getUnsafeSchnorrWallet(context.pxe, ownerAddress.address, signingKey); contract = await TokenBlacklistContract.at(contractAddress, ownerWallet); - - await waitForAccountSynch(context.pxe, ownerAddress, { interval: 0.1, timeout: 5 }); }); afterEach(async () => { diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index d0c3c94695f2..c95e16b9d7a8 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -47,6 +47,9 @@ describe('e2e_2_pxes', () => { /*TODO(post-honk): We wait 5 seconds for a race condition in setting up two nodes. What is a more robust solution? */ await sleep(5000); + + await walletA.registerContact(walletB.getAddress()); + await walletB.registerContact(walletA.getAddress()); }); afterEach(async () => { @@ -152,30 +155,10 @@ describe('e2e_2_pxes', () => { await expectTokenBalance(walletB, token, walletB.getAddress(), userBBalance, logger); // CHECK THAT PRIVATE BALANCES ARE 0 WHEN ACCOUNT'S SECRET KEYS ARE NOT REGISTERED - // Note: Not checking if the account is synchronized because it is not registered as an account (it would throw). - const checkIfSynchronized = false; // Check that user A balance is 0 on server B - await expectTokenBalance(walletB, token, walletA.getAddress(), 0n, logger, checkIfSynchronized); + await expectTokenBalance(walletB, token, walletA.getAddress(), 0n, logger); // Check that user B balance is 0 on server A - await expectTokenBalance(walletA, token, walletB.getAddress(), 0n, logger, checkIfSynchronized); - }); - - it('permits migrating an account from one PXE to another', async () => { - const secretKey = Fr.random(); - const account = getUnsafeSchnorrAccount(pxeA, secretKey, Fr.random()); - const completeAddress = account.getCompleteAddress(); - const wallet = await account.waitSetup(); - - await expect(wallet.isAccountStateSynchronized(completeAddress.address)).resolves.toBe(true); - const accountOnB = getUnsafeSchnorrAccount(pxeB, secretKey, account.salt); - const walletOnB = await accountOnB.getWallet(); - - // need to register first otherwise the new PXE won't know about the account - await expect(walletOnB.isAccountStateSynchronized(completeAddress.address)).rejects.toThrow(); - - await accountOnB.register(); - // registering should wait for the account to be synchronized - await expect(walletOnB.isAccountStateSynchronized(completeAddress.address)).resolves.toBe(true); + await expectTokenBalance(walletA, token, walletB.getAddress(), 0n, logger); }); it('permits sending funds to a user before they have registered the contract', async () => { @@ -208,12 +191,15 @@ describe('e2e_2_pxes', () => { const sharedAccountOnA = getUnsafeSchnorrAccount(pxeA, sharedSecretKey, Fr.random()); const sharedAccountAddress = sharedAccountOnA.getCompleteAddress(); const sharedWalletOnA = await sharedAccountOnA.waitSetup(); - await expect(sharedWalletOnA.isAccountStateSynchronized(sharedAccountAddress.address)).resolves.toBe(true); + + await sharedWalletOnA.registerContact(walletA.getAddress()); const sharedAccountOnB = getUnsafeSchnorrAccount(pxeB, sharedSecretKey, sharedAccountOnA.salt); await sharedAccountOnB.register(); const sharedWalletOnB = await sharedAccountOnB.getWallet(); + await sharedWalletOnB.registerContact(sharedWalletOnA.getAddress()); + // deploy the contract on PXE A const token = await deployToken(walletA, initialBalance, logger); @@ -242,7 +228,6 @@ describe('e2e_2_pxes', () => { // PXE-B reprocesses the deferred notes, and sees the nullifier for A -> Shared await pxeB.registerContract(token); await expectTokenBalance(walletB, token, walletB.getAddress(), transferAmount2, logger); - await expect(sharedWalletOnB.isAccountStateSynchronized(sharedAccountAddress.address)).resolves.toBe(true); await expectTokenBalance( sharedWalletOnB, token, @@ -267,14 +252,16 @@ describe('e2e_2_pxes', () => { const receipt = await testContract.methods .call_create_note(noteValue, owner, outgoingViewer, noteStorageSlot) .send() - .wait({ debug: true }); - const { visibleIncomingNotes, visibleOutgoingNotes } = receipt.debugInfo!; - expect(visibleIncomingNotes).toHaveLength(1); - note = visibleIncomingNotes![0]; + .wait(); + await testContract.methods.sync_notes().simulate(); + const incomingNotes = await walletA.getIncomingNotes({ txHash: receipt.txHash }); + const outgoingNotes = await walletA.getOutgoingNotes({ txHash: receipt.txHash }); + expect(incomingNotes).toHaveLength(1); + note = incomingNotes[0]; // Since owner is the same as outgoing viewer the incoming and outgoing notes should be the same - expect(visibleOutgoingNotes).toHaveLength(1); - expect(visibleOutgoingNotes![0]).toEqual(note); + expect(outgoingNotes).toHaveLength(1); + expect(outgoingNotes[0]).toEqual(note); } // 3. Nullify the note diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts index 7623818516fa..e2ca5a2fa640 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts @@ -96,7 +96,6 @@ export class BlacklistTokenContractTest { this.other = this.wallets[1]; this.blacklisted = this.wallets[2]; this.accounts = await pxe.getRegisteredAccounts(); - this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`)); }); await this.snapshotManager.snapshot( @@ -222,8 +221,7 @@ export class BlacklistTokenContractTest { this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`); expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address)); - tokenSim.mintPrivate(amount); - tokenSim.redeemShield(address, amount); + tokenSim.mintPrivate(address, amount); const privateBalance = await asset.methods.balance_of_private(address).simulate(); this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`); expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address)); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts index 19dd05a9aade..03aa384b6858 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts @@ -83,13 +83,10 @@ describe('e2e_blacklist_token_contract mint', () => { }); describe('Mint flow', () => { - it('mint_private as minter', async () => { + it('mint_private as minter and redeem as recipient', async () => { const receipt = await asset.methods.mint_private(amount, secretHash).send().wait(); - tokenSim.mintPrivate(amount); txHash = receipt.txHash; - }); - it('redeem as recipient', async () => { await t.addPendingShieldNoteToPXE(0, amount, secretHash, txHash); const receiptClaim = await asset.methods @@ -97,9 +94,11 @@ describe('e2e_blacklist_token_contract mint', () => { .send() .wait({ debug: true }); - tokenSim.redeemShield(wallets[0].getAddress(), amount); - // 1 note should be created containing `amount` of tokens - const { visibleIncomingNotes } = receiptClaim.debugInfo!; + tokenSim.mintPrivate(wallets[0].getAddress(), amount); + // Trigger a note sync + await asset.methods.sync_notes().simulate(); + // 1 note should have been created containing `amount` of tokens + const visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receiptClaim.txHash }); expect(visibleIncomingNotes.length).toBe(1); expect(visibleIncomingNotes[0].note.items[0].toBigInt()).toBe(amount); }); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts index de9a3e1529d5..c2955daf7701 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts @@ -37,14 +37,13 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { const receipt = await asset.methods.shield(wallets[0].getAddress(), amount, secretHash, 0).send().wait(); - tokenSim.shield(wallets[0].getAddress(), amount); - await t.tokenSim.check(); - // Redeem it await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); await asset.methods.redeem_shield(wallets[0].getAddress(), amount, secret).send().wait(); - tokenSim.redeemShield(wallets[0].getAddress(), amount); + // Check that the result matches token sim + tokenSim.transferToPrivate(wallets[0].getAddress(), wallets[0].getAddress(), amount); + await t.tokenSim.check(); }); it('on behalf of other', async () => { @@ -59,9 +58,6 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { const receipt = await action.send().wait(); - tokenSim.shield(wallets[0].getAddress(), amount); - await t.tokenSim.check(); - // Check that replaying the shield should fail! await expect( asset.withWallet(wallets[1]).methods.shield(wallets[0].getAddress(), amount, secretHash, nonce).simulate(), @@ -71,7 +67,9 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); await asset.methods.redeem_shield(wallets[0].getAddress(), amount, secret).send().wait(); - tokenSim.redeemShield(wallets[0].getAddress(), amount); + // Check that the result matches token sim + tokenSim.transferToPrivate(wallets[0].getAddress(), wallets[0].getAddress(), amount); + await t.tokenSim.check(); }); describe('failure cases', () => { diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 605644f13fb2..88bfd6a1b236 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -400,7 +400,7 @@ describe('e2e_block_building', () => { logger.info('Spamming the network with public txs'); const txs = []; for (let i = 0; i < 30; i++) { - const tx = token.methods.mint_public(owner.getAddress(), 10n); + const tx = token.methods.mint_to_public(owner.getAddress(), 10n); txs.push(tx.send({ skipPublicSimulation: false })); } diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index ceae5ad7c6b8..6dc08e64aeee 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -180,6 +180,7 @@ describe('e2e_cheat_codes', () => { const mintAmount = 100n; await mintTokensToPrivate(token, wallet, admin, mintAmount); + await token.methods.sync_notes().simulate(); const balancesAdminSlot = cc.aztec.computeSlotInMap(TokenContract.storage.balances.slot, admin); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts index cac9f75b106c..f91f0ab555e0 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts @@ -52,7 +52,7 @@ describe('e2e_cross_chain_messaging token_bridge_failure_cases', () => { // Wrong message hash const wrongBridgeAmount = bridgeAmount + 1n; const wrongMessageContent = sha256ToField([ - Buffer.from(toFunctionSelector('mint_private(uint256)').substring(2), 'hex'), + Buffer.from(toFunctionSelector('mint_to_private(uint256)').substring(2), 'hex'), new Fr(wrongBridgeAmount), ]); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts index 87af389c0e33..b55cedc1e025 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts @@ -72,7 +72,7 @@ describe('e2e_cross_chain_messaging token_bridge_private', () => { const nonce = Fr.random(); await user1Wallet.createAuthWit({ caller: l2Bridge.address, - action: l2Token.methods.burn(ownerAddress, withdrawAmount, nonce), + action: l2Token.methods.burn_private(ownerAddress, withdrawAmount, nonce), }); // docs:end:authwit_to_another_sc diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts deleted file mode 100644 index 0b065456ecb1..000000000000 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Fr } from '@aztec/circuits.js'; - -import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; - -// TODO(benesjan): this test seems quite redundant. Nuke? -describe('e2e_cross_chain_messaging token_bridge_public_to_private', () => { - const t = new CrossChainMessagingTest('token_bridge_public_to_private'); - - let { crossChainTestHarness, ethAccount, aztecNode, ownerAddress } = t; - - beforeEach(async () => { - await t.applyBaseSnapshots(); - await t.setup(); - // Have to destructure again to ensure we have latest refs. - ({ crossChainTestHarness } = t); - - ethAccount = crossChainTestHarness.ethAccount; - aztecNode = crossChainTestHarness.aztecNode; - ownerAddress = crossChainTestHarness.ownerAddress; - }, 300_000); - - afterEach(async () => { - await t.teardown(); - }); - - it('Milestone 5.4: Should be able to create a commitment in a public function and spend in a private function', async () => { - const l1TokenBalance = 1000000n; - const bridgeAmount = 100n; - const shieldAmount = 50n; - - await crossChainTestHarness.mintTokensOnL1(l1TokenBalance); - const claim = await crossChainTestHarness.sendTokensToPortalPublic(bridgeAmount); - const msgHash = Fr.fromString(claim.messageHash); - expect(await crossChainTestHarness.getL1BalanceOf(ethAccount)).toEqual(l1TokenBalance - bridgeAmount); - - await crossChainTestHarness.makeMessageConsumable(msgHash); - - // Check message leaf index matches - const maybeIndexAndPath = await aztecNode.getL1ToL2MessageMembershipWitness('latest', msgHash); - expect(maybeIndexAndPath).toBeDefined(); - const messageLeafIndex = maybeIndexAndPath![0]; - expect(messageLeafIndex).toEqual(claim.messageLeafIndex); - - await crossChainTestHarness.consumeMessageOnAztecAndMintPublicly(claim); - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount); - - // Create the commitment to be spent in the private domain - await crossChainTestHarness.transferToPrivateOnL2(shieldAmount); - - // Create the transaction spending the commitment - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount - shieldAmount); - await crossChainTestHarness.expectPrivateBalanceOnL2(ownerAddress, shieldAmount); - - // Transfer to public the tokens again, sending them to the same account, however this can be any account. - await crossChainTestHarness.transferToPublicOnL2(shieldAmount); - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount); - await crossChainTestHarness.expectPrivateBalanceOnL2(ownerAddress, 0n); - }); -}); diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index 08a49bced6d6..5c8d1470d4d1 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -112,6 +112,13 @@ describe('e2e_crowdfunding_and_claim', () => { await rewardToken.methods.set_minter(claimContract.address, true).send().wait(); + // Add the operator address + // as a contact to all donor wallets, so they can receive notes + await Promise.all( + donorWallets.map(async wallet => { + await wallet.registerContact(operatorWallet.getAddress()); + }), + ); // Now we mint DNT to donors await mintTokensToPrivate(donationToken, operatorWallet, donorWallets[0].getAddress(), 1234n); await mintTokensToPrivate(donationToken, operatorWallet, donorWallets[1].getAddress(), 2345n); @@ -148,7 +155,7 @@ describe('e2e_crowdfunding_and_claim', () => { { const action = donationToken .withWallet(donorWallets[0]) - .methods.transfer_from(donorWallets[0].getAddress(), crowdfundingContract.address, donationAmount, 0); + .methods.transfer_in_private(donorWallets[0].getAddress(), crowdfundingContract.address, donationAmount, 0); const witness = await donorWallets[0].createAuthWit({ caller: crowdfundingContract.address, action }); await donorWallets[0].addAuthWitness(witness); } @@ -164,9 +171,9 @@ describe('e2e_crowdfunding_and_claim', () => { }); // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the value note) - const notes = donateTxReceipt.debugInfo?.visibleIncomingNotes.filter(x => - x.contractAddress.equals(crowdfundingContract.address), - ); + await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate(); + const incomingNotes = await donorWallets[0].getIncomingNotes({ txHash: donateTxReceipt.txHash }); + const notes = incomingNotes.filter(x => x.contractAddress.equals(crowdfundingContract.address)); expect(notes!.length).toEqual(1); // Set the value note in a format which can be passed to claim function @@ -219,7 +226,7 @@ describe('e2e_crowdfunding_and_claim', () => { { const action = donationToken .withWallet(donorWallets[1]) - .methods.transfer_from(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); + .methods.transfer_in_private(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); const witness = await donorWallets[1].createAuthWit({ caller: crowdfundingContract.address, action }); await donorWallets[1].addAuthWitness(witness); } @@ -235,9 +242,9 @@ describe('e2e_crowdfunding_and_claim', () => { }); // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the value note) - const notes = donateTxReceipt.debugInfo?.visibleIncomingNotes.filter(x => - x.contractAddress.equals(crowdfundingContract.address), - ); + await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate(); + const incomingNotes = await donorWallets[0].getIncomingNotes({ txHash: donateTxReceipt.txHash }); + const notes = incomingNotes.filter(x => x.contractAddress.equals(crowdfundingContract.address)); expect(notes!.length).toEqual(1); // Set the value note in a format which can be passed to claim function @@ -291,9 +298,10 @@ describe('e2e_crowdfunding_and_claim', () => { let note: any; { const receipt = await inclusionsProofsContract.methods.create_note(owner, 5n).send().wait({ debug: true }); - const { visibleIncomingNotes } = receipt.debugInfo!; - expect(visibleIncomingNotes.length).toEqual(1); - note = processUniqueNote(visibleIncomingNotes![0]); + await inclusionsProofsContract.methods.sync_notes().simulate(); + const incomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash }); + expect(incomingNotes.length).toEqual(1); + note = processUniqueNote(incomingNotes[0]); } // 3) Test the note was included @@ -311,7 +319,7 @@ describe('e2e_crowdfunding_and_claim', () => { // 1) We add authwit so that the Crowdfunding contract can transfer donor's DNT const action = donationToken .withWallet(donorWallets[1]) - .methods.transfer_from(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); + .methods.transfer_in_private(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); const witness = await donorWallets[1].createAuthWit({ caller: crowdfundingContract.address, action }); await donorWallets[1].addAuthWitness(witness); @@ -357,7 +365,7 @@ describe('e2e_crowdfunding_and_claim', () => { { const action = donationToken .withWallet(donorWallets[1]) - .methods.transfer_from(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); + .methods.transfer_in_private(donorWallets[1].getAddress(), crowdfundingContract.address, donationAmount, 0); const witness = await donorWallets[1].createAuthWit({ caller: crowdfundingContract.address, action }); await donorWallets[1].addAuthWitness(witness); } diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts index 36641e9296b4..9908dfecbec9 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts @@ -71,7 +71,7 @@ describe('e2e_deploy_contract contract class registration', () => { const selector = FunctionSelector.fromNameAndParameters(constructorArtifact.name, constructorArtifact.parameters); const tx = await (await broadcastPrivateFunction(wallet, artifact, selector)).send().wait(); - const logs = await pxe.getUnencryptedLogs({ txHash: tx.txHash }); + const logs = await pxe.getContractClassLogs({ txHash: tx.txHash }); const logData = logs.logs[0].log.data; writeTestData('yarn-project/circuits.js/fixtures/PrivateFunctionBroadcastedEventData.hex', logData); @@ -85,7 +85,7 @@ describe('e2e_deploy_contract contract class registration', () => { const functionArtifact = artifact.functions.find(fn => fn.functionType === FunctionType.UNCONSTRAINED)!; const selector = FunctionSelector.fromNameAndParameters(functionArtifact); const tx = await (await broadcastUnconstrainedFunction(wallet, artifact, selector)).send().wait(); - const logs = await pxe.getUnencryptedLogs({ txHash: tx.txHash }); + const logs = await pxe.getContractClassLogs({ txHash: tx.txHash }); const logData = logs.logs[0].log.data; writeTestData('yarn-project/circuits.js/fixtures/UnconstrainedFunctionBroadcastedEventData.hex', logData); diff --git a/yarn-project/end-to-end/src/e2e_fees/account_init.test.ts b/yarn-project/end-to-end/src/e2e_fees/account_init.test.ts index b114bd07fd67..6685ff2f5c2b 100644 --- a/yarn-project/end-to-end/src/e2e_fees/account_init.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/account_init.test.ts @@ -134,7 +134,7 @@ describe('e2e_fees account_init', () => { it('pays publicly through an FPC', async () => { const mintedBananas = BigInt(1e12); - await bananaCoin.methods.mint_public(bobsAddress, mintedBananas).send().wait(); + await bananaCoin.methods.mint_to_public(bobsAddress, mintedBananas).send().wait(); const paymentMethod = new PublicFeePaymentMethod(bananaCoin.address, bananaFPC.address, bobsWallet); const tx = await bobsAccountManager @@ -192,7 +192,11 @@ describe('e2e_fees account_init', () => { await expect(t.getGasBalanceFn(aliceAddress)).resolves.toEqual([alicesInitialGas - tx.transactionFee!]); // bob can now use his wallet for sending txs - await bananaCoin.withWallet(bobsWallet).methods.transfer_public(bobsAddress, aliceAddress, 0n, 0n).send().wait(); + await bananaCoin + .withWallet(bobsWallet) + .methods.transfer_in_public(bobsAddress, aliceAddress, 0n, 0n) + .send() + .wait(); }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts b/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts index 6511ad56466a..b567a385c434 100644 --- a/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts @@ -207,7 +207,7 @@ describe('e2e_fees dapp_subscription', () => { async function subscribe(paymentMethod: FeePaymentMethod, blockDelta: number = 5, txCount: number = 4) { const nonce = Fr.random(); - const action = bananaCoin.methods.transfer_from(aliceAddress, bobAddress, t.SUBSCRIPTION_AMOUNT, nonce); + const action = bananaCoin.methods.transfer_in_private(aliceAddress, bobAddress, t.SUBSCRIPTION_AMOUNT, nonce); await aliceWallet.createAuthWit({ caller: subscriptionContract.address, action }); return subscriptionContract diff --git a/yarn-project/end-to-end/src/e2e_fees/failures.test.ts b/yarn-project/end-to-end/src/e2e_fees/failures.test.ts index d96da87f4b14..18058dba9445 100644 --- a/yarn-project/end-to-end/src/e2e_fees/failures.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/failures.test.ts @@ -51,7 +51,7 @@ describe('e2e_fees failures', () => { await expect( bananaCoin.methods // still use a public transfer so as to fail in the public app logic phase - .transfer_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) .send({ fee: { gasSettings, @@ -79,7 +79,7 @@ describe('e2e_fees failures', () => { const currentSequencerL1Gas = await t.getCoinbaseBalance(); const txReceipt = await bananaCoin.methods - .transfer_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) .send({ skipPublicSimulation: true, fee: { @@ -143,11 +143,11 @@ describe('e2e_fees failures', () => { sequencerAddress, ); - await bananaCoin.methods.mint_public(aliceAddress, publicMintedAlicePublicBananas).send().wait(); + await bananaCoin.methods.mint_to_public(aliceAddress, publicMintedAlicePublicBananas).send().wait(); // if we simulate locally, it throws an error await expect( bananaCoin.methods - .transfer_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) .send({ fee: { gasSettings, @@ -176,7 +176,7 @@ describe('e2e_fees failures', () => { // if we skip simulation, it includes the failed TX const txReceipt = await bananaCoin.methods - .transfer_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, outrageousPublicAmountAliceDoesNotHave, 0) .send({ skipPublicSimulation: true, fee: { @@ -213,7 +213,7 @@ describe('e2e_fees failures', () => { // simulation throws an error when setup fails await expect( bananaCoin.methods - .transfer_public(aliceAddress, sequencerAddress, OutrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, OutrageousPublicAmountAliceDoesNotHave, 0) .send({ fee: { gasSettings, @@ -226,7 +226,7 @@ describe('e2e_fees failures', () => { // so does the sequencer await expect( bananaCoin.methods - .transfer_public(aliceAddress, sequencerAddress, OutrageousPublicAmountAliceDoesNotHave, 0) + .transfer_in_public(aliceAddress, sequencerAddress, OutrageousPublicAmountAliceDoesNotHave, 0) .send({ skipPublicSimulation: true, fee: { @@ -258,7 +258,7 @@ describe('e2e_fees failures', () => { sequencerAddress, ); - await bananaCoin.methods.mint_public(aliceAddress, publicMintedAlicePublicBananas).send().wait(); + await bananaCoin.methods.mint_to_public(aliceAddress, publicMintedAlicePublicBananas).send().wait(); const badGas = GasSettings.from({ gasLimits: gasSettings.gasLimits, @@ -268,7 +268,7 @@ describe('e2e_fees failures', () => { await expect( bananaCoin.methods - .mint_public(aliceAddress, 1n) // random operation + .mint_to_public(aliceAddress, 1n) // random operation .send({ fee: { gasSettings: badGas, @@ -279,7 +279,7 @@ describe('e2e_fees failures', () => { ).rejects.toThrow(); const receipt = await bananaCoin.methods - .mint_public(aliceAddress, 1n) // random operation + .mint_to_public(aliceAddress, 1n) // random operation .send({ skipPublicSimulation: true, fee: { @@ -329,9 +329,9 @@ class BuggedSetupFeePaymentMethod extends PublicFeePaymentMethod { { caller: this.paymentContract, action: { - name: 'transfer_public', + name: 'transfer_in_public', args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce], - selector: FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'), + selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'), type: FunctionType.PUBLIC, isStatic: false, to: this.asset, diff --git a/yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts b/yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts index 6956bcf24a93..dcaabbf882b8 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts @@ -43,7 +43,7 @@ describe('e2e_fees Fee Juice payments', () => { it('fails to send a tx', async () => { await expect( bananaCoin.methods - .transfer_public(aliceAddress, bobAddress, 1n, 0n) + .transfer_in_public(aliceAddress, bobAddress, 1n, 0n) .send({ fee: { gasSettings, paymentMethod } }) .wait(), ).rejects.toThrow(/Not enough balance for fee payer to pay for transaction/i); @@ -53,7 +53,7 @@ describe('e2e_fees Fee Juice payments', () => { const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(t.INITIAL_GAS_BALANCE, aliceAddress); const paymentMethod = new FeeJuicePaymentMethodWithClaim(aliceAddress, claim); const receipt = await bananaCoin.methods - .transfer_public(aliceAddress, bobAddress, 1n, 0n) + .transfer_in_public(aliceAddress, bobAddress, 1n, 0n) .send({ fee: { gasSettings, paymentMethod } }) .wait(); const endBalance = await feeJuiceContract.methods.balance_of_public(aliceAddress).simulate(); @@ -72,7 +72,7 @@ describe('e2e_fees Fee Juice payments', () => { it('sends tx with payment in Fee Juice with public calls', async () => { const initialBalance = await feeJuiceContract.methods.balance_of_public(aliceAddress).simulate(); const { transactionFee } = await bananaCoin.methods - .transfer_public(aliceAddress, bobAddress, 1n, 0n) + .transfer_in_public(aliceAddress, bobAddress, 1n, 0n) .send({ fee: { gasSettings, paymentMethod } }) .wait(); expect(transactionFee).toBeGreaterThan(0n); diff --git a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts index aa930a1a56ec..d69ff14f11be 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts @@ -4,12 +4,8 @@ import { type AztecAddress, type AztecNode, type DebugLogger, - ExtendedNote, - Fr, - Note, type PXE, SignerlessWallet, - type TxHash, createDebugLogger, sleep, } from '@aztec/aztec.js'; @@ -126,22 +122,6 @@ export class FeesTest { expect(balanceAfter).toEqual(balanceBefore + amount); } - /** Adds a pending shield transparent node for the banana coin token contract to the pxe. */ - // TODO(benesjan): nuke this - async addPendingShieldNoteToPXE(owner: AztecAddress | AccountWallet, amount: bigint, secretHash: Fr, txHash: TxHash) { - const note = new Note([new Fr(amount), secretHash]); - const ownerAddress = 'getAddress' in owner ? owner.getAddress() : owner; - const extendedNote = new ExtendedNote( - note, - ownerAddress, - this.bananaCoin.address, - BananaCoin.storage.pending_shields.slot, - BananaCoin.notes.TransparentNote.id, - txHash, - ); - await this.pxe.addNote(extendedNote, ownerAddress); - } - public async applyBaseSnapshots() { await this.applyInitialAccountsSnapshot(); await this.applyPublicDeployAccountsSnapshot(); @@ -290,7 +270,7 @@ export class FeesTest { 'fund_alice', async () => { await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress); - await this.bananaCoin.methods.mint_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send().wait(); + await this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send().wait(); }, () => Promise.resolve(), ); diff --git a/yarn-project/end-to-end/src/e2e_fees/gas_estimation.test.ts b/yarn-project/end-to-end/src/e2e_fees/gas_estimation.test.ts index 862bdc387cb1..28e20fc79e59 100644 --- a/yarn-project/end-to-end/src/e2e_fees/gas_estimation.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/gas_estimation.test.ts @@ -42,7 +42,7 @@ describe('e2e_fees gas_estimation', () => { await t.teardown(); }); - const makeTransferRequest = () => bananaCoin.methods.transfer_public(aliceAddress, bobAddress, 1n, 0n); + const makeTransferRequest = () => bananaCoin.methods.transfer_in_public(aliceAddress, bobAddress, 1n, 0n); // Sends two tx with transfers of public tokens: one with estimateGas on, one with estimateGas off const sendTransfers = (paymentMethod: FeePaymentMethod) => diff --git a/yarn-project/end-to-end/src/e2e_fees/private_payments.test.ts b/yarn-project/end-to-end/src/e2e_fees/private_payments.test.ts index bf9fdb65ba80..870f40707c99 100644 --- a/yarn-project/end-to-end/src/e2e_fees/private_payments.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/private_payments.test.ts @@ -1,12 +1,4 @@ -import { - type AccountWallet, - type AztecAddress, - BatchCall, - Fr, - PrivateFeePaymentMethod, - computeSecretHash, - sleep, -} from '@aztec/aztec.js'; +import { type AccountWallet, type AztecAddress, BatchCall, PrivateFeePaymentMethod, sleep } from '@aztec/aztec.js'; import { type GasSettings } from '@aztec/circuits.js'; import { type TokenContract as BananaCoin, FPCContract } from '@aztec/noir-contracts.js'; @@ -179,8 +171,8 @@ describe('e2e_fees private_payment', () => { * BC increase total supply * * PUBLIC TEARDOWN - * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note - * increase Alice's private banana balance by feeAmount by finalizing partial note + * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note + * increase Alice's private banana balance by feeAmount by finalizing partial note */ const newlyMintedBananas = 10n; const from = aliceAddress; // we are setting from to Alice here because of TODO(#9887) @@ -221,23 +213,20 @@ describe('e2e_fees private_payment', () => { * setup fee and refund partial notes * setup public teardown call * - * * PRIVATE APP LOGIC - * N/A + * a partial note is prepared * * PUBLIC APP LOGIC * BC decrease Alice public balance by shieldedBananas - * BC create transparent note of shieldedBananas + * BC finalizes the partial note with an amount --> this is where the note is created in public * * PUBLIC TEARDOWN - * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note - * increase Alice's private banana balance by feeAmount by finalizing partial note + * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note + * increase Alice's private banana balance by feeAmount by finalizing partial note */ - const shieldedBananas = 1n; - const shieldSecret = Fr.random(); - const shieldSecretHash = computeSecretHash(shieldSecret); + const amountTransferredToPrivate = 1n; const tx = await bananaCoin.methods - .shield(aliceAddress, shieldedBananas, shieldSecretHash, 0n) + .transfer_to_private(aliceAddress, amountTransferredToPrivate) .send({ fee: { gasSettings, @@ -256,30 +245,27 @@ describe('e2e_fees private_payment', () => { await expectMapping( t.getBananaPrivateBalanceFn, [aliceAddress, bananaFPC.address, sequencerAddress], - [initialAlicePrivateBananas - feeAmount, 0n, initialSequencerPrivateBananas + feeAmount], + [ + initialAlicePrivateBananas - feeAmount + amountTransferredToPrivate, + 0n, + initialSequencerPrivateBananas + feeAmount, + ], ); await expectMapping( t.getBananaPublicBalanceFn, [aliceAddress, bananaFPC.address, sequencerAddress], - [initialAlicePublicBananas - shieldedBananas, initialFPCPublicBananas, 0n], + [initialAlicePublicBananas - amountTransferredToPrivate, initialFPCPublicBananas, 0n], ); await expectMapping( t.getGasBalanceFn, [aliceAddress, bananaFPC.address, sequencerAddress], [initialAliceGas, initialFPCGas - feeAmount, initialSequencerGas], ); - - await expect( - t.addPendingShieldNoteToPXE(t.aliceWallet, shieldedBananas, shieldSecretHash, tx.txHash), - ).resolves.toBeUndefined(); }); it('pays fees for tx that creates notes in both private and public', async () => { - const privateTransfer = 1n; - const shieldedBananas = 1n; - const shieldSecret = Fr.random(); - const shieldSecretHash = computeSecretHash(shieldSecret); - + const amountTransferredInPrivate = 1n; + const amountTransferredToPrivate = 2n; /** * PRIVATE SETUP * check authwit @@ -290,18 +276,19 @@ describe('e2e_fees private_payment', () => { * PRIVATE APP LOGIC * reduce Alice's private balance by privateTransfer * create note for Bob with privateTransfer amount of private BC + * prepare partial note (in the transfer to private) * * PUBLIC APP LOGIC - * BC decrease Alice public balance by shieldedBananas - * BC create transparent note of shieldedBananas + * BC decrease Alice public balance by amountTransferredToPrivate + * BC finalize partial note with amountTransferredToPrivate (this is where the note is created in public) * * PUBLIC TEARDOWN - * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note - * increase Alice's private banana balance by feeAmount by finalizing partial note + * increase sequencer/fee recipient/FPC admin private banana balance by feeAmount by finalizing partial note + * increase Alice's private banana balance by feeAmount by finalizing partial note */ const tx = await new BatchCall(aliceWallet, [ - bananaCoin.methods.transfer(bobAddress, privateTransfer).request(), - bananaCoin.methods.shield(aliceAddress, shieldedBananas, shieldSecretHash, 0n).request(), + bananaCoin.methods.transfer(bobAddress, amountTransferredInPrivate).request(), + bananaCoin.methods.transfer_to_private(aliceAddress, amountTransferredToPrivate).request(), ]) .send({ fee: { @@ -322,8 +309,8 @@ describe('e2e_fees private_payment', () => { t.getBananaPrivateBalanceFn, [aliceAddress, bobAddress, bananaFPC.address, sequencerAddress], [ - initialAlicePrivateBananas - feeAmount - privateTransfer, - initialBobPrivateBananas + privateTransfer, + initialAlicePrivateBananas - feeAmount - amountTransferredInPrivate + amountTransferredToPrivate, + initialBobPrivateBananas + amountTransferredInPrivate, 0n, initialSequencerPrivateBananas + feeAmount, ], @@ -331,17 +318,13 @@ describe('e2e_fees private_payment', () => { await expectMapping( t.getBananaPublicBalanceFn, [aliceAddress, bananaFPC.address, sequencerAddress], - [initialAlicePublicBananas - shieldedBananas, initialFPCPublicBananas, 0n], + [initialAlicePublicBananas - amountTransferredToPrivate, initialFPCPublicBananas, 0n], ); await expectMapping( t.getGasBalanceFn, [aliceAddress, bananaFPC.address, sequencerAddress], [initialAliceGas, initialFPCGas - feeAmount, initialSequencerGas], ); - - await expect( - t.addPendingShieldNoteToPXE(t.aliceWallet, shieldedBananas, shieldSecretHash, tx.txHash), - ).resolves.toBeUndefined(); }); it('rejects txs that dont have enough balance to cover gas costs', async () => { diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index cb356d6ebda6..4b0c502e1e21 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -100,18 +100,16 @@ describe('e2e_lending_contract', () => { const mintAmount = 10000n; for (const asset of assets) { await Promise.all([ - asset.methods.mint_public(lendingAccount.address, mintAmount).send().wait(), + asset.methods.mint_to_public(lendingAccount.address, mintAmount).send().wait(), mintTokensToPrivate(asset, wallet, lendingAccount.address, mintAmount), ]); } } lendingSim.mintStableCoinOutsideLoan(lendingAccount.address, 10000n, true); - lendingSim.stableCoin.redeemShield(lendingAccount.address, 10000n); lendingSim.mintStableCoinOutsideLoan(lendingAccount.address, 10000n, false); - lendingSim.collateralAsset.mintPrivate(10000n); - lendingSim.collateralAsset.redeemShield(lendingAccount.address, 10000n); + lendingSim.collateralAsset.mintPrivate(lendingAccount.address, 10000n); lendingSim.collateralAsset.mintPublic(lendingAccount.address, 10000n); }); @@ -203,7 +201,7 @@ describe('e2e_lending_contract', () => { .setPublicAuthWit( { caller: lendingContract.address, - action: collateralAsset.methods.transfer_public( + action: collateralAsset.methods.transfer_in_public( lendingAccount.address, lendingContract.address, depositAmount, @@ -273,7 +271,7 @@ describe('e2e_lending_contract', () => { const nonce = Fr.random(); await wallet.createAuthWit({ caller: lendingContract.address, - action: stableCoin.methods.burn(lendingAccount.address, repayAmount, nonce), + action: stableCoin.methods.burn_private(lendingAccount.address, repayAmount, nonce), }); await lendingSim.progressSlots(SLOT_JUMP); @@ -297,7 +295,7 @@ describe('e2e_lending_contract', () => { const nonce = Fr.random(); await wallet.createAuthWit({ caller: lendingContract.address, - action: stableCoin.methods.burn(lendingAccount.address, repayAmount, nonce), + action: stableCoin.methods.burn_private(lendingAccount.address, repayAmount, nonce), }); await lendingSim.progressSlots(SLOT_JUMP); diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index c379ae088aa7..fa9230fa294a 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -301,12 +301,12 @@ describe('e2e_pending_note_hashes_contract', () => { const outgoingViewer = owner; // Add a note of value 10, with a note log // Then emit another note log with the same counter as the one above, but with value 5 - await deployedContract.methods.test_emit_bad_note_log(owner, outgoingViewer).send().wait(); + const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, outgoingViewer).send().wait(); - const syncStats = await wallet.getSyncStats(); - // Expect two incoming decryptable note logs to be emitted - expect(syncStats[owner.toString()].decryptedIncoming).toEqual(2); - // Expect one note log to be dropped - expect(syncStats[owner.toString()].failed).toEqual(1); + await deployedContract.methods.sync_notes().simulate(); + + const incomingNotes = await wallet.getIncomingNotes({ txHash: txReceipt.txHash }); + + expect(incomingNotes.length).toBe(1); }); }); diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts index 737575c3597f..15e77e4e7752 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts @@ -8,12 +8,9 @@ import { type DebugLogger, type DeployL1Contracts, EthAddress, - ExtendedNote, type Fq, Fr, - Note, type PXE, - type TxHash, createDebugLogger, deployL1Contract, } from '@aztec/aztec.js'; @@ -37,7 +34,6 @@ import solc from 'solc'; import { type Hex, getContract } from 'viem'; import { privateKeyToAddress } from 'viem/accounts'; -import { waitRegisteredAccountSynced } from '../benchmarks/utils.js'; import { getACVMConfig } from '../fixtures/get_acvm_config.js'; import { getBBConfig } from '../fixtures/get_bb_config.js'; import { @@ -222,17 +218,8 @@ export class FullProverTest { await result.pxe.registerContract(this.fakeProofsAsset); for (let i = 0; i < 2; i++) { - await waitRegisteredAccountSynced( - result.pxe, - this.keys[i][0], - this.wallets[i].getCompleteAddress().partialAddress, - ); - - await waitRegisteredAccountSynced( - this.pxe, - this.keys[i][0], - this.wallets[i].getCompleteAddress().partialAddress, - ); + await result.pxe.registerAccount(this.keys[i][0], this.wallets[i].getCompleteAddress().partialAddress); + await this.pxe.registerAccount(this.keys[i][0], this.wallets[i].getCompleteAddress().partialAddress); } const account = getSchnorrAccount(result.pxe, this.keys[0][0], this.keys[0][1], SALT); @@ -327,19 +314,6 @@ export class FullProverTest { await this.acvmConfigCleanup?.(); } - async addPendingShieldNoteToPXE(accountIndex: number, amount: bigint, secretHash: Fr, txHash: TxHash) { - const note = new Note([new Fr(amount), secretHash]); - const extendedNote = new ExtendedNote( - note, - this.accounts[accountIndex].address, - this.fakeProofsAsset.address, - TokenContract.storage.pending_shields.slot, - TokenContract.notes.TransparentNote.id, - txHash, - ); - await this.wallets[accountIndex].addNote(extendedNote); - } - async applyMintSnapshot() { await this.snapshotManager.snapshot( 'mint', @@ -352,7 +326,7 @@ export class FullProverTest { this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`); await asset.methods - .mint_public(accounts[0].address, privateAmount + publicAmount) + .mint_to_public(accounts[0].address, privateAmount + publicAmount) .send() .wait(waitOpts); @@ -375,8 +349,7 @@ export class FullProverTest { this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`); expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address)); - tokenSim.mintPrivate(amount); - tokenSim.redeemShield(address, amount); + tokenSim.mintPrivate(address, amount); const privateBalance = await asset.methods.balance_of_private(address).simulate(); this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`); expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address)); diff --git a/yarn-project/end-to-end/src/e2e_prover/full.test.ts b/yarn-project/end-to-end/src/e2e_prover/full.test.ts index 15662b971066..6bc9e3f30052 100644 --- a/yarn-project/end-to-end/src/e2e_prover/full.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/full.test.ts @@ -74,7 +74,7 @@ describe('full_prover', () => { const publicBalance = await provenAssets[1].methods.balance_of_public(sender).simulate(); const publicSendAmount = publicBalance / 10n; expect(publicSendAmount).toBeGreaterThan(0n); - const publicInteraction = provenAssets[1].methods.transfer_public(sender, recipient, publicSendAmount, 0); + const publicInteraction = provenAssets[1].methods.transfer_in_public(sender, recipient, publicSendAmount, 0); // Prove them logger.info(`Proving txs`); @@ -166,7 +166,7 @@ describe('full_prover', () => { } const privateInteraction = t.fakeProofsAsset.methods.transfer(recipient, 1n); - const publicInteraction = t.fakeProofsAsset.methods.transfer_public(sender, recipient, 1n, 0); + const publicInteraction = t.fakeProofsAsset.methods.transfer_in_public(sender, recipient, 1n, 0); const sentPrivateTx = privateInteraction.send({ skipPublicSimulation: true }); const sentPublicTx = publicInteraction.send({ skipPublicSimulation: true }); diff --git a/yarn-project/end-to-end/src/e2e_synching.test.ts b/yarn-project/end-to-end/src/e2e_synching.test.ts index 448b36e69c63..743c780bda86 100644 --- a/yarn-project/end-to-end/src/e2e_synching.test.ts +++ b/yarn-project/end-to-end/src/e2e_synching.test.ts @@ -36,7 +36,6 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr'; import { createArchiver } from '@aztec/archiver'; import { AztecNodeService } from '@aztec/aztec-node'; import { - type AccountWallet, type AccountWalletWithSecretKey, AnvilTestWatcher, BatchCall, @@ -48,7 +47,7 @@ import { sleep, } from '@aztec/aztec.js'; // eslint-disable-next-line no-restricted-imports -import { ExtendedNote, L2Block, LogType, Note, type TxHash, tryStop } from '@aztec/circuit-types'; +import { L2Block, LogType, tryStop } from '@aztec/circuit-types'; import { type AztecAddress } from '@aztec/circuits.js'; import { getL1ContractsConfigEnvVars } from '@aztec/ethereum'; import { Timer } from '@aztec/foundation/timer'; @@ -173,7 +172,7 @@ class TestVariant { if (this.txComplexity == TxComplexity.PublicTransfer) { await Promise.all( this.wallets.map(w => - this.token.methods.mint_public(w.getAddress(), MINT_AMOUNT).send().wait({ timeout: 600 }), + this.token.methods.mint_to_public(w.getAddress(), MINT_AMOUNT).send().wait({ timeout: 600 }), ), ); } @@ -184,27 +183,6 @@ class TestVariant { } } - private async addPendingShieldNoteToPXE(args: { - amount: bigint; - secretHash: Fr; - txHash: TxHash; - accountAddress: AztecAddress; - assetAddress: AztecAddress; - wallet: AccountWallet; - }) { - const { accountAddress, assetAddress, amount, secretHash, txHash, wallet } = args; - const note = new Note([new Fr(amount), secretHash]); - const extendedNote = new ExtendedNote( - note, - accountAddress, - assetAddress, - TokenContract.storage.pending_shields.slot, - TokenContract.notes.TransparentNote.id, - txHash, - ); - await wallet.addNote(extendedNote); - } - async createAndSendTxs() { if (!this.pxe) { throw new Error('Undefined PXE'); @@ -241,7 +219,7 @@ class TestVariant { const sender = this.wallets[i].getAddress(); const recipient = this.wallets[(i + 1) % this.txCount].getAddress(); const tk = await TokenContract.at(this.token.address, this.wallets[i]); - txs.push(tk.methods.transfer_public(sender, recipient, 1n, 0).send()); + txs.push(tk.methods.transfer_in_public(sender, recipient, 1n, 0).send()); } return txs; } else if (this.txComplexity == TxComplexity.Spam) { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts index ed23358282eb..0b7b10306bfb 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts @@ -116,7 +116,7 @@ describe('e2e_token_contract burn', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - await asset.methods.burn(accounts[0].address, amount, 0).send().wait(); + await asset.methods.burn_private(accounts[0].address, amount, 0).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); }); @@ -127,7 +127,7 @@ describe('e2e_token_contract burn', () => { expect(amount).toBeGreaterThan(0n); // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce); + const action = asset.withWallet(wallets[1]).methods.burn_private(accounts[0].address, amount, nonce); // Both wallets are connected to same node and PXE so we could just insert directly // But doing it in two actions to show the flow. @@ -137,11 +137,11 @@ describe('e2e_token_contract burn', () => { // We give wallets[1] access to wallets[0]'s notes to burn the note. wallets[1].setScopes([wallets[1].getAddress(), wallets[0].getAddress()]); - await asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send().wait(); + await asset.withWallet(wallets[1]).methods.burn_private(accounts[0].address, amount, nonce).send().wait(); tokenSim.burnPrivate(accounts[0].address, amount); // Perform the transfer again, should fail - const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); + const txReplay = asset.withWallet(wallets[1]).methods.burn_private(accounts[0].address, amount, nonce).send(); await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); @@ -150,7 +150,7 @@ describe('e2e_token_contract burn', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); const amount = balance0 + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrow( + await expect(asset.methods.burn_private(accounts[0].address, amount, 0).simulate()).rejects.toThrow( 'Assertion failed: Balance too low', ); }); @@ -159,7 +159,7 @@ describe('e2e_token_contract burn', () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrow( + await expect(asset.methods.burn_private(accounts[0].address, amount, 1).simulate()).rejects.toThrow( 'Assertion failed: invalid nonce', ); }); @@ -171,7 +171,7 @@ describe('e2e_token_contract burn', () => { expect(amount).toBeGreaterThan(0n); // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce); + const action = asset.withWallet(wallets[1]).methods.burn_private(accounts[0].address, amount, nonce); // Both wallets are connected to same node and PXE so we could just insert directly // But doing it in two actions to show the flow. @@ -188,7 +188,7 @@ describe('e2e_token_contract burn', () => { expect(amount).toBeGreaterThan(0n); // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce); + const action = asset.withWallet(wallets[1]).methods.burn_private(accounts[0].address, amount, nonce); const messageHash = computeAuthWitMessageHash( { caller: accounts[1].address, action: action.request() }, { chainId: wallets[0].getChainId(), version: wallets[0].getVersion() }, @@ -209,7 +209,7 @@ describe('e2e_token_contract burn', () => { expect(amount).toBeGreaterThan(0n); // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[2]).methods.burn(accounts[0].address, amount, nonce); + const action = asset.withWallet(wallets[2]).methods.burn_private(accounts[0].address, amount, nonce); const expectedMessageHash = computeAuthWitMessageHash( { caller: accounts[2].address, action: action.request() }, { chainId: wallets[0].getChainId(), version: wallets[0].getVersion() }, diff --git a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts index 484f62885336..b2fcc69add96 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts @@ -22,7 +22,7 @@ describe('e2e_token_contract minting', () => { describe('Public', () => { it('as minter', async () => { const amount = 10000n; - await asset.methods.mint_public(accounts[0].address, amount).send().wait(); + await asset.methods.mint_to_public(accounts[0].address, amount).send().wait(); tokenSim.mintPublic(accounts[0].address, amount); expect(await asset.methods.balance_of_public(accounts[0].address).simulate()).toEqual( @@ -35,27 +35,27 @@ describe('e2e_token_contract minting', () => { it('as non-minter', async () => { const amount = 10000n; await expect( - asset.withWallet(wallets[1]).methods.mint_public(accounts[0].address, amount).simulate(), + asset.withWallet(wallets[1]).methods.mint_to_public(accounts[0].address, amount).simulate(), ).rejects.toThrow('Assertion failed: caller is not minter'); }); it('mint >u128 tokens to overflow', async () => { const amount = 2n ** 128n; // U128::max() + 1; - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( + await expect(asset.methods.mint_to_public(accounts[0].address, amount).simulate()).rejects.toThrow( BITSIZE_TOO_BIG_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrow( + await expect(asset.methods.mint_to_public(accounts[0].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); it('mint u128', async () => { const amount = 2n ** 128n - tokenSim.balanceOfPublic(accounts[0].address); - await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrow( + await expect(asset.methods.mint_to_public(accounts[1].address, amount).simulate()).rejects.toThrow( U128_OVERFLOW_ERROR, ); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts deleted file mode 100644 index d7a576e09b59..000000000000 --- a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { Fr, computeSecretHash } from '@aztec/aztec.js'; - -import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; -import { TokenContractTest } from './token_contract_test.js'; - -describe('e2e_token_contract shield + redeem shield', () => { - const t = new TokenContractTest('shielding'); - let { asset, accounts, tokenSim, wallets } = t; - const secret = Fr.random(); - let secretHash: Fr; - - beforeAll(async () => { - await t.applyBaseSnapshots(); - await t.applyMintSnapshot(); - await t.setup(); - // Have to destructure again to ensure we have latest refs. - ({ asset, accounts, tokenSim, wallets } = t); - secretHash = computeSecretHash(secret); - }); - - afterAll(async () => { - await t.teardown(); - }); - - afterEach(async () => { - await t.tokenSim.check(); - }); - - it('on behalf of self', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub / 2n; - expect(amount).toBeGreaterThan(0n); - - const receipt = await asset.methods.shield(accounts[0].address, amount, secretHash, 0).send().wait(); - - tokenSim.shield(accounts[0].address, amount); - await tokenSim.check(); - - // Redeem it - await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); - await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); - - tokenSim.redeemShield(accounts[0].address, amount); - }); - - it('on behalf of other', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub / 2n; - const nonce = Fr.random(); - expect(amount).toBeGreaterThan(0n); - - // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce); - await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); - - const receipt = await action.send().wait(); - - tokenSim.shield(accounts[0].address, amount); - await tokenSim.check(); - - // Check that replaying the shield should fail! - await expect( - asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), - ).rejects.toThrow(/unauthorized/); - - // Redeem it - await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); - await asset.methods.redeem_shield(accounts[0].address, amount, secret).send().wait(); - - tokenSim.redeemShield(accounts[0].address, amount); - }); - - describe('failure cases', () => { - it('on behalf of self (more than balance)', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub + 1n; - expect(amount).toBeGreaterThan(0n); - - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrow( - U128_UNDERFLOW_ERROR, - ); - }); - - it('on behalf of self (invalid nonce)', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub + 1n; - expect(amount).toBeGreaterThan(0n); - - await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrow( - 'Assertion failed: invalid nonce', - ); - }); - - it('on behalf of other (more than balance)', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub + 1n; - const nonce = Fr.random(); - expect(amount).toBeGreaterThan(0n); - - // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce); - await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); - - await expect(action.simulate()).rejects.toThrow(U128_UNDERFLOW_ERROR); - }); - - it('on behalf of other (wrong designated caller)', async () => { - const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balancePub + 1n; - const nonce = Fr.random(); - expect(amount).toBeGreaterThan(0n); - - // We need to compute the message we want to sign and add it to the wallet as approved - const action = asset.withWallet(wallets[2]).methods.shield(accounts[0].address, amount, secretHash, nonce); - await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); - - await expect(action.simulate()).rejects.toThrow(/unauthorized/); - }); - - it('on behalf of other (without approval)', async () => { - const balance = await asset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balance / 2n; - const nonce = Fr.random(); - expect(amount).toBeGreaterThan(0n); - - await expect( - asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), - ).rejects.toThrow(/unauthorized/); - }); - }); -}); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts b/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts index 6ede484f6d2c..ccaea95bc3f8 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts @@ -1,14 +1,5 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr'; -import { - type AccountWallet, - type CompleteAddress, - type DebugLogger, - ExtendedNote, - Fr, - Note, - type TxHash, - createDebugLogger, -} from '@aztec/aztec.js'; +import { type AccountWallet, type CompleteAddress, type DebugLogger, createDebugLogger } from '@aztec/aztec.js'; import { DocsExampleContract, TokenContract } from '@aztec/noir-contracts.js'; import { jest } from '@jest/globals'; @@ -55,7 +46,14 @@ export class TokenContractTest { const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); this.wallets = await Promise.all(accountManagers.map(a => a.getWallet())); this.accounts = await pxe.getRegisteredAccounts(); - this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`)); + // // Add every wallet the contacts of every other wallet. This way, they can send notes to each other and discover them + // await Promise.all( + // this.wallets.map(w => { + // const otherWallets = this.wallets.filter(ow => ow.getAddress() !== w.getAddress()); + // return Promise.all(otherWallets.map(ow => w.registerContact(ow.getAddress()))); + // }), + // ); + // this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`)); }); await this.snapshotManager.snapshot( @@ -123,19 +121,6 @@ export class TokenContractTest { await this.snapshotManager.teardown(); } - async addPendingShieldNoteToPXE(accountIndex: number, amount: bigint, secretHash: Fr, txHash: TxHash) { - const note = new Note([new Fr(amount), secretHash]); - const extendedNote = new ExtendedNote( - note, - this.accounts[accountIndex].address, - this.asset.address, - TokenContract.storage.pending_shields.slot, - TokenContract.notes.TransparentNote.id, - txHash, - ); - await this.wallets[accountIndex].addNote(extendedNote); - } - async applyMintSnapshot() { await this.snapshotManager.snapshot( 'mint', @@ -144,7 +129,7 @@ export class TokenContractTest { const amount = 10000n; this.logger.verbose(`Minting ${amount} publicly...`); - await asset.methods.mint_public(wallets[0].getAddress(), amount).send().wait(); + await asset.methods.mint_to_public(wallets[0].getAddress(), amount).send().wait(); this.logger.verbose(`Minting ${amount} privately...`); await mintTokensToPrivate(asset, wallets[0], wallets[0].getAddress(), amount); @@ -164,8 +149,7 @@ export class TokenContractTest { this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`); expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address)); - tokenSim.mintPrivate(amount); - tokenSim.redeemShield(address, amount); + tokenSim.mintPrivate(address, amount); const privateBalance = await asset.methods.balance_of_private(address).simulate(); this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`); expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address)); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts new file mode 100644 index 000000000000..619f24c3a7d0 --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts @@ -0,0 +1,85 @@ +import { AztecAddress, CompleteAddress } from '@aztec/aztec.js'; +import { TokenContract, type Transfer } from '@aztec/noir-contracts.js'; + +import { TokenContractTest } from './token_contract_test.js'; + +describe('e2e_token_contract transfer private', () => { + const t = new TokenContractTest('transfer_private'); + let { asset, accounts, tokenSim, wallets } = t; + + beforeAll(async () => { + await t.applyBaseSnapshots(); + await t.applyMintSnapshot(); + await t.setup(); + ({ asset, accounts, tokenSim, wallets } = t); + }); + + afterAll(async () => { + await t.teardown(); + }); + + afterEach(async () => { + await t.tokenSim.check(); + }); + + it('transfer less than balance', async () => { + const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); + const amount = balance0 / 2n; + expect(amount).toBeGreaterThan(0n); + + // We give wallets[0] access to wallets[1]'s notes to be able to transfer the notes. + wallets[0].setScopes([wallets[0].getAddress(), wallets[1].getAddress()]); + + const tx = await asset.methods.transfer(accounts[1].address, amount).send().wait(); + tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); + + const events = await wallets[1].getEncryptedEvents(TokenContract.events.Transfer, tx.blockNumber!, 1); + + expect(events[0]).toEqual({ + from: accounts[0].address, + to: accounts[1].address, + amount: amount, + }); + }); + + it('transfer less than balance to non-deployed account', async () => { + const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); + const amount = balance0 / 2n; + expect(amount).toBeGreaterThan(0n); + + const nonDeployed = CompleteAddress.random(); + + await asset.methods.transfer(nonDeployed.address, amount).send().wait(); + + // Add the account as balance we should change, but since we don't have the key, + // we cannot decrypt, and instead we simulate a transfer to address(0) + tokenSim.addAccount(nonDeployed.address); + tokenSim.transferPrivate(accounts[0].address, AztecAddress.ZERO, amount); + }); + + it('transfer to self', async () => { + const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); + const amount = balance0 / 2n; + expect(amount).toBeGreaterThan(0n); + await asset.methods.transfer(accounts[0].address, amount).send().wait(); + tokenSim.transferPrivate(accounts[0].address, accounts[0].address, amount); + }); + + describe('failure cases', () => { + it('transfer more than balance', async () => { + const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); + const amount = balance0 + 1n; + expect(amount).toBeGreaterThan(0n); + await expect(asset.methods.transfer(accounts[1].address, amount).simulate()).rejects.toThrow( + 'Assertion failed: Balance too low', + ); + }); + + it.skip('transfer into account to overflow', () => { + // This should already be covered by the mint case earlier. e.g., since we cannot mint to overflow, there is not + // a way to get funds enough to overflow. + // Require direct storage manipulation for us to perform a nice explicit case though. + // See https://github.com/AztecProtocol/aztec-packages/issues/1259 + }); + }); +}); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts similarity index 69% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts rename to yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts index b1a81efd77b8..d2cf242aff0d 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts @@ -1,11 +1,4 @@ -import { - AztecAddress, - CompleteAddress, - Fr, - computeAuthWitMessageHash, - computeInnerAuthWitHashFromAction, -} from '@aztec/aztec.js'; -import { TokenContract, type Transfer } from '@aztec/noir-contracts.js'; +import { Fr, computeAuthWitMessageHash, computeInnerAuthWitHashFromAction } from '@aztec/aztec.js'; import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; @@ -29,49 +22,6 @@ describe('e2e_token_contract transfer private', () => { await t.tokenSim.check(); }); - it('transfer less than balance', async () => { - const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); - const amount = balance0 / 2n; - expect(amount).toBeGreaterThan(0n); - - // We give wallets[0] access to wallets[1]'s notes to be able to transfer the notes. - wallets[0].setScopes([wallets[0].getAddress(), wallets[1].getAddress()]); - - const tx = await asset.methods.transfer(accounts[1].address, amount).send().wait(); - tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); - - const events = await wallets[1].getEncryptedEvents(TokenContract.events.Transfer, tx.blockNumber!, 1); - - expect(events[0]).toEqual({ - from: accounts[0].address, - to: accounts[1].address, - amount: amount, - }); - }); - - it('transfer less than balance to non-deployed account', async () => { - const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); - const amount = balance0 / 2n; - expect(amount).toBeGreaterThan(0n); - - const nonDeployed = CompleteAddress.random(); - - await asset.methods.transfer(nonDeployed.address, amount).send().wait(); - - // Add the account as balance we should change, but since we don't have the key, - // we cannot decrypt, and instead we simulate a transfer to address(0) - tokenSim.addAccount(nonDeployed.address); - tokenSim.transferPrivate(accounts[0].address, AztecAddress.ZERO, amount); - }); - - it('transfer to self', async () => { - const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); - const amount = balance0 / 2n; - expect(amount).toBeGreaterThan(0n); - await asset.methods.transfer(accounts[0].address, amount).send().wait(); - tokenSim.transferPrivate(accounts[0].address, accounts[0].address, amount); - }); - it('transfer on behalf of other', async () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); const amount = balance0 / 2n; @@ -82,7 +32,7 @@ describe('e2e_token_contract transfer private', () => { // docs:start:authwit_transfer_example const action = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce); const witness = await wallets[0].createAuthWit({ caller: accounts[1].address, action }); await wallets[1].addAuthWitness(witness); @@ -102,30 +52,18 @@ describe('e2e_token_contract transfer private', () => { // Perform the transfer again, should fail const txReplay = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce) + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce) .send(); await expect(txReplay.wait()).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); - - // We let wallets[0] see wallets[1]'s notes because the check uses wallets[0]'s wallet to interact with the contracts to "get" state. - wallets[0].setScopes([wallets[0].getAddress(), wallets[1].getAddress()]); }); describe('failure cases', () => { - it('transfer more than balance', async () => { - const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); - const amount = balance0 + 1n; - expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.transfer(accounts[1].address, amount).simulate()).rejects.toThrow( - 'Assertion failed: Balance too low', - ); - }); - it('transfer on behalf of self with non-zero nonce', async () => { const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); await expect( - asset.methods.transfer_from(accounts[0].address, accounts[1].address, amount, 1).simulate(), + asset.methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, 1).simulate(), ).rejects.toThrow('Assertion failed: invalid nonce'); }); @@ -139,7 +77,7 @@ describe('e2e_token_contract transfer private', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce); // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); @@ -169,7 +107,7 @@ describe('e2e_token_contract transfer private', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce); const messageHash = computeAuthWitMessageHash( { caller: accounts[1].address, action: action.request() }, { @@ -192,7 +130,7 @@ describe('e2e_token_contract transfer private', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[2]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce); const expectedMessageHash = computeAuthWitMessageHash( { caller: accounts[2].address, action: action.request() }, { @@ -222,7 +160,7 @@ describe('e2e_token_contract transfer private', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce); const intent = { caller: accounts[1].address, action }; @@ -245,7 +183,7 @@ describe('e2e_token_contract transfer private', () => { // Perform the transfer, should fail because nullifier already emitted const txCancelledAuthwit = asset .withWallet(wallets[1]) - .methods.transfer_from(accounts[0].address, accounts[1].address, amount, nonce) + .methods.transfer_in_private(accounts[0].address, accounts[1].address, amount, nonce) .send(); await expect(txCancelledAuthwit.wait()).rejects.toThrowError(DUPLICATE_NULLIFIER_ERROR); }); @@ -256,7 +194,7 @@ describe('e2e_token_contract transfer private', () => { // Should fail as the returned value from the badAccount is malformed const txCancelledAuthwit = asset .withWallet(wallets[1]) - .methods.transfer_from(badAccount.address, accounts[1].address, 0, nonce) + .methods.transfer_in_private(badAccount.address, accounts[1].address, 0, nonce) .send(); await expect(txCancelledAuthwit.wait()).rejects.toThrow( "Assertion failed: Message not authorized by account 'result == IS_VALID_SELECTOR'", diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts similarity index 85% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts rename to yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts index 5ba38158564b..0c92a459ad0b 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts @@ -4,7 +4,7 @@ import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract transfer public', () => { - const t = new TokenContractTest('transfer_public'); + const t = new TokenContractTest('transfer_in_public'); let { asset, accounts, tokenSim, wallets, badAccount } = t; beforeAll(async () => { @@ -27,7 +27,7 @@ describe('e2e_token_contract transfer public', () => { const balance0 = await asset.methods.balance_of_public(accounts[0].address).simulate(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - await asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send().wait(); + await asset.methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); }); @@ -36,7 +36,7 @@ describe('e2e_token_contract transfer public', () => { const balance = await asset.methods.balance_of_public(accounts[0].address).simulate(); const amount = balance / 2n; expect(amount).toBeGreaterThan(0n); - await asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send().wait(); + await asset.methods.transfer_in_public(accounts[0].address, accounts[0].address, amount, 0).send().wait(); tokenSim.transferPublic(accounts[0].address, accounts[0].address, amount); }); @@ -50,7 +50,7 @@ describe('e2e_token_contract transfer public', () => { // docs:start:authwit_public_transfer_example const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); // docs:end:authwit_public_transfer_example @@ -64,7 +64,7 @@ describe('e2e_token_contract transfer public', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrow(/unauthorized/); }); @@ -75,7 +75,7 @@ describe('e2e_token_contract transfer public', () => { const amount = balance0 + 1n; const nonce = 0; await expect( - asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), + asset.methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), ).rejects.toThrow(U128_UNDERFLOW_ERROR); }); @@ -84,7 +84,7 @@ describe('e2e_token_contract transfer public', () => { const amount = balance0 - 1n; const nonce = 1; await expect( - asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), + asset.methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), ).rejects.toThrow('Assertion failed: invalid nonce'); }); @@ -95,7 +95,7 @@ describe('e2e_token_contract transfer public', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrow(/unauthorized/); }); @@ -109,7 +109,7 @@ describe('e2e_token_contract transfer public', () => { const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); expect(await wallets[0].lookupValidity(wallets[0].getAddress(), { caller: accounts[1].address, action })).toEqual( { @@ -145,7 +145,7 @@ describe('e2e_token_contract transfer public', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); await wallets[0].setPublicAuthWit({ caller: accounts[0].address, action }, true).send().wait(); @@ -166,7 +166,7 @@ describe('e2e_token_contract transfer public', () => { // We need to compute the message we want to sign and add it to the wallet as approved const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); await wallets[0].setPublicAuthWit({ caller: accounts[0].address, action }, true).send().wait(); // Perform the transfer @@ -184,7 +184,7 @@ describe('e2e_token_contract transfer public', () => { const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); @@ -193,7 +193,7 @@ describe('e2e_token_contract transfer public', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError(/unauthorized/); }); @@ -206,7 +206,7 @@ describe('e2e_token_contract transfer public', () => { const action = asset .withWallet(wallets[1]) - .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce); + .methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, nonce); await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); @@ -221,7 +221,7 @@ describe('e2e_token_contract transfer public', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public(badAccount.address, accounts[1].address, 0, nonce) + .methods.transfer_in_public(badAccount.address, accounts[1].address, 0, nonce) .simulate(), ).rejects.toThrow(/unauthorized/); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts new file mode 100644 index 000000000000..c0f6c1368b2e --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts @@ -0,0 +1,59 @@ +import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; +import { TokenContractTest } from './token_contract_test.js'; + +describe('e2e_token_contract transfer_to_private', () => { + const t = new TokenContractTest('transfer_to_private'); + let { asset, accounts, tokenSim } = t; + + beforeAll(async () => { + await t.applyBaseSnapshots(); + await t.applyMintSnapshot(); + await t.setup(); + // Have to destructure again to ensure we have latest refs. + ({ asset, accounts, tokenSim } = t); + }); + + afterAll(async () => { + await t.teardown(); + }); + + afterEach(async () => { + await t.tokenSim.check(); + }); + + it('to self', async () => { + const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); + const amount = balancePub / 2n; + expect(amount).toBeGreaterThan(0n); + + await asset.methods.transfer_to_private(accounts[0].address, amount).send().wait(); + + // Check that the result matches token sim + tokenSim.transferToPrivate(accounts[0].address, accounts[0].address, amount); + await tokenSim.check(); + }); + + it('to someone else', async () => { + const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); + const amount = balancePub / 2n; + expect(amount).toBeGreaterThan(0n); + + await asset.methods.transfer_to_private(accounts[1].address, amount).send().wait(); + + // Check that the result matches token sim + tokenSim.transferToPrivate(accounts[0].address, accounts[1].address, amount); + await tokenSim.check(); + }); + + describe('failure cases', () => { + it('to self (more than balance)', async () => { + const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); + const amount = balancePub + 1n; + expect(amount).toBeGreaterThan(0n); + + await expect(asset.methods.transfer_to_private(accounts[0].address, amount).simulate()).rejects.toThrow( + U128_UNDERFLOW_ERROR, + ); + }); + }); +}); diff --git a/yarn-project/end-to-end/src/fixtures/token_utils.ts b/yarn-project/end-to-end/src/fixtures/token_utils.ts index 834438f686f6..6769aae9daab 100644 --- a/yarn-project/end-to-end/src/fixtures/token_utils.ts +++ b/yarn-project/end-to-end/src/fixtures/token_utils.ts @@ -1,4 +1,4 @@ -import { type AztecAddress, type DebugLogger, type Wallet, retryUntil } from '@aztec/aztec.js'; +import { type AztecAddress, type DebugLogger, type Wallet } from '@aztec/aztec.js'; import { TokenContract } from '@aztec/noir-contracts.js'; export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigint, logger: DebugLogger) { @@ -28,26 +28,13 @@ export async function mintTokensToPrivate( await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait(); } -const awaitUserSynchronized = async (wallet: Wallet, owner: AztecAddress) => { - const isUserSynchronized = async () => { - return await wallet.isAccountStateSynchronized(owner); - }; - await retryUntil(isUserSynchronized, `synch of user ${owner.toString()}`, 10); -}; - export async function expectTokenBalance( wallet: Wallet, token: TokenContract, owner: AztecAddress, expectedBalance: bigint, logger: DebugLogger, - checkIfSynchronized = true, ) { - if (checkIfSynchronized) { - // First wait until the corresponding PXE has synchronized the account - await awaitUserSynchronized(wallet, owner); - } - // Then check the balance const contractWithWallet = await TokenContract.at(token.address, wallet); const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner }); diff --git a/yarn-project/end-to-end/src/flakey_e2e_inclusion_proofs_contract.test.ts b/yarn-project/end-to-end/src/flakey_e2e_inclusion_proofs_contract.test.ts index 5fb6a8e61130..534300c633a7 100644 --- a/yarn-project/end-to-end/src/flakey_e2e_inclusion_proofs_contract.test.ts +++ b/yarn-project/end-to-end/src/flakey_e2e_inclusion_proofs_contract.test.ts @@ -62,7 +62,10 @@ describe('e2e_inclusion_proofs_contract', () => { const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; - ({ noteHashes, visibleIncomingNotes } = receipt.debugInfo!); + ({ noteHashes } = receipt.debugInfo!); + + await contract.methods.sync_notes().simulate(); + visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash }); }); it('should return the correct values for creating a note', () => { @@ -155,7 +158,10 @@ describe('e2e_inclusion_proofs_contract', () => { const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; - const { noteHashes, visibleIncomingNotes } = receipt.debugInfo!; + const { noteHashes } = receipt.debugInfo!; + + await contract.methods.sync_notes().simulate(); + const visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash }); expect(noteHashes.length).toBe(1); expect(visibleIncomingNotes.length).toBe(1); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 1fea34910177..001ecca4712b 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -106,6 +106,7 @@ describe('guides/dapp/testing', () => { it('checks private storage', async () => { // docs:start:private-storage + await token.methods.sync_notes().simulate(); const notes = await pxe.getIncomingNotes({ owner: owner.getAddress(), contractAddress: token.address, @@ -120,8 +121,11 @@ describe('guides/dapp/testing', () => { it('checks public storage', async () => { // docs:start:public-storage - await token.methods.mint_public(owner.getAddress(), 100n).send().wait(); - const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap(6n, owner.getAddress()); + await token.methods.mint_to_public(owner.getAddress(), 100n).send().wait(); + const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap( + TokenContract.storage.public_balances.slot, + owner.getAddress(), + ); const balance = await pxe.getPublicStorageAt(token.address, ownerPublicBalanceSlot); expect(balance.value).toEqual(100n); // docs:end:public-storage @@ -169,17 +173,20 @@ describe('guides/dapp/testing', () => { it('asserts a simulation for a public function call fails', async () => { // docs:start:local-pub-fails - const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); + const call = token.methods.transfer_in_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); await expect(call.prove()).rejects.toThrow(U128_UNDERFLOW_ERROR); // docs:end:local-pub-fails }); it('asserts a transaction with a failing public call is included (with no state changes)', async () => { // docs:start:pub-reverted - const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); + const call = token.methods.transfer_in_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); const receipt = await call.send({ skipPublicSimulation: true }).wait({ dontThrowOnRevert: true }); expect(receipt.status).toEqual(TxStatus.APP_LOGIC_REVERTED); - const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap(6n, owner.getAddress()); + const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap( + TokenContract.storage.public_balances.slot, + owner.getAddress(), + ); const balance = await pxe.getPublicStorageAt(token.address, ownerPublicBalanceSlot); expect(balance.value).toEqual(100n); // docs:end:pub-reverted diff --git a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts index 3840c08a3bf3..678aeaa5682e 100644 --- a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts +++ b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts @@ -80,7 +80,7 @@ describe('guides/writing_an_account_contract', () => { const tokenWithWrongWallet = token.withWallet(wrongWallet); try { - await tokenWithWrongWallet.methods.mint_public(address, 200).prove(); + await tokenWithWrongWallet.methods.mint_to_public(address, 200).prove(); } catch (err) { logger.info(`Failed to send tx: ${err}`); } diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index 2c68a011117e..fff9f14e117a 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -84,7 +84,7 @@ async function mintPublicFunds(pxe) { await showPublicBalances(pxe); console.log(`Sending transaction, awaiting transaction to be mined`); - const receipt = await token.methods.mint_public(owner.getAddress(), 100).send().wait(); + const receipt = await token.methods.mint_to_public(owner.getAddress(), 100).send().wait(); console.log(`Transaction ${receipt.txHash} has been mined on block ${receipt.blockNumber}`); await showPublicBalances(pxe); diff --git a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts index b561aa03488d..d68750db2302 100644 --- a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts @@ -1,20 +1,18 @@ // docs:start:cross_chain_test_harness import { + type AccountWallet, type AztecAddress, type AztecNode, type DebugLogger, EthAddress, - ExtendedNote, type FieldsOf, Fr, type L1TokenManager, L1TokenPortalManager, type L2AmountClaim, type L2AmountClaimWithRecipient, - Note, type PXE, type SiblingPath, - type TxHash, type TxReceipt, type Wallet, deployL1Contract, @@ -141,7 +139,7 @@ export class CrossChainTestHarness { pxeService: PXE, publicClient: PublicClient, walletClient: WalletClient, - wallet: Wallet, + wallet: AccountWallet, logger: DebugLogger, underlyingERC20Address?: EthAddress, ): Promise { @@ -210,7 +208,7 @@ export class CrossChainTestHarness { public readonly l1ContractAddresses: L1ContractAddresses, /** Wallet of the owner. */ - public readonly ownerWallet: Wallet, + public readonly ownerWallet: AccountWallet, ) { this.l1TokenPortalManager = new L1TokenPortalManager( this.tokenPortalAddress, @@ -243,7 +241,7 @@ export class CrossChainTestHarness { async mintTokensPublicOnL2(amount: bigint) { this.logger.info('Minting tokens on L2 publicly'); - await this.l2Token.methods.mint_public(this.ownerAddress, amount).send().wait(); + await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send().wait(); } async mintTokensPrivateOnL2(amount: bigint) { @@ -252,7 +250,7 @@ export class CrossChainTestHarness { async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) { // send a transfer tx to force through rollup with the message included - await this.l2Token.methods.transfer_public(this.ownerAddress, receiverAddress, transferAmount, 0).send().wait(); + await this.l2Token.methods.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0).send().wait(); } async consumeMessageOnAztecAndMintPrivately( @@ -343,20 +341,6 @@ export class CrossChainTestHarness { await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send().wait(); } - async addPendingShieldNoteToPXE(shieldAmount: bigint, secretHash: Fr, txHash: TxHash) { - this.logger.info('Adding note to PXE'); - const note = new Note([new Fr(shieldAmount), secretHash]); - const extendedNote = new ExtendedNote( - note, - this.ownerAddress, - this.l2Token.address, - TokenContract.storage.pending_shields.slot, - TokenContract.notes.TransparentNote.id, - txHash, - ); - await this.ownerWallet.addNote(extendedNote); - } - async transferToPublicOnL2(amount: bigint, nonce = Fr.ZERO) { this.logger.info('Transferring tokens to public'); await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, nonce).send().wait(); diff --git a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts index 6e5942539853..ef6b20c00186 100644 --- a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts +++ b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts @@ -418,7 +418,7 @@ export const uniswapL1L2TestSuite = ( // { // caller: uniswapL2Contract.address, // action: wethCrossChainHarness.l2Token.methods - // .transfer_public( + // .transfer_in_public( // ownerAddress, // uniswapL2Contract.address, // wethAmountToBridge, @@ -690,7 +690,7 @@ export const uniswapL1L2TestSuite = ( { caller: uniswapL2Contract.address, action: wethCrossChainHarness.l2Token.methods - .transfer_public( + .transfer_in_public( ownerAddress, uniswapL2Contract.address, wethAmountToBridge, @@ -762,7 +762,7 @@ export const uniswapL1L2TestSuite = ( { caller: uniswapL2Contract.address, action: wethCrossChainHarness.l2Token.methods - .transfer_public( + .transfer_in_public( ownerAddress, uniswapL2Contract.address, wethAmountToBridge, @@ -932,7 +932,7 @@ export const uniswapL1L2TestSuite = ( { caller: uniswapL2Contract.address, action: wethCrossChainHarness.l2Token.methods - .transfer_public( + .transfer_in_public( ownerAddress, uniswapL2Contract.address, wethAmountToBridge, diff --git a/yarn-project/end-to-end/src/simulators/lending_simulator.ts b/yarn-project/end-to-end/src/simulators/lending_simulator.ts index 288cac32eaf0..d09741b637e6 100644 --- a/yarn-project/end-to-end/src/simulators/lending_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/lending_simulator.ts @@ -166,7 +166,7 @@ export class LendingSimulator { mintStableCoinOutsideLoan(recipient: AztecAddress, amount: bigint, priv = false) { if (priv) { - this.stableCoin.mintPrivate(amount); + this.stableCoin.mintPrivate(recipient, amount); } else { this.stableCoin.mintPublic(recipient, amount); } diff --git a/yarn-project/end-to-end/src/simulators/token_simulator.ts b/yarn-project/end-to-end/src/simulators/token_simulator.ts index 03caf19ab169..53a4c5d6e2c9 100644 --- a/yarn-project/end-to-end/src/simulators/token_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/token_simulator.ts @@ -26,8 +26,9 @@ export class TokenSimulator { this.lookupProvider.set(account.toString(), wallet); } - public mintPrivate(amount: bigint) { + public mintPrivate(to: AztecAddress, amount: bigint) { this.totalSupply += amount; + this.balancesPrivate.set(to.toString(), (this.balancesPrivate.get(to.toString()) || 0n) + amount); } public mintPublic(to: AztecAddress, amount: bigint) { @@ -54,13 +55,10 @@ export class TokenSimulator { this.balancesPrivate.set(to.toString(), toBalance + amount); } - public shield(from: AztecAddress, amount: bigint) { + public transferToPrivate(from: AztecAddress, to: AztecAddress, amount: bigint) { const fromBalance = this.balancePublic.get(from.toString()) || 0n; expect(fromBalance).toBeGreaterThanOrEqual(amount); this.balancePublic.set(from.toString(), fromBalance - amount); - } - - public redeemShield(to: AztecAddress, amount: bigint) { const toBalance = this.balancesPrivate.get(to.toString()) || 0n; this.balancesPrivate.set(to.toString(), toBalance + amount); } diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts index 9c601e1fa269..354da3335f0b 100644 --- a/yarn-project/end-to-end/src/spartan/4epochs.test.ts +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -80,7 +80,7 @@ describe('token transfer test', () => { ...testWallets.wallets.map(async w => ( await TokenContract.at(testWallets.tokenAddress, w) - ).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), + ).methods.transfer_in_public(w.getAddress(), recipient, transferAmount, 0), ), ]); diff --git a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts index 5feb52d1de8e..bb4528707a90 100644 --- a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts +++ b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts @@ -69,7 +69,7 @@ export async function setupTestWalletsWithTokens( logger.verbose(`Minting ${mintAmount} public assets to the ${wallets.length} wallets...`); await Promise.all( - wallets.map(w => tokenAdminWallet.methods.mint_public(w.getAddress(), mintAmount).send().wait({ timeout: 600 })), + wallets.map(w => tokenAdminWallet.methods.mint_to_public(w.getAddress(), mintAmount).send().wait({ timeout: 600 })), ); logger.verbose(`Minting complete.`); @@ -95,7 +95,7 @@ export async function performTransfers({ testWallets.wallets.map(async w => ( await TokenContract.at(testWallets.tokenAddress, w) - ).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), + ).methods.transfer_in_public(w.getAddress(), recipient, transferAmount, 0), ), ); diff --git a/yarn-project/end-to-end/src/spartan/transfer.test.ts b/yarn-project/end-to-end/src/spartan/transfer.test.ts index 2988c23b9cba..a073247cae3e 100644 --- a/yarn-project/end-to-end/src/spartan/transfer.test.ts +++ b/yarn-project/end-to-end/src/spartan/transfer.test.ts @@ -57,7 +57,7 @@ describe('token transfer test', () => { ...testWallets.wallets.map(async w => ( await TokenContract.at(testWallets.tokenAddress, w) - ).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), + ).methods.transfer_in_public(w.getAddress(), recipient, transferAmount, 0), ), ]); diff --git a/yarn-project/ivc-integration/package.json b/yarn-project/ivc-integration/package.json index c74cfa2e5be5..c9fc4dae62ee 100644 --- a/yarn-project/ivc-integration/package.json +++ b/yarn-project/ivc-integration/package.json @@ -18,7 +18,7 @@ "formatting:fix:types": "NODE_OPTIONS='--max-old-space-size=8096' run -T eslint --fix ./src/types && run -T prettier -w ./src/types", "generate": "yarn generate:noir-circuits", "generate:noir-circuits": "mkdir -p ./artifacts && cp -r ../../noir-projects/mock-protocol-circuits/target/* ./artifacts && node --no-warnings --loader ts-node/esm src/scripts/generate_declaration_files.ts && node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", - "test:non-browser": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --testPathIgnorePatterns=browser", + "test:non-browser": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testPathIgnorePatterns=browser --passWithNoTests ", "test:browser": "./run_browser_tests.sh", "test": "yarn test:non-browser", "codegen": "yarn noir-codegen", @@ -78,7 +78,10 @@ }, "devDependencies": { "@aztec/bb-prover": "workspace:^", + "@aztec/kv-store": "workspace:^", "@aztec/simulator": "workspace:^", + "@aztec/telemetry-client": "workspace:^", + "@aztec/world-state": "workspace:^", "@jest/globals": "^29.5.0", "@msgpack/msgpack": "^3.0.0-beta2", "@playwright/test": "^1.48.2", diff --git a/yarn-project/ivc-integration/package.local.json b/yarn-project/ivc-integration/package.local.json index 8625c9c135c2..82e5715546b1 100644 --- a/yarn-project/ivc-integration/package.local.json +++ b/yarn-project/ivc-integration/package.local.json @@ -2,7 +2,7 @@ "scripts": { "build": "yarn clean && yarn generate && rm -rf dest && webpack && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts", - "test:non-browser":"NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --testPathIgnorePatterns=browser", + "test:non-browser":"NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testPathIgnorePatterns=browser --passWithNoTests ", "test:browser": "./run_browser_tests.sh", "test": "yarn test:non-browser" }, diff --git a/yarn-project/ivc-integration/src/avm_integration.test.ts b/yarn-project/ivc-integration/src/avm_integration.test.ts index 7e65402008b7..967fd92bc1cf 100644 --- a/yarn-project/ivc-integration/src/avm_integration.test.ts +++ b/yarn-project/ivc-integration/src/avm_integration.test.ts @@ -27,6 +27,7 @@ import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec import { Fr, Point } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; import { BufferReader } from '@aztec/foundation/serialize'; +import { openTmpStore } from '@aztec/kv-store/utils'; import { type FixedLengthArray } from '@aztec/noir-protocol-circuits-types/types'; import { AvmSimulator, PublicSideEffectTrace, type WorldStateDB } from '@aztec/simulator'; import { @@ -37,6 +38,8 @@ import { initPersistableStateManager, resolveAvmTestContractAssertionMessage, } from '@aztec/simulator/avm/fixtures'; +import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; +import { MerkleTrees } from '@aztec/world-state'; import { jest } from '@jest/globals'; import fs from 'fs/promises'; @@ -197,7 +200,10 @@ const proveAvmTestContract = async ( worldStateDB.storageRead.mockResolvedValue(storageValue); const trace = new PublicSideEffectTrace(startSideEffectCounter); - const persistableState = initPersistableStateManager({ worldStateDB, trace }); + const telemetry = new NoopTelemetryClient(); + const merkleTrees = await (await MerkleTrees.new(openTmpStore(), telemetry)).fork(); + worldStateDB.getMerkleInterface.mockReturnValue(merkleTrees); + const persistableState = initPersistableStateManager({ worldStateDB, trace, merkleTrees, doMerkleOperations: true }); const environment = initExecutionEnvironment({ functionSelector, calldata, diff --git a/yarn-project/ivc-integration/tsconfig.json b/yarn-project/ivc-integration/tsconfig.json index 1b3f38e75d31..e9e2f12cb2c9 100644 --- a/yarn-project/ivc-integration/tsconfig.json +++ b/yarn-project/ivc-integration/tsconfig.json @@ -19,9 +19,22 @@ { "path": "../bb-prover" }, + { + "path": "../kv-store" + }, { "path": "../simulator" + }, + { + "path": "../telemetry-client" + }, + { + "path": "../world-state" } ], - "include": ["src", "artifacts/*.d.json.ts", "artifacts/**/*.d.json.ts"] + "include": [ + "src", + "artifacts/*.d.json.ts", + "artifacts/**/*.d.json.ts" + ] } diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts index 4f0147f12aee..0bfc86ba3358 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts @@ -42,6 +42,7 @@ import { type L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, LogHash, + MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_TX, @@ -991,7 +992,7 @@ export function mapPrivateCircuitPublicInputsToNoir( end_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.endSideEffectCounter), note_encrypted_logs_hashes: mapTuple(privateCircuitPublicInputs.noteEncryptedLogsHashes, mapNoteLogHashToNoir), encrypted_logs_hashes: mapTuple(privateCircuitPublicInputs.encryptedLogsHashes, mapEncryptedLogHashToNoir), - unencrypted_logs_hashes: mapTuple(privateCircuitPublicInputs.unencryptedLogsHashes, mapLogHashToNoir), + contract_class_logs_hashes: mapTuple(privateCircuitPublicInputs.contractClassLogsHashes, mapLogHashToNoir), historical_header: mapHeaderToNoir(privateCircuitPublicInputs.historicalHeader), tx_context: mapTxContextToNoir(privateCircuitPublicInputs.txContext), min_revertible_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.minRevertibleSideEffectCounter), @@ -1384,8 +1385,8 @@ export function mapPrivateAccumulatedDataFromNoir( mapScopedEncryptedLogHashFromNoir, ), mapTupleFromNoir( - privateAccumulatedData.unencrypted_logs_hashes, - MAX_UNENCRYPTED_LOGS_PER_TX, + privateAccumulatedData.contract_class_logs_hashes, + MAX_CONTRACT_CLASS_LOGS_PER_TX, mapScopedLogHashFromNoir, ), mapTupleFromNoir( @@ -1408,7 +1409,7 @@ export function mapPrivateAccumulatedDataToNoir(data: PrivateAccumulatedData): P l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), note_encrypted_logs_hashes: mapTuple(data.noteEncryptedLogsHashes, mapNoteLogHashToNoir), encrypted_logs_hashes: mapTuple(data.encryptedLogsHashes, mapScopedEncryptedLogHashToNoir), - unencrypted_logs_hashes: mapTuple(data.unencryptedLogsHashes, mapScopedLogHashToNoir), + contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), public_call_requests: mapTuple(data.publicCallRequests, mapCountedPublicCallRequestToNoir), private_call_stack: mapTuple(data.privateCallStack, mapPrivateCallRequestToNoir), }; @@ -1537,7 +1538,7 @@ function mapPrivateToPublicAccumulatedDataFromNoir(data: PrivateToPublicAccumula mapTupleFromNoir(data.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), mapTupleFromNoir(data.note_encrypted_logs_hashes, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, mapLogHashFromNoir), mapTupleFromNoir(data.encrypted_logs_hashes, MAX_ENCRYPTED_LOGS_PER_TX, mapScopedLogHashFromNoir), - mapTupleFromNoir(data.unencrypted_logs_hashes, MAX_UNENCRYPTED_LOGS_PER_TX, mapScopedLogHashFromNoir), + mapTupleFromNoir(data.contract_class_logs_hashes, MAX_CONTRACT_CLASS_LOGS_PER_TX, mapScopedLogHashFromNoir), mapTupleFromNoir(data.public_call_requests, MAX_ENQUEUED_CALLS_PER_TX, mapPublicCallRequestFromNoir), ); } @@ -1551,7 +1552,7 @@ function mapPrivateToPublicAccumulatedDataToNoir( l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), note_encrypted_logs_hashes: mapTuple(data.noteEncryptedLogsHashes, mapLogHashToNoir), encrypted_logs_hashes: mapTuple(data.encryptedLogsHashes, mapScopedLogHashToNoir), - unencrypted_logs_hashes: mapTuple(data.unencryptedLogsHashes, mapScopedLogHashToNoir), + contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), public_call_requests: mapTuple(data.publicCallRequests, mapPublicCallRequestToNoir), }; } @@ -1611,9 +1612,15 @@ export function mapCombinedAccumulatedDataFromNoir( MAX_UNENCRYPTED_LOGS_PER_TX, mapScopedLogHashFromNoir, ), + mapTupleFromNoir( + combinedAccumulatedData.contract_class_logs_hashes, + MAX_CONTRACT_CLASS_LOGS_PER_TX, + mapScopedLogHashFromNoir, + ), mapFieldFromNoir(combinedAccumulatedData.note_encrypted_log_preimages_length), mapFieldFromNoir(combinedAccumulatedData.encrypted_log_preimages_length), mapFieldFromNoir(combinedAccumulatedData.unencrypted_log_preimages_length), + mapFieldFromNoir(combinedAccumulatedData.contract_class_log_preimages_length), mapTupleFromNoir( combinedAccumulatedData.public_data_writes, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, @@ -1632,9 +1639,11 @@ export function mapCombinedAccumulatedDataToNoir( note_encrypted_logs_hashes: mapTuple(combinedAccumulatedData.noteEncryptedLogsHashes, mapLogHashToNoir), encrypted_logs_hashes: mapTuple(combinedAccumulatedData.encryptedLogsHashes, mapScopedLogHashToNoir), unencrypted_logs_hashes: mapTuple(combinedAccumulatedData.unencryptedLogsHashes, mapScopedLogHashToNoir), + contract_class_logs_hashes: mapTuple(combinedAccumulatedData.contractClassLogsHashes, mapScopedLogHashToNoir), note_encrypted_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.noteEncryptedLogPreimagesLength), encrypted_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.encryptedLogPreimagesLength), unencrypted_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.unencryptedLogPreimagesLength), + contract_class_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.contractClassLogPreimagesLength), public_data_writes: mapTuple(combinedAccumulatedData.publicDataWrites, mapPublicDataWriteToNoir), }; } @@ -2126,6 +2135,7 @@ function mapAvmCircuitPublicInputsToNoir(inputs: AvmCircuitPublicInputs): AvmCir inputs.previousRevertibleAccumulatedData, ), end_tree_snapshots: mapTreeSnapshotsToNoir(inputs.endTreeSnapshots), + end_gas_used: mapGasToNoir(inputs.endGasUsed), accumulated_data: mapAvmAccumulatedDataToNoir(inputs.accumulatedData), transaction_fee: mapFieldToNoir(inputs.transactionFee), reverted: inputs.reverted, diff --git a/yarn-project/pxe/src/contract_data_oracle/index.ts b/yarn-project/pxe/src/contract_data_oracle/index.ts index e29c95675cd9..d5f6f9e5c0d2 100644 --- a/yarn-project/pxe/src/contract_data_oracle/index.ts +++ b/yarn-project/pxe/src/contract_data_oracle/index.ts @@ -130,6 +130,11 @@ export class ContractDataOracle { return tree.getFunctionMembershipWitness(selector); } + public async getDebugContractName(contractAddress: AztecAddress) { + const tree = await this.getTreeForAddress(contractAddress); + return tree.getArtifact().name; + } + public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) { const tree = await this.getTreeForAddress(contractAddress); const { name: contractName } = tree.getArtifact(); diff --git a/yarn-project/pxe/src/database/deferred_note_dao.test.ts b/yarn-project/pxe/src/database/deferred_note_dao.test.ts deleted file mode 100644 index 79250c687b81..000000000000 --- a/yarn-project/pxe/src/database/deferred_note_dao.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { L1NotePayload, UnencryptedTxL2Logs, randomTxHash } from '@aztec/circuit-types'; -import { Fr, Point } from '@aztec/circuits.js'; -import { randomInt } from '@aztec/foundation/crypto'; - -import { DeferredNoteDao } from './deferred_note_dao.js'; - -export const randomDeferredNoteDao = ({ - publicKey = Point.random(), - payload = L1NotePayload.random(), - txHash = randomTxHash(), - noteHashes = [Fr.random(), Fr.random()], - dataStartIndexForTx = randomInt(100), - unencryptedLogs = UnencryptedTxL2Logs.random(1, 1), -}: Partial = {}) => { - return new DeferredNoteDao(publicKey, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs); -}; - -describe('Deferred Note DAO', () => { - it('convert to and from buffer', () => { - const deferredNote = randomDeferredNoteDao(); - const buf = deferredNote.toBuffer(); - expect(DeferredNoteDao.fromBuffer(buf)).toEqual(deferredNote); - }); -}); diff --git a/yarn-project/pxe/src/database/deferred_note_dao.ts b/yarn-project/pxe/src/database/deferred_note_dao.ts deleted file mode 100644 index 16044d7441ec..000000000000 --- a/yarn-project/pxe/src/database/deferred_note_dao.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { L1NotePayload, TxHash, UnencryptedTxL2Logs } from '@aztec/circuit-types'; -import { Fr, Point, type PublicKey, Vector } from '@aztec/circuits.js'; -import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; - -/** - * A note that is intended for us, but we cannot decode it yet because the contract is not yet in our database. - * - * So keep the state that we need to decode it later. - */ -export class DeferredNoteDao { - constructor( - /** Address Point or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */ - public publicKey: PublicKey, - /** The note payload delivered via L1. */ - public payload: L1NotePayload, - /** The hash of the tx the note was created in. Equal to the first nullifier */ - public txHash: TxHash, - /** New note hashes in this transaction, one of which belongs to this note */ - public noteHashes: Fr[], - /** The next available leaf index for the note hash tree for this transaction */ - public dataStartIndexForTx: number, - /** Unencrypted logs for the transaction (used to complete partial notes) */ - public unencryptedLogs: UnencryptedTxL2Logs, - ) {} - - toBuffer(): Buffer { - return serializeToBuffer( - this.publicKey, - this.payload, - this.txHash, - new Vector(this.noteHashes), - this.dataStartIndexForTx, - this.unencryptedLogs, - ); - } - static fromBuffer(buffer: Buffer | BufferReader) { - const reader = BufferReader.asReader(buffer); - return new DeferredNoteDao( - reader.readObject(Point), - reader.readObject(L1NotePayload), - reader.readObject(TxHash), - reader.readVector(Fr), - reader.readNumber(), - reader.readObject(UnencryptedTxL2Logs), - ); - } -} diff --git a/yarn-project/pxe/src/database/incoming_note_dao.ts b/yarn-project/pxe/src/database/incoming_note_dao.ts index 8a07c9d39a5c..cbd344b135ca 100644 --- a/yarn-project/pxe/src/database/incoming_note_dao.ts +++ b/yarn-project/pxe/src/database/incoming_note_dao.ts @@ -5,7 +5,7 @@ import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type NoteData } from '@aztec/simulator'; -import { type NoteInfo } from '../note_processor/utils/index.js'; +import { type NoteInfo } from '../note_decryption_utils/index.js'; /** * A note with contextual data which was decrypted as incoming. diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index 9c6f25092d08..2fea8a0452b5 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -4,9 +4,9 @@ import { CompleteAddress, type ContractInstanceWithAddress, Header, + type IndexedTaggingSecret, type PublicKey, SerializableContractInstance, - type TaggingSecret, computePoint, } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; @@ -22,7 +22,6 @@ import { } from '@aztec/kv-store'; import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/types/abi'; -import { DeferredNoteDao } from './deferred_note_dao.js'; import { IncomingNoteDao } from './incoming_note_dao.js'; import { OutgoingNoteDao } from './outgoing_note_dao.js'; import { type PxeDatabase } from './pxe_database.js'; @@ -45,8 +44,6 @@ export class KVPxeDatabase implements PxeDatabase { #nullifiedNotesByStorageSlot: AztecMultiMap; #nullifiedNotesByTxHash: AztecMultiMap; #nullifiedNotesByAddressPoint: AztecMultiMap; - #deferredNotes: AztecArray; - #deferredNotesByContract: AztecMultiMap; #syncedBlockPerPublicKey: AztecMap; #contractArtifacts: AztecMap; #contractInstances: AztecMap; @@ -64,8 +61,11 @@ export class KVPxeDatabase implements PxeDatabase { #notesByTxHashAndScope: Map>; #notesByAddressPointAndScope: Map>; - // Stores the last index used for each tagging secret - #taggingSecretIndexes: AztecMap; + // Stores the last index used for each tagging secret, taking direction into account + // This is necessary to avoid reusing the same index for the same secret, which happens if + // sender and recipient are the same + #taggingSecretIndexesForSenders: AztecMap; + #taggingSecretIndexesForRecipients: AztecMap; constructor(private db: AztecKVStore) { this.#db = db; @@ -93,9 +93,6 @@ export class KVPxeDatabase implements PxeDatabase { this.#nullifiedNotesByTxHash = db.openMultiMap('nullified_notes_by_tx_hash'); this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point'); - this.#deferredNotes = db.openArray('deferred_notes'); - this.#deferredNotesByContract = db.openMultiMap('deferred_notes_by_contract'); - this.#outgoingNotes = db.openMap('outgoing_notes'); this.#outgoingNotesByContract = db.openMultiMap('outgoing_notes_by_contract'); this.#outgoingNotesByStorageSlot = db.openMultiMap('outgoing_notes_by_storage_slot'); @@ -115,7 +112,8 @@ export class KVPxeDatabase implements PxeDatabase { this.#notesByAddressPointAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_address_point`)); } - this.#taggingSecretIndexes = db.openMap('tagging_secret_indices'); + this.#taggingSecretIndexesForSenders = db.openMap('tagging_secret_indexes_for_senders'); + this.#taggingSecretIndexesForRecipients = db.openMap('tagging_secret_indexes_for_recipients'); } public async getContract( @@ -216,56 +214,6 @@ export class KVPxeDatabase implements PxeDatabase { }); } - async addDeferredNotes(deferredNotes: DeferredNoteDao[]): Promise { - const newLength = await this.#deferredNotes.push(...deferredNotes.map(note => note.toBuffer())); - for (const [index, note] of deferredNotes.entries()) { - const noteId = newLength - deferredNotes.length + index; - await this.#deferredNotesByContract.set(note.payload.contractAddress.toString(), noteId); - } - } - - getDeferredNotesByContract(contractAddress: AztecAddress): Promise { - const noteIds = this.#deferredNotesByContract.getValues(contractAddress.toString()); - const notes: DeferredNoteDao[] = []; - for (const noteId of noteIds) { - const serializedNote = this.#deferredNotes.at(noteId); - if (!serializedNote) { - continue; - } - - const note = DeferredNoteDao.fromBuffer(serializedNote); - notes.push(note); - } - - return Promise.resolve(notes); - } - - /** - * Removes all deferred notes for a given contract address. - * @param contractAddress - the contract address to remove deferred notes for - * @returns an array of the removed deferred notes - */ - removeDeferredNotesByContract(contractAddress: AztecAddress): Promise { - return this.#db.transaction(() => { - const deferredNotes: DeferredNoteDao[] = []; - const indices = Array.from(this.#deferredNotesByContract.getValues(contractAddress.toString())); - - for (const index of indices) { - const deferredNoteBuffer = this.#deferredNotes.at(index); - if (!deferredNoteBuffer) { - continue; - } else { - deferredNotes.push(DeferredNoteDao.fromBuffer(deferredNoteBuffer)); - } - - void this.#deferredNotesByContract.deleteValue(contractAddress.toString(), index); - void this.#deferredNotes.setAt(index, null); - } - - return deferredNotes; - }); - } - getIncomingNotes(filter: IncomingNotesFilter): Promise { const publicKey: PublicKey | undefined = filter.owner ? computePoint(filter.owner) : undefined; @@ -600,23 +548,37 @@ export class KVPxeDatabase implements PxeDatabase { return incomingNotesSize + outgoingNotesSize + treeRootsSize + authWitsSize + addressesSize; } - async incrementTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise { - const indexes = await this.getTaggingSecretsIndexes(appTaggingSecretsWithRecipient); + async incrementTaggingSecretsIndexesAsSender(appTaggingSecrets: Fr[]): Promise { + await this.#incrementTaggingSecretsIndexes(appTaggingSecrets, this.#taggingSecretIndexesForSenders); + } + + async #incrementTaggingSecretsIndexes(appTaggingSecrets: Fr[], storageMap: AztecMap): Promise { + const indexes = await this.#getTaggingSecretsIndexes(appTaggingSecrets, storageMap); await this.db.transaction(() => { indexes.forEach((taggingSecretIndex, listIndex) => { const nextIndex = taggingSecretIndex + 1; - const { secret, recipient } = appTaggingSecretsWithRecipient[listIndex]; - const key = `${secret.toString()}-${recipient.toString()}`; - void this.#taggingSecretIndexes.set(key, nextIndex); + void storageMap.set(appTaggingSecrets[listIndex].toString(), nextIndex); }); }); } - getTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise { - return this.db.transaction(() => - appTaggingSecretsWithRecipient.map( - ({ secret, recipient }) => this.#taggingSecretIndexes.get(`${secret.toString()}-${recipient.toString()}`) ?? 0, - ), - ); + async setTaggingSecretsIndexesAsRecipient(indexedSecrets: IndexedTaggingSecret[]): Promise { + await this.db.transaction(() => { + indexedSecrets.forEach(indexedSecret => { + void this.#taggingSecretIndexesForRecipients.set(indexedSecret.secret.toString(), indexedSecret.index); + }); + }); + } + + async getTaggingSecretsIndexesAsRecipient(appTaggingSecrets: Fr[]) { + return await this.#getTaggingSecretsIndexes(appTaggingSecrets, this.#taggingSecretIndexesForRecipients); + } + + async getTaggingSecretsIndexesAsSender(appTaggingSecrets: Fr[]) { + return await this.#getTaggingSecretsIndexes(appTaggingSecrets, this.#taggingSecretIndexesForSenders); + } + + #getTaggingSecretsIndexes(appTaggingSecrets: Fr[], storageMap: AztecMap): Promise { + return this.db.transaction(() => appTaggingSecrets.map(secret => storageMap.get(`${secret.toString()}`) ?? 0)); } } diff --git a/yarn-project/pxe/src/database/outgoing_note_dao.ts b/yarn-project/pxe/src/database/outgoing_note_dao.ts index 30385bb684e0..04bb7d4835c5 100644 --- a/yarn-project/pxe/src/database/outgoing_note_dao.ts +++ b/yarn-project/pxe/src/database/outgoing_note_dao.ts @@ -4,7 +4,7 @@ import { NoteSelector } from '@aztec/foundation/abi'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { type NoteInfo } from '../note_processor/utils/index.js'; +import { type NoteInfo } from '../note_decryption_utils/index.js'; /** * A note with contextual data which was decrypted as outgoing. diff --git a/yarn-project/pxe/src/database/pxe_database.ts b/yarn-project/pxe/src/database/pxe_database.ts index d6758e233d88..d4cdb12bcec2 100644 --- a/yarn-project/pxe/src/database/pxe_database.ts +++ b/yarn-project/pxe/src/database/pxe_database.ts @@ -3,8 +3,8 @@ import { type CompleteAddress, type ContractInstanceWithAddress, type Header, + type IndexedTaggingSecret, type PublicKey, - type TaggingSecret, } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; @@ -12,7 +12,6 @@ import { type Fr } from '@aztec/foundation/fields'; import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js'; import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js'; -import { type DeferredNoteDao } from './deferred_note_dao.js'; import { type IncomingNoteDao } from './incoming_note_dao.js'; import { type OutgoingNoteDao } from './outgoing_note_dao.js'; @@ -90,25 +89,6 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD */ addNotes(incomingNotes: IncomingNoteDao[], outgoingNotes: OutgoingNoteDao[], scope?: AztecAddress): Promise; - /** - * Add notes to the database that are intended for us, but we don't yet have the contract. - * @param deferredNotes - An array of deferred notes. - */ - addDeferredNotes(deferredNotes: DeferredNoteDao[]): Promise; - - /** - * Get deferred notes for a given contract address. - * @param contractAddress - The contract address to get the deferred notes for. - */ - getDeferredNotesByContract(contractAddress: AztecAddress): Promise; - - /** - * Remove deferred notes for a given contract address. - * @param contractAddress - The contract address to remove the deferred notes for. - * @returns an array of the removed deferred notes - */ - removeDeferredNotesByContract(contractAddress: AztecAddress): Promise; - /** * Remove nullified notes associated with the given account and nullifiers. * @@ -209,18 +189,29 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD /** * Returns the last seen indexes for the provided app siloed tagging secrets or 0 if they've never been seen. - * The recipient must also be provided to convey "directionality" of the secret and index pair, or in other words - * whether the index was used to tag a sent or received note. * @param appTaggingSecrets - The app siloed tagging secrets. * @returns The indexes for the provided secrets, 0 if they've never been seen. */ - getTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise; + getTaggingSecretsIndexesAsRecipient(appTaggingSecrets: Fr[]): Promise; + + /** + * Returns the last seen indexes for the provided app siloed tagging secrets or 0 if they've never been used + * @param appTaggingSecrets - The app siloed tagging secrets. + * @returns The indexes for the provided secrets, 0 if they've never been seen. + */ + getTaggingSecretsIndexesAsSender(appTaggingSecrets: Fr[]): Promise; + + /** + * Increments the index for the provided app siloed tagging secrets in the senders database + * To be used when the generated tags have been used as sender + * @param appTaggingSecrets - The app siloed tagging secrets. + */ + incrementTaggingSecretsIndexesAsSender(appTaggingSecrets: Fr[]): Promise; /** - * Increments the index for the provided app siloed tagging secrets. - * The recipient must also be provided to convey "directionality" of the secret and index pair, or in other words - * whether the index was used to tag a sent or received note. + * Sets the index for the provided app siloed tagging secrets + * To be used when the generated tags have been "seen" as a recipient * @param appTaggingSecrets - The app siloed tagging secrets. */ - incrementTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise; + setTaggingSecretsIndexesAsRecipient(indexedTaggingSecrets: IndexedTaggingSecret[]): Promise; } diff --git a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts index 241ea97c919a..ec6396e90f07 100644 --- a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +++ b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts @@ -454,7 +454,17 @@ export class PrivateKernelResetPrivateInputsBuilder { const numLogs = this.previousKernel.end.encryptedLogsHashes.filter(l => !l.logHash.randomness.isZero()).length; const numToSilo = Math.max(0, numLogs - this.numTransientData); - this.requestedDimensions.ENCRYPTED_LOG_SILOING_AMOUNT = numToSilo; + // The reset circuit checks that capped_size must be greater than or equal to all non-empty logs. + // Since there is no current config with ENCRYPTED_LOG_SILOING_AMOUNT = 0 (only 1+), it defaults to 1, + // so the circuit fails when we have more than 1 log and require no siloing. + const numLogsNoSiloing = this.previousKernel.end.encryptedLogsHashes.filter( + l => !l.logHash.isEmpty() && l.logHash.randomness.isZero(), + ).length; + const cappedSize = !numToSilo && numLogsNoSiloing > 1 ? numLogsNoSiloing : numToSilo; + // NB: This is a little flimsy, and only works because we have either ENCRYPTED_LOG_SILOING_AMOUNT=1 or 8. + // e.g. if we have 2 logs that need siloing, and 2 that dont, then numLogs = ENCRYPTED_LOG_SILOING_AMOUNT = 2 + // This would fail because the circuit thinks that cappedSize = 2, but we have 4 logs. + this.requestedDimensions.ENCRYPTED_LOG_SILOING_AMOUNT = cappedSize; return numToSilo > 0; } diff --git a/yarn-project/pxe/src/note_processor/utils/add_public_values_to_payload.ts b/yarn-project/pxe/src/note_decryption_utils/add_public_values_to_payload.ts similarity index 97% rename from yarn-project/pxe/src/note_processor/utils/add_public_values_to_payload.ts rename to yarn-project/pxe/src/note_decryption_utils/add_public_values_to_payload.ts index 8a249ceab6d2..1d9c3806eea0 100644 --- a/yarn-project/pxe/src/note_processor/utils/add_public_values_to_payload.ts +++ b/yarn-project/pxe/src/note_decryption_utils/add_public_values_to_payload.ts @@ -1,7 +1,7 @@ import { type L1NotePayload, Note } from '@aztec/circuit-types'; import { ContractNotFoundError } from '@aztec/simulator'; -import { type PxeDatabase } from '../../database/pxe_database.js'; +import { type PxeDatabase } from '../database/pxe_database.js'; /** * Merges privately and publicly delivered note values. diff --git a/yarn-project/pxe/src/note_processor/utils/brute_force_note_info.ts b/yarn-project/pxe/src/note_decryption_utils/brute_force_note_info.ts similarity index 100% rename from yarn-project/pxe/src/note_processor/utils/brute_force_note_info.ts rename to yarn-project/pxe/src/note_decryption_utils/brute_force_note_info.ts diff --git a/yarn-project/pxe/src/note_processor/utils/index.ts b/yarn-project/pxe/src/note_decryption_utils/index.ts similarity index 100% rename from yarn-project/pxe/src/note_processor/utils/index.ts rename to yarn-project/pxe/src/note_decryption_utils/index.ts diff --git a/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts similarity index 79% rename from yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts rename to yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts index 07a1a8a84337..8e857d513301 100644 --- a/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts +++ b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts @@ -1,12 +1,11 @@ -import { type L1NotePayload, type PublicKey, type TxHash, type UnencryptedTxL2Logs } from '@aztec/circuit-types'; +import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types'; import { type Fr } from '@aztec/foundation/fields'; import { type Logger } from '@aztec/foundation/log'; import { type AcirSimulator } from '@aztec/simulator'; -import { type DeferredNoteDao } from '../../database/deferred_note_dao.js'; -import { IncomingNoteDao } from '../../database/incoming_note_dao.js'; -import { OutgoingNoteDao } from '../../database/outgoing_note_dao.js'; -import { type PxeDatabase } from '../../database/pxe_database.js'; +import { IncomingNoteDao } from '../database/incoming_note_dao.js'; +import { OutgoingNoteDao } from '../database/outgoing_note_dao.js'; +import { type PxeDatabase } from '../database/pxe_database.js'; import { produceNoteDaosForKey } from './produce_note_daos_for_key.js'; /** @@ -39,12 +38,9 @@ export async function produceNoteDaos( dataStartIndexForTx: number, excludedIndices: Set, logger: Logger, - unencryptedLogs: UnencryptedTxL2Logs, ): Promise<{ incomingNote: IncomingNoteDao | undefined; outgoingNote: OutgoingNoteDao | undefined; - incomingDeferredNote: DeferredNoteDao | undefined; - outgoingDeferredNote: DeferredNoteDao | undefined; }> { if (!addressPoint && !ovpkM) { throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.'); @@ -52,11 +48,9 @@ export async function produceNoteDaos( let incomingNote: IncomingNoteDao | undefined; let outgoingNote: OutgoingNoteDao | undefined; - let incomingDeferredNote: DeferredNoteDao | undefined; - let outgoingDeferredNote: DeferredNoteDao | undefined; if (addressPoint) { - [incomingNote, incomingDeferredNote] = await produceNoteDaosForKey( + incomingNote = await produceNoteDaosForKey( simulator, db, addressPoint, @@ -66,7 +60,6 @@ export async function produceNoteDaos( dataStartIndexForTx, excludedIndices, logger, - unencryptedLogs, IncomingNoteDao.fromPayloadAndNoteInfo, ); } @@ -87,7 +80,7 @@ export async function produceNoteDaos( ovpkM, ); } else { - [outgoingNote, outgoingDeferredNote] = await produceNoteDaosForKey( + outgoingNote = await produceNoteDaosForKey( simulator, db, ovpkM, @@ -97,7 +90,6 @@ export async function produceNoteDaos( dataStartIndexForTx, excludedIndices, logger, - unencryptedLogs, OutgoingNoteDao.fromPayloadAndNoteInfo, ); } @@ -106,7 +98,5 @@ export async function produceNoteDaos( return { incomingNote, outgoingNote, - incomingDeferredNote, - outgoingDeferredNote, }; } diff --git a/yarn-project/pxe/src/note_processor/utils/produce_note_daos_for_key.ts b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos_for_key.ts similarity index 62% rename from yarn-project/pxe/src/note_processor/utils/produce_note_daos_for_key.ts rename to yarn-project/pxe/src/note_decryption_utils/produce_note_daos_for_key.ts index 42b04fc3c137..9e530b387d13 100644 --- a/yarn-project/pxe/src/note_processor/utils/produce_note_daos_for_key.ts +++ b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos_for_key.ts @@ -1,10 +1,9 @@ -import { type L1NotePayload, type Note, type TxHash, type UnencryptedTxL2Logs } from '@aztec/circuit-types'; +import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types'; import { type Fr, type PublicKey } from '@aztec/circuits.js'; import { type Logger } from '@aztec/foundation/log'; -import { type AcirSimulator, ContractNotFoundError } from '@aztec/simulator'; +import { type AcirSimulator } from '@aztec/simulator'; -import { DeferredNoteDao } from '../../database/deferred_note_dao.js'; -import { type PxeDatabase } from '../../database/pxe_database.js'; +import { type PxeDatabase } from '../database/pxe_database.js'; import { getOrderedNoteItems } from './add_public_values_to_payload.js'; import { type NoteInfo, bruteForceNoteInfo } from './brute_force_note_info.js'; @@ -18,7 +17,6 @@ export async function produceNoteDaosForKey( dataStartIndexForTx: number, excludedIndices: Set, logger: Logger, - unencryptedLogs: UnencryptedTxL2Logs, daoConstructor: ( note: Note, payload: L1NotePayload, @@ -26,9 +24,8 @@ export async function produceNoteDaosForKey( dataStartIndexForTx: number, pkM: PublicKey, ) => T, -): Promise<[T | undefined, DeferredNoteDao | undefined]> { +): Promise { let noteDao: T | undefined; - let deferredNoteDao: DeferredNoteDao | undefined; try { // We get the note by merging publicly and privately delivered note values. @@ -49,14 +46,8 @@ export async function produceNoteDaosForKey( noteDao = daoConstructor(note, payload, noteInfo, dataStartIndexForTx, pkM); } catch (e) { - if (e instanceof ContractNotFoundError) { - logger.warn(e.message); - - deferredNoteDao = new DeferredNoteDao(pkM, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs); - } else { - logger.error(`Could not process note because of "${e}". Discarding note...`); - } + logger.error(`Could not process note because of "${e}". Discarding note...`); } - return [noteDao, deferredNoteDao]; + return noteDao; } diff --git a/yarn-project/pxe/src/note_processor/index.ts b/yarn-project/pxe/src/note_processor/index.ts deleted file mode 100644 index 3190e8eb40e5..000000000000 --- a/yarn-project/pxe/src/note_processor/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './note_processor.js'; diff --git a/yarn-project/pxe/src/note_processor/note_processor.test.ts b/yarn-project/pxe/src/note_processor/note_processor.test.ts deleted file mode 100644 index a5d7c77f0d88..000000000000 --- a/yarn-project/pxe/src/note_processor/note_processor.test.ts +++ /dev/null @@ -1,391 +0,0 @@ -import { - type AztecNode, - EncryptedL2NoteLog, - EncryptedLogPayload, - L1NotePayload, - L2Block, - Note, -} from '@aztec/circuit-types'; -import { - AztecAddress, - CompleteAddress, - Fr, - INITIAL_L2_BLOCK_NUM, - KeyValidationRequest, - MAX_NOTE_HASHES_PER_TX, - type PublicKey, - computeOvskApp, - deriveKeys, -} from '@aztec/circuits.js'; -import { pedersenHash } from '@aztec/foundation/crypto'; -import { GrumpkinScalar } from '@aztec/foundation/fields'; -import { type KeyStore } from '@aztec/key-store'; -import { openTmpStore } from '@aztec/kv-store/utils'; -import { type AcirSimulator } from '@aztec/simulator'; - -import { jest } from '@jest/globals'; -import { type MockProxy, mock } from 'jest-mock-extended'; - -import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; -import { type PxeDatabase } from '../database/index.js'; -import { KVPxeDatabase } from '../database/kv_pxe_database.js'; -import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js'; -import { NoteProcessor } from './note_processor.js'; - -const TXS_PER_BLOCK = 4; -const NUM_NOTE_HASHES_PER_BLOCK = TXS_PER_BLOCK * MAX_NOTE_HASHES_PER_TX; - -/** A wrapper containing info about a note we want to mock and insert into a block. */ -class MockNoteRequest { - constructor( - /** Log payload corresponding to a note we want to insert into a block. */ - public readonly logPayload: EncryptedLogPayload, - /** Block number this note corresponds to. */ - public readonly blockNumber: number, - /** Index of a tx within a block this note corresponds to. */ - public readonly txIndex: number, - /** Index of a note hash within a list of note hashes for 1 tx. */ - public readonly noteHashIndex: number, - /** Address point we use when encrypting a note. */ - public readonly recipient: AztecAddress, - /** ovKeys we use when encrypting a note. */ - public readonly ovKeys: KeyValidationRequest, - ) { - if (blockNumber < INITIAL_L2_BLOCK_NUM) { - throw new Error(`Block number should be greater than or equal to ${INITIAL_L2_BLOCK_NUM}.`); - } - if (noteHashIndex >= MAX_NOTE_HASHES_PER_TX) { - throw new Error(`Data index should be less than ${MAX_NOTE_HASHES_PER_TX}.`); - } - if (txIndex >= TXS_PER_BLOCK) { - throw new Error(`Tx index should be less than ${TXS_PER_BLOCK}.`); - } - } - - encrypt(): EncryptedL2NoteLog { - const ephSk = GrumpkinScalar.random(); - const log = this.logPayload.encrypt(ephSk, this.recipient, this.ovKeys); - return new EncryptedL2NoteLog(log); - } - - get indexWithinNoteHashTree(): bigint { - return BigInt( - (this.blockNumber - 1) * NUM_NOTE_HASHES_PER_BLOCK + this.txIndex * MAX_NOTE_HASHES_PER_TX + this.noteHashIndex, - ); - } - - get snippetOfNoteDao() { - const payload = L1NotePayload.fromIncomingBodyPlaintextContractAndPublicValues( - this.logPayload.incomingBodyPlaintext, - this.logPayload.contractAddress, - [], - )!; - return { - note: new Note(payload.privateNoteValues), - contractAddress: payload.contractAddress, - storageSlot: payload.storageSlot, - noteTypeId: payload.noteTypeId, - }; - } -} - -describe('Note Processor', () => { - let database: PxeDatabase; - let aztecNode: ReturnType>; - let addNotesSpy: any; - let noteProcessor: NoteProcessor; - let keyStore: MockProxy; - let simulator: MockProxy; - - const app = AztecAddress.random(); - - let ownerIvskM: GrumpkinScalar; - let ownerOvskM: GrumpkinScalar; - let ownerOvKeys: KeyValidationRequest; - let account: CompleteAddress; - - function mockBlocks(requests: MockNoteRequest[]) { - const blocks = []; - - // The number of blocks we create starts from INITIAL_L2_BLOCK_NUM and ends at the highest block number in requests - const numBlocks = requests.reduce((maxBlockNum, request) => Math.max(maxBlockNum, request.blockNumber), 0); - - for (let i = 0; i < numBlocks; i++) { - // First we get a random block with correct block number - const block = L2Block.random(INITIAL_L2_BLOCK_NUM + i, TXS_PER_BLOCK, 1, 0, 4); - - // We have to update the next available leaf index in note hash tree to match the block number - block.header.state.partial.noteHashTree.nextAvailableLeafIndex = block.number * NUM_NOTE_HASHES_PER_BLOCK; - - // Then we get all the note requests for the block - const noteRequestsForBlock = requests.filter(request => request.blockNumber === block.number); - - // Then we update the relevant note hashes to match the note requests - for (const request of noteRequestsForBlock) { - const note = request.snippetOfNoteDao.note; - const noteHash = pedersenHash(note.items); - block.body.txEffects[request.txIndex].noteHashes[request.noteHashIndex] = noteHash; - - // Now we populate the log - to simplify we say that there is only 1 function invocation in each tx - block.body.txEffects[request.txIndex].noteEncryptedLogs.functionLogs[0].logs[request.noteHashIndex] = - request.encrypt(); - } - - // The block is finished so we add it to the list of blocks - blocks.push(block); - } - - return blocks; - } - - beforeAll(() => { - const ownerSk = Fr.random(); - const partialAddress = Fr.random(); - - account = CompleteAddress.fromSecretKeyAndPartialAddress(ownerSk, partialAddress); - - ({ masterIncomingViewingSecretKey: ownerIvskM, masterOutgoingViewingSecretKey: ownerOvskM } = deriveKeys(ownerSk)); - - ownerOvKeys = new KeyValidationRequest( - account.publicKeys.masterOutgoingViewingPublicKey, - computeOvskApp(ownerOvskM, app), - ); - }); - - beforeEach(() => { - database = new KVPxeDatabase(openTmpStore()); - addNotesSpy = jest.spyOn(database, 'addNotes'); - - aztecNode = mock(); - keyStore = mock(); - simulator = mock(); - - keyStore.getMasterSecretKey.mockImplementation((pkM: PublicKey) => { - if (pkM.equals(account.publicKeys.masterIncomingViewingPublicKey)) { - return Promise.resolve(ownerIvskM); - } - if (pkM.equals(ownerOvKeys.pkM)) { - return Promise.resolve(ownerOvskM); - } - throw new Error(`Unknown public key: ${pkM}`); - }); - - keyStore.getMasterIncomingViewingPublicKey.mockResolvedValue(account.publicKeys.masterIncomingViewingPublicKey); - keyStore.getMasterOutgoingViewingPublicKey.mockResolvedValue(account.publicKeys.masterOutgoingViewingPublicKey); - - noteProcessor = NoteProcessor.create(account, keyStore, database, aztecNode, INITIAL_L2_BLOCK_NUM, simulator); - - simulator.computeNoteHashAndOptionallyANullifier.mockImplementation((...args) => - Promise.resolve({ - noteHash: Fr.random(), - uniqueNoteHash: Fr.random(), - siloedNoteHash: pedersenHash(args[5].items), // args[5] is note - innerNullifier: Fr.random(), - }), - ); - }); - - afterEach(() => { - addNotesSpy.mockReset(); - }); - - it('should store an incoming note that belongs to us', async () => { - const request = new MockNoteRequest( - getRandomNoteLogPayload(app), - 4, - 0, - 2, - account.address, - KeyValidationRequest.random(), - ); - - const blocks = mockBlocks([request]); - await noteProcessor.process(blocks); - - expect(addNotesSpy).toHaveBeenCalledTimes(1); - expect(addNotesSpy).toHaveBeenCalledWith( - [ - expect.objectContaining({ - ...request.snippetOfNoteDao, - index: request.indexWithinNoteHashTree, - }), - ], - [], - account.address, - ); - }, 25_000); - - it('should store an outgoing note that belongs to us', async () => { - const request = new MockNoteRequest( - getRandomNoteLogPayload(app), - 4, - 0, - 2, - CompleteAddress.random().address, - ownerOvKeys, - ); - - const blocks = mockBlocks([request]); - await noteProcessor.process(blocks); - - expect(addNotesSpy).toHaveBeenCalledTimes(1); - // For outgoing notes, the resulting DAO does not contain index. - expect(addNotesSpy).toHaveBeenCalledWith([], [expect.objectContaining(request.snippetOfNoteDao)], account.address); - }, 25_000); - - it('should store multiple notes that belong to us', async () => { - const requests = [ - new MockNoteRequest(getRandomNoteLogPayload(app), 1, 1, 1, account.address, ownerOvKeys), - new MockNoteRequest(getRandomNoteLogPayload(app), 2, 3, 0, CompleteAddress.random().address, ownerOvKeys), - new MockNoteRequest(getRandomNoteLogPayload(app), 6, 3, 2, account.address, KeyValidationRequest.random()), - new MockNoteRequest( - getRandomNoteLogPayload(app), - 9, - 3, - 2, - CompleteAddress.random().address, - KeyValidationRequest.random(), - ), - new MockNoteRequest(getRandomNoteLogPayload(app), 12, 3, 2, account.address, ownerOvKeys), - ]; - - const blocks = mockBlocks(requests); - await noteProcessor.process(blocks); - - expect(addNotesSpy).toHaveBeenCalledTimes(1); - expect(addNotesSpy).toHaveBeenCalledWith( - // Incoming should contain notes from requests 0, 2, 4 because in those requests we set owner address point. - [ - expect.objectContaining({ - ...requests[0].snippetOfNoteDao, - index: requests[0].indexWithinNoteHashTree, - }), - expect.objectContaining({ - ...requests[2].snippetOfNoteDao, - index: requests[2].indexWithinNoteHashTree, - }), - expect.objectContaining({ - ...requests[4].snippetOfNoteDao, - index: requests[4].indexWithinNoteHashTree, - }), - ], - // Outgoing should contain notes from requests 0, 1, 4 because in those requests we set owner ovKeys. - [ - expect.objectContaining(requests[0].snippetOfNoteDao), - expect.objectContaining(requests[1].snippetOfNoteDao), - expect.objectContaining(requests[4].snippetOfNoteDao), - ], - account.address, - ); - }, 30_000); - - it('should not store notes that do not belong to us', async () => { - // Both notes should be ignored because the encryption keys do not belong to owner (they are random). - const blocks = mockBlocks([ - new MockNoteRequest( - getRandomNoteLogPayload(), - 2, - 1, - 1, - CompleteAddress.random().address, - KeyValidationRequest.random(), - ), - new MockNoteRequest( - getRandomNoteLogPayload(), - 2, - 3, - 0, - CompleteAddress.random().address, - KeyValidationRequest.random(), - ), - ]); - await noteProcessor.process(blocks); - - expect(addNotesSpy).toHaveBeenCalledTimes(0); - }); - - it('should be able to recover two note payloads containing the same note', async () => { - const note = getRandomNoteLogPayload(app); - const note2 = getRandomNoteLogPayload(app); - // All note payloads except one have the same contract address, storage slot, and the actual note. - const requests = [ - new MockNoteRequest(note, 3, 0, 0, account.address, ownerOvKeys), - new MockNoteRequest(note, 4, 0, 2, account.address, ownerOvKeys), - new MockNoteRequest(note, 4, 2, 0, account.address, ownerOvKeys), - new MockNoteRequest(note2, 5, 2, 1, account.address, ownerOvKeys), - new MockNoteRequest(note, 6, 2, 3, account.address, ownerOvKeys), - ]; - - const blocks = mockBlocks(requests); - await noteProcessor.process(blocks); - - // First we check incoming - { - const addedIncoming: IncomingNoteDao[] = addNotesSpy.mock.calls[0][0]; - expect(addedIncoming.map(dao => dao)).toEqual([ - expect.objectContaining({ ...requests[0].snippetOfNoteDao, index: requests[0].indexWithinNoteHashTree }), - expect.objectContaining({ ...requests[1].snippetOfNoteDao, index: requests[1].indexWithinNoteHashTree }), - expect.objectContaining({ ...requests[2].snippetOfNoteDao, index: requests[2].indexWithinNoteHashTree }), - expect.objectContaining({ ...requests[3].snippetOfNoteDao, index: requests[3].indexWithinNoteHashTree }), - expect.objectContaining({ ...requests[4].snippetOfNoteDao, index: requests[4].indexWithinNoteHashTree }), - ]); - - // Check that every note has a different nonce. - const nonceSet = new Set(); - addedIncoming.forEach(info => nonceSet.add(info.nonce.value)); - expect(nonceSet.size).toBe(requests.length); - } - - // Then we check outgoing - { - const addedOutgoing: OutgoingNoteDao[] = addNotesSpy.mock.calls[0][1]; - expect(addedOutgoing.map(dao => dao)).toEqual([ - expect.objectContaining(requests[0].snippetOfNoteDao), - expect.objectContaining(requests[1].snippetOfNoteDao), - expect.objectContaining(requests[2].snippetOfNoteDao), - expect.objectContaining(requests[3].snippetOfNoteDao), - expect.objectContaining(requests[4].snippetOfNoteDao), - ]); - - // Outgoing note daos do not have a nonce so we don't check it. - } - }); - - it('advances the block number', async () => { - const request = new MockNoteRequest(getRandomNoteLogPayload(), 6, 0, 2, account.address, ownerOvKeys); - - const blocks = mockBlocks([request]); - await noteProcessor.process(blocks); - - expect(noteProcessor.status.syncedToBlock).toEqual(blocks.at(-1)?.number); - }); - - it('should restore the last block number processed and ignore the starting block', async () => { - const request = new MockNoteRequest( - getRandomNoteLogPayload(), - 6, - 0, - 2, - CompleteAddress.random().address, - KeyValidationRequest.random(), - ); - - const blocks = mockBlocks([request]); - await noteProcessor.process(blocks); - - const newNoteProcessor = NoteProcessor.create( - account, - keyStore, - database, - aztecNode, - INITIAL_L2_BLOCK_NUM, - simulator, - ); - - expect(newNoteProcessor.status).toEqual(noteProcessor.status); - }); - - function getRandomNoteLogPayload(app = AztecAddress.random()): EncryptedLogPayload { - return new EncryptedLogPayload(Fr.random(), app, L1NotePayload.random(app).toIncomingBodyPlaintext()); - } -}); diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts deleted file mode 100644 index 128b58b8104c..000000000000 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ /dev/null @@ -1,358 +0,0 @@ -import { type AztecNode, L1NotePayload, type L2Block } from '@aztec/circuit-types'; -import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; -import { - type CompleteAddress, - INITIAL_L2_BLOCK_NUM, - MAX_NOTE_HASHES_PER_TX, - computeAddressSecret, - computePoint, -} from '@aztec/circuits.js'; -import { type Fr } from '@aztec/foundation/fields'; -import { type Logger, createDebugLogger } from '@aztec/foundation/log'; -import { Timer } from '@aztec/foundation/timer'; -import { type KeyStore } from '@aztec/key-store'; -import { type AcirSimulator } from '@aztec/simulator'; - -import { type DeferredNoteDao } from '../database/deferred_note_dao.js'; -import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; -import { type PxeDatabase } from '../database/index.js'; -import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js'; -import { getAcirSimulator } from '../simulator/index.js'; -import { produceNoteDaos } from './utils/produce_note_daos.js'; - -/** - * Contains all the decrypted data in this array so that we can later batch insert it all into the database. - */ -interface ProcessedData { - /** Holds L2 block. */ - block: L2Block; - /** DAOs of processed incoming notes. */ - incomingNotes: IncomingNoteDao[]; - /** DAOs of processed outgoing notes. */ - outgoingNotes: OutgoingNoteDao[]; -} - -/** - * NoteProcessor is responsible for decrypting logs and converting them to notes via their originating contracts - * before storing them against their owner. - */ -export class NoteProcessor { - /** Keeps track of processing time since an instance is created. */ - public readonly timer: Timer = new Timer(); - - /** Stats accumulated for this processor. */ - public readonly stats: NoteProcessorStats = { - seen: 0, - decryptedIncoming: 0, - decryptedOutgoing: 0, - deferredIncoming: 0, - deferredOutgoing: 0, - failed: 0, - blocks: 0, - txs: 0, - }; - - private constructor( - public readonly account: CompleteAddress, - private keyStore: KeyStore, - private db: PxeDatabase, - private node: AztecNode, - private startingBlock: number, - private simulator: AcirSimulator, - private log: Logger, - ) {} - - public static create( - account: CompleteAddress, - keyStore: KeyStore, - db: PxeDatabase, - node: AztecNode, - startingBlock: number = INITIAL_L2_BLOCK_NUM, - simulator = getAcirSimulator(db, node, keyStore), - log = createDebugLogger('aztec:note_processor'), - ) { - return new NoteProcessor(account, keyStore, db, node, startingBlock, simulator, log); - } - - /** - * Check if the NoteProcessor is synchronized with the remote block number. - * The function queries the remote block number from the AztecNode and compares it with the syncedToBlock value in the NoteProcessor. - * If the values are equal, then the NoteProcessor is considered to be synchronized, otherwise not. - * - * @returns A boolean indicating whether the NoteProcessor is synchronized with the remote block number or not. - */ - public async isSynchronized() { - const remoteBlockNumber = await this.node.getBlockNumber(); - return this.getSyncedToBlock() === remoteBlockNumber; - } - - /** - * Returns synchronization status (ie up to which block has been synced ) for this note processor. - */ - public get status() { - return { syncedToBlock: this.getSyncedToBlock() }; - } - - private getSyncedToBlock(): number { - return this.db.getSynchedBlockNumberForAccount(this.account.address) ?? this.startingBlock - 1; - } - - /** - * Extracts new user-relevant notes from the information contained in the provided L2 blocks and encrypted logs. - * - * @param blocks - L2 blocks to be processed. - * @returns A promise that resolves once the processing is completed. - */ - public async process(blocks: L2Block[]): Promise { - if (blocks.length === 0) { - return; - } - - const blocksAndNotes: ProcessedData[] = []; - // Keep track of notes that we couldn't process because the contract was not found. - const deferredIncomingNotes: DeferredNoteDao[] = []; - const deferredOutgoingNotes: DeferredNoteDao[] = []; - - const ivskM = await this.keyStore.getMasterSecretKey(this.account.publicKeys.masterIncomingViewingPublicKey); - const addressSecret = computeAddressSecret(this.account.getPreaddress(), ivskM); - - const ovskM = await this.keyStore.getMasterSecretKey(this.account.publicKeys.masterOutgoingViewingPublicKey); - - // Iterate over both blocks and encrypted logs. - for (const block of blocks) { - this.stats.blocks++; - const { txLogs: encryptedTxLogs } = block.body.noteEncryptedLogs; - const { txLogs: unencryptedTxLogs } = block.body.unencryptedLogs; - - const dataStartIndexForBlock = - block.header.state.partial.noteHashTree.nextAvailableLeafIndex - - block.body.numberOfTxsIncludingPadded * MAX_NOTE_HASHES_PER_TX; - - // We are using set for `userPertainingTxIndices` to avoid duplicates. This would happen in case there were - // multiple encrypted logs in a tx pertaining to a user. - const incomingNotes: IncomingNoteDao[] = []; - const outgoingNotes: OutgoingNoteDao[] = []; - - // Iterate over all the encrypted logs and try decrypting them. If successful, store the note. - for (let indexOfTxInABlock = 0; indexOfTxInABlock < encryptedTxLogs.length; ++indexOfTxInABlock) { - this.stats.txs++; - const dataStartIndexForTx = dataStartIndexForBlock + indexOfTxInABlock * MAX_NOTE_HASHES_PER_TX; - const noteHashes = block.body.txEffects[indexOfTxInABlock].noteHashes; - // Note: Each tx generates a `TxL2Logs` object and for this reason we can rely on its index corresponding - // to the index of a tx in a block. - const encryptedTxFunctionLogs = encryptedTxLogs[indexOfTxInABlock].functionLogs; - const unencryptedTxFunctionLogs = unencryptedTxLogs[indexOfTxInABlock].functionLogs; - const excludedIndices: Set = new Set(); - - // We iterate over both encrypted and unencrypted logs to decrypt the notes since partial notes are passed - // via the unencrypted logs stream. - for (const txFunctionLogs of [encryptedTxFunctionLogs, unencryptedTxFunctionLogs]) { - const isFromPublic = txFunctionLogs === unencryptedTxFunctionLogs; - for (const functionLogs of txFunctionLogs) { - for (const unprocessedLog of functionLogs.logs) { - this.stats.seen++; - const incomingNotePayload = L1NotePayload.decryptAsIncoming( - unprocessedLog.data, - addressSecret, - isFromPublic, - ); - const outgoingNotePayload = L1NotePayload.decryptAsOutgoing(unprocessedLog.data, ovskM, isFromPublic); - - if (incomingNotePayload || outgoingNotePayload) { - if (incomingNotePayload && outgoingNotePayload && !incomingNotePayload.equals(outgoingNotePayload)) { - throw new Error( - `Incoming and outgoing note payloads do not match. Incoming: ${JSON.stringify( - incomingNotePayload, - )}, Outgoing: ${JSON.stringify(outgoingNotePayload)}`, - ); - } - - const payload = incomingNotePayload || outgoingNotePayload; - - const txEffect = block.body.txEffects[indexOfTxInABlock]; - const { incomingNote, outgoingNote, incomingDeferredNote, outgoingDeferredNote } = - await produceNoteDaos( - this.simulator, - this.db, - incomingNotePayload ? computePoint(this.account.address) : undefined, - outgoingNotePayload ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined, - payload!, - txEffect.txHash, - noteHashes, - dataStartIndexForTx, - excludedIndices, - this.log, - txEffect.unencryptedLogs, - ); - - if (incomingNote) { - incomingNotes.push(incomingNote); - this.stats.decryptedIncoming++; - } - if (outgoingNote) { - outgoingNotes.push(outgoingNote); - this.stats.decryptedOutgoing++; - } - if (incomingDeferredNote) { - deferredIncomingNotes.push(incomingDeferredNote); - this.stats.deferredIncoming++; - } - if (outgoingDeferredNote) { - deferredOutgoingNotes.push(outgoingDeferredNote); - this.stats.deferredOutgoing++; - } - - if (incomingNote == undefined && outgoingNote == undefined && incomingDeferredNote == undefined) { - this.stats.failed++; - } - } - } - } - } - } - - blocksAndNotes.push({ - block, - incomingNotes, - outgoingNotes, - }); - } - - await this.processBlocksAndNotes(blocksAndNotes); - await this.processDeferredNotes(deferredIncomingNotes, deferredOutgoingNotes); - - const syncedToBlock = blocks[blocks.length - 1].number; - await this.db.setSynchedBlockNumberForAccount(this.account.address, syncedToBlock); - - this.log.debug(`Synched block ${syncedToBlock}`); - } - - /** - * Process the given blocks and their associated transaction auxiliary data. - * This function updates the database with information about new transactions, - * user-pertaining transaction indices, and auxiliary data. It also removes nullified - * transaction auxiliary data from the database. This function keeps track of new nullifiers - * and ensures all other transactions are updated with newly settled block information. - * - * @param blocksAndNotes - Array of objects containing L2 blocks, user-pertaining transaction indices, and NoteDaos. - */ - private async processBlocksAndNotes(blocksAndNotes: ProcessedData[]) { - const incomingNotes = blocksAndNotes.flatMap(b => b.incomingNotes); - const outgoingNotes = blocksAndNotes.flatMap(b => b.outgoingNotes); - if (incomingNotes.length || outgoingNotes.length) { - await this.db.addNotes(incomingNotes, outgoingNotes, this.account.address); - incomingNotes.forEach(noteDao => { - this.log.verbose( - `Added incoming note for contract ${noteDao.contractAddress} at slot ${ - noteDao.storageSlot - } with nullifier ${noteDao.siloedNullifier.toString()}`, - ); - }); - outgoingNotes.forEach(noteDao => { - this.log.verbose(`Added outgoing note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`); - }); - } - - const nullifiers: Fr[] = blocksAndNotes.flatMap(b => - b.block.body.txEffects.flatMap(txEffect => txEffect.nullifiers), - ); - const removedNotes = await this.db.removeNullifiedNotes(nullifiers, computePoint(this.account.address)); - removedNotes.forEach(noteDao => { - this.log.verbose( - `Removed note for contract ${noteDao.contractAddress} at slot ${ - noteDao.storageSlot - } with nullifier ${noteDao.siloedNullifier.toString()}`, - ); - }); - } - - /** - * Store the given deferred notes in the database for later decoding. - * - * @param deferredIncomingNotes - incoming notes that are intended for us but we couldn't process because the contract was not found. - * @param deferredOutgoingNotes - outgoing notes that we couldn't process because the contract was not found. - */ - private async processDeferredNotes( - deferredIncomingNotes: DeferredNoteDao[], - deferredOutgoingNotes: DeferredNoteDao[], - ) { - if (deferredIncomingNotes.length || deferredOutgoingNotes.length) { - await this.db.addDeferredNotes([...deferredIncomingNotes, ...deferredOutgoingNotes]); - deferredIncomingNotes.forEach(noteDao => { - this.log.verbose( - `Deferred incoming note for contract ${noteDao.payload.contractAddress} at slot ${ - noteDao.payload.storageSlot - } in tx ${noteDao.txHash.toString()}`, - ); - }); - deferredOutgoingNotes.forEach(noteDao => { - this.log.verbose( - `Deferred outgoing note for contract ${noteDao.payload.contractAddress} at slot ${ - noteDao.payload.storageSlot - } in tx ${noteDao.txHash.toString()}`, - ); - }); - } - } - - /** - * Retry decoding the given deferred notes because we now have the contract code. - * - * @param deferredNoteDaos - notes that we have previously deferred because the contract was not found - * @returns An object containing arrays of incoming and outgoing notes that were successfully decoded. - * - * @remarks Caller is responsible for making sure that we have the contract for the - * deferred notes provided: we will not retry notes that fail again. - */ - public async decodeDeferredNotes(deferredNoteDaos: DeferredNoteDao[]): Promise<{ - incomingNotes: IncomingNoteDao[]; - outgoingNotes: OutgoingNoteDao[]; - }> { - const excludedIndices: Set = new Set(); - const incomingNotes: IncomingNoteDao[] = []; - const outgoingNotes: OutgoingNoteDao[] = []; - - for (const deferredNote of deferredNoteDaos) { - const { publicKey, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs } = deferredNote; - - const isIncoming = publicKey.equals(computePoint(this.account.address)); - const isOutgoing = publicKey.equals(this.account.publicKeys.masterOutgoingViewingPublicKey); - - if (!isIncoming && !isOutgoing) { - // The note does not belong to this note processor - continue; - } - - const { incomingNote, outgoingNote } = await produceNoteDaos( - this.simulator, - this.db, - isIncoming ? computePoint(this.account.address) : undefined, - isOutgoing ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined, - payload, - txHash, - noteHashes, - dataStartIndexForTx, - excludedIndices, - this.log, - unencryptedLogs, - ); - - if (isIncoming) { - if (!incomingNote) { - throw new Error('Deferred incoming note could not be decoded'); - } - incomingNotes.push(incomingNote); - this.stats.decryptedIncoming++; - } - if (outgoingNote) { - if (!outgoingNote) { - throw new Error('Deferred outgoing note could not be decoded'); - } - outgoingNotes.push(outgoingNote); - this.stats.decryptedOutgoing++; - } - } - - return { incomingNotes, outgoingNotes }; - } -} diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 08654326d1de..62e960817804 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -31,7 +31,6 @@ import { UniqueNote, getNonNullifiedL1ToL2MessageWitness, } from '@aztec/circuit-types'; -import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; import { type AztecAddress, type CompleteAddress, @@ -115,33 +114,11 @@ export class PXEService implements PXE { public async start() { const { l2BlockPollingIntervalMS } = this.config; await this.synchronizer.start(1, l2BlockPollingIntervalMS); - await this.restoreNoteProcessors(); await this.#registerProtocolContracts(); const info = await this.getNodeInfo(); this.log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`); } - private async restoreNoteProcessors() { - const accounts = await this.keyStore.getAccounts(); - const accountsSet = new Set(accounts.map(k => k.toString())); - - const registeredAddresses = await this.db.getCompleteAddresses(); - - let count = 0; - for (const completeAddress of registeredAddresses) { - if (!accountsSet.has(completeAddress.address.toString())) { - continue; - } - - count++; - this.synchronizer.addAccount(completeAddress, this.keyStore, this.config.l2StartingBlock); - } - - if (count > 0) { - this.log.info(`Restored ${count} accounts`); - } - } - /** * Stops the PXE Service, halting processing of new transactions and shutting down the synchronizer. * This function ensures that all ongoing tasks are completed before stopping the server. @@ -193,7 +170,6 @@ export class PXEService implements PXE { this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`); return accountCompleteAddress; } else { - this.synchronizer.addAccount(accountCompleteAddress, this.keyStore, this.config.l2StartingBlock); this.log.info(`Registered account ${accountCompleteAddress.address.toString()}`); this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`); } @@ -293,7 +269,6 @@ export class PXEService implements PXE { this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()}`); await this.db.addContractInstance(instance); - await this.synchronizer.reprocessDeferredNotesForContract(instance.address); } public getContracts(): Promise { @@ -390,13 +365,15 @@ export class PXEService implements PXE { note.note, ); - const index = await this.node.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, siloedNoteHash); + const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]); if (index === undefined) { throw new Error('Note does not exist.'); } const siloedNullifier = siloNullifier(note.contractAddress, innerNullifier!); - const nullifierIndex = await this.node.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, siloedNullifier); + const [nullifierIndex] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [ + siloedNullifier, + ]); if (nullifierIndex !== undefined) { throw new Error('The note has been destroyed.'); } @@ -439,7 +416,7 @@ export class PXEService implements PXE { throw new Error('Unexpectedly received non-zero nullifier.'); } - const index = await this.node.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, siloedNoteHash); + const [index] = await this.node.findLeavesIndexes('latest', MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]); if (index === undefined) { throw new Error('Note does not exist.'); } @@ -631,6 +608,15 @@ export class PXEService implements PXE { return this.node.getUnencryptedLogs(filter); } + /** + * Gets contract class logs based on the provided filter. + * @param filter - The filter to apply to the logs. + * @returns The requested logs. + */ + public getContractClassLogs(filter: LogFilter): Promise { + return this.node.getContractClassLogs(filter); + } + async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise { const contract = await this.db.getContract(to); if (!contract) { @@ -695,7 +681,6 @@ export class PXEService implements PXE { const { address, contractClass, instance, artifact } = getCanonicalProtocolContract(name); await this.db.addContractArtifact(contractClass.id, artifact); await this.db.addContractInstance(instance); - await this.synchronizer.reprocessDeferredNotesForContract(address); this.log.info(`Added protocol contract ${name} at ${address.toString()}`); } } @@ -840,18 +825,10 @@ export class PXEService implements PXE { return await this.synchronizer.isGlobalStateSynchronized(); } - public async isAccountStateSynchronized(account: AztecAddress) { - return await this.synchronizer.isAccountStateSynchronized(account); - } - public getSyncStatus() { return Promise.resolve(this.synchronizer.getSyncStatus()); } - public getSyncStats(): Promise<{ [address: string]: NoteProcessorStats }> { - return Promise.resolve(this.synchronizer.getSyncStats()); - } - public async isContractClassPubliclyRegistered(id: Fr): Promise { return !!(await this.node.getContractClass(id)); } diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 425603d6516e..73cf685b016a 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -2,24 +2,25 @@ import { type AztecNode, L1NotePayload, type L2Block, + type L2BlockNumber, MerkleTreeId, type NoteStatus, type NullifierMembershipWitness, type PublicDataWitness, - type TxScopedEncryptedL2NoteLog, + type TxEffect, + type TxScopedL2Log, getNonNullifiedL1ToL2MessageWitness, } from '@aztec/circuit-types'; import { type AztecAddress, type CompleteAddress, type ContractInstance, - type Fr, + Fr, type FunctionSelector, type Header, IndexedTaggingSecret, type KeyValidationRequest, type L1_TO_L2_MSG_TREE_HEIGHT, - TaggingSecret, computeAddressSecret, computePoint, computeTaggingSecret, @@ -31,11 +32,10 @@ import { type KeyStore } from '@aztec/key-store'; import { type AcirSimulator, type DBOracle, MessageLoadOracleInputs } from '@aztec/simulator'; import { type ContractDataOracle } from '../contract_data_oracle/index.js'; -import { type DeferredNoteDao } from '../database/deferred_note_dao.js'; import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; import { type PxeDatabase } from '../database/index.js'; import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js'; -import { produceNoteDaos } from '../note_processor/utils/produce_note_daos.js'; +import { produceNoteDaos } from '../note_decryption_utils/produce_note_daos.js'; import { getAcirSimulator } from '../simulator/index.js'; /** @@ -161,7 +161,7 @@ export class SimulatorOracle implements DBOracle { * @returns - The index of the commitment. Undefined if it does not exist in the tree. */ async getCommitmentIndex(commitment: Fr) { - return await this.aztecNode.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, commitment); + return await this.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, commitment); } // We need this in public as part of the EXISTS calls - but isn't used in private @@ -170,11 +170,16 @@ export class SimulatorOracle implements DBOracle { } async getNullifierIndex(nullifier: Fr) { - return await this.aztecNode.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier); + return await this.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier); } - public async findLeafIndex(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise { - return await this.aztecNode.findLeafIndex(blockNumber, treeId, leafValue); + public async findLeafIndex( + blockNumber: L2BlockNumber, + treeId: MerkleTreeId, + leafValue: Fr, + ): Promise { + const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [leafValue]); + return leafIndex; } public async getSiblingPath(blockNumber: number, treeId: MerkleTreeId, leafIndex: bigint): Promise { @@ -258,14 +263,14 @@ export class SimulatorOracle implements DBOracle { * @param recipient - The address receiving the note * @returns A siloed tagging secret that can be used to tag notes. */ - public async getAppTaggingSecret( + public async getAppTaggingSecretAsSender( contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress, ): Promise { - const directionalSecret = await this.#calculateDirectionalSecret(contractAddress, sender, recipient); - const [index] = await this.db.getTaggingSecretsIndexes([directionalSecret]); - return IndexedTaggingSecret.fromTaggingSecret(directionalSecret, index); + const secret = await this.#calculateTaggingSecret(contractAddress, sender, recipient); + const [index] = await this.db.getTaggingSecretsIndexesAsSender([secret]); + return new IndexedTaggingSecret(secret, index); } /** @@ -274,24 +279,26 @@ export class SimulatorOracle implements DBOracle { * @param sender - The address sending the note * @param recipient - The address receiving the note */ - public async incrementAppTaggingSecret( + public async incrementAppTaggingSecretIndexAsSender( contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress, ): Promise { - const directionalSecret = await this.#calculateDirectionalSecret(contractAddress, sender, recipient); - await this.db.incrementTaggingSecretsIndexes([directionalSecret]); + const secret = await this.#calculateTaggingSecret(contractAddress, sender, recipient); + const contractName = await this.contractDataOracle.getDebugContractName(contractAddress); + this.log.verbose( + `Incrementing secret ${secret} as sender ${sender} for recipient: ${recipient} at contract: ${contractName}(${contractAddress})`, + ); + await this.db.incrementTaggingSecretsIndexesAsSender([secret]); } - async #calculateDirectionalSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) { + async #calculateTaggingSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) { const senderCompleteAddress = await this.getCompleteAddress(sender); const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender); const sharedSecret = computeTaggingSecret(senderCompleteAddress, senderIvsk, recipient); // Silo the secret to the app so it can't be used to track other app's notes const siloedSecret = poseidon2Hash([sharedSecret.x, sharedSecret.y, contractAddress]); - // Get the index of the secret, ensuring the directionality (sender -> recipient) - const directionalSecret = new TaggingSecret(siloedSecret, recipient); - return directionalSecret; + return siloedSecret; } /** @@ -303,29 +310,27 @@ export class SimulatorOracle implements DBOracle { * @param recipient - The address receiving the notes * @returns A list of siloed tagging secrets */ - async #getAppTaggingSecretsForSenders( + async #getAppTaggingSecretsForContacts( contractAddress: AztecAddress, recipient: AztecAddress, ): Promise { const recipientCompleteAddress = await this.getCompleteAddress(recipient); const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient); - // We implicitly add the recipient as a contact, this helps us decrypt tags on notes that we send to ourselves (recipient = us, sender = us) - const contacts = [...this.db.getContactAddresses(), recipient]; + // We implicitly add all PXE accounts as contacts, this helps us decrypt tags on notes that we send to ourselves (recipient = us, sender = us) + const contacts = [...this.db.getContactAddresses(), ...(await this.keyStore.getAccounts())].filter( + (address, index, self) => index === self.findIndex(otherAddress => otherAddress.equals(address)), + ); const appTaggingSecrets = contacts.map(contact => { const sharedSecret = computeTaggingSecret(recipientCompleteAddress, recipientIvsk, contact); return poseidon2Hash([sharedSecret.x, sharedSecret.y, contractAddress]); }); - // Ensure the directionality (sender -> recipient) - const directionalSecrets = appTaggingSecrets.map(secret => new TaggingSecret(secret, recipient)); - const indexes = await this.db.getTaggingSecretsIndexes(directionalSecrets); - return directionalSecrets.map((directionalSecret, i) => - IndexedTaggingSecret.fromTaggingSecret(directionalSecret, indexes[i]), - ); + const indexes = await this.db.getTaggingSecretsIndexesAsRecipient(appTaggingSecrets); + return appTaggingSecrets.map((secret, i) => new IndexedTaggingSecret(secret, indexes[i])); } /** - * Synchronizes the logs tagged with the recipient's address and all the senders in the addressbook. + * Synchronizes the logs tagged with scoped addresses and all the senders in the addressbook. * Returns the unsynched logs and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for * @param recipient - The address of the recipient @@ -333,40 +338,113 @@ export class SimulatorOracle implements DBOracle { */ public async syncTaggedLogs( contractAddress: AztecAddress, - recipient: AztecAddress, - ): Promise { - // Ideally this algorithm would be implemented in noir, exposing its building blocks as oracles. - // However it is impossible at the moment due to the language not supporting nested slices. - // This nesting is necessary because for a given set of tags we don't - // know how many logs we will get back. Furthermore, these logs are of undetermined - // length, since we don't really know the note they correspond to until we decrypt them. - - // 1. Get all the secrets for the recipient and sender pairs (#9365) - let appTaggingSecrets = await this.#getAppTaggingSecretsForSenders(contractAddress, recipient); - - const logs: TxScopedEncryptedL2NoteLog[] = []; - while (appTaggingSecrets.length > 0) { - // 2. Compute tags using the secrets, recipient and index. Obtain logs for each tag (#9380) - const currentTags = appTaggingSecrets.map(taggingSecret => taggingSecret.computeTag()); - const logsByTags = await this.aztecNode.getLogsByTags(currentTags); - const newTaggingSecrets: IndexedTaggingSecret[] = []; - logsByTags.forEach((logsByTag, index) => { - // 3.1. Append logs to the list and increment the index for the tags that have logs (#9380) - if (logsByTag.length > 0) { - logs.push(...logsByTag); - // 3.2. Increment the index for the tags that have logs (#9380) - newTaggingSecrets.push( - new IndexedTaggingSecret(appTaggingSecrets[index].secret, recipient, appTaggingSecrets[index].index + 1), + maxBlockNumber: number, + scopes?: AztecAddress[], + ): Promise> { + const recipients = scopes ? scopes : await this.keyStore.getAccounts(); + const result = new Map(); + const contractName = await this.contractDataOracle.getDebugContractName(contractAddress); + for (const recipient of recipients) { + const logs: TxScopedL2Log[] = []; + // Ideally this algorithm would be implemented in noir, exposing its building blocks as oracles. + // However it is impossible at the moment due to the language not supporting nested slices. + // This nesting is necessary because for a given set of tags we don't + // know how many logs we will get back. Furthermore, these logs are of undetermined + // length, since we don't really know the note they correspond to until we decrypt them. + + // 1. Get all the secrets for the recipient and sender pairs (#9365) + const appTaggingSecrets = await this.#getAppTaggingSecretsForContacts(contractAddress, recipient); + + // 1.1 Set up a sliding window with an offset. Chances are the sender might have messed up + // and inadvertedly incremented their index without use getting any logs (for example, in case + // of a revert). If we stopped looking for logs the first time + // we receive 0 for a tag, we might never receive anything from that sender again. + // Also there's a possibility that we have advanced our index, but the sender has reused it, so + // we might have missed some logs. For these reasons, we have to look both back and ahead of the + // stored index + const INDEX_OFFSET = 10; + type SearchState = { + currentTagggingSecrets: IndexedTaggingSecret[]; + maxIndexesToCheck: { [k: string]: number }; + initialSecretIndexes: { [k: string]: number }; + secretsToIncrement: { [k: string]: number }; + }; + const searchState = appTaggingSecrets.reduce( + (acc, appTaggingSecret) => ({ + // Start looking for logs before the stored index + currentTagggingSecrets: acc.currentTagggingSecrets.concat([ + new IndexedTaggingSecret(appTaggingSecret.secret, Math.max(0, appTaggingSecret.index - INDEX_OFFSET)), + ]), + // Keep looking for logs beyond the stored index + maxIndexesToCheck: { + ...acc.maxIndexesToCheck, + ...{ [appTaggingSecret.secret.toString()]: appTaggingSecret.index + INDEX_OFFSET }, + }, + // Keeps track of the secrets we have to increment in the database + secretsToIncrement: {}, + // Store the initial set of indexes for the secrets + initialSecretIndexes: { + ...acc.initialSecretIndexes, + ...{ [appTaggingSecret.secret.toString()]: appTaggingSecret.index }, + }, + }), + { currentTagggingSecrets: [], maxIndexesToCheck: {}, secretsToIncrement: {}, initialSecretIndexes: {} }, + ); + + let { currentTagggingSecrets } = searchState; + const { maxIndexesToCheck, secretsToIncrement, initialSecretIndexes } = searchState; + + while (currentTagggingSecrets.length > 0) { + // 2. Compute tags using the secrets, recipient and index. Obtain logs for each tag (#9380) + const currentTags = currentTagggingSecrets.map(taggingSecret => taggingSecret.computeTag(recipient)); + const logsByTags = await this.aztecNode.getLogsByTags(currentTags); + const newTaggingSecrets: IndexedTaggingSecret[] = []; + logsByTags.forEach((logsByTag, logIndex) => { + const { secret: currentSecret, index: currentIndex } = currentTagggingSecrets[logIndex]; + const currentSecretAsStr = currentSecret.toString(); + this.log.debug( + `Syncing logs for recipient ${recipient}, secret ${currentSecretAsStr}:${currentIndex} at contract: ${contractName}(${contractAddress})`, ); - } - }); - // 4. Consolidate in db and replace initial appTaggingSecrets with the new ones (updated indexes) - await this.db.incrementTaggingSecretsIndexes( - newTaggingSecrets.map(secret => new TaggingSecret(secret.secret, recipient)), + // 3.1. Append logs to the list and increment the index for the tags that have logs (#9380) + if (logsByTag.length > 0) { + this.log.verbose( + `Found ${ + logsByTag.length + } logs for secret ${currentSecretAsStr} as recipient ${recipient}. Incrementing index to ${ + currentIndex + 1 + } at contract: ${contractName}(${contractAddress})`, + ); + logs.push(...logsByTag); + + if (currentIndex >= initialSecretIndexes[currentSecretAsStr]) { + // 3.2. Increment the index for the tags that have logs, provided they're higher than the one + // we have stored in the db (#9380) + secretsToIncrement[currentSecretAsStr] = currentIndex + 1; + // 3.3. Slide the window forwards if we have found logs beyond the initial index + maxIndexesToCheck[currentSecretAsStr] = currentIndex + INDEX_OFFSET; + } + } + // 3.4 Keep increasing the index (inside the window) temporarily for the tags that have no logs + // There's a chance the sender missed some and we want to catch up + if (currentIndex < maxIndexesToCheck[currentSecretAsStr]) { + const newTaggingSecret = new IndexedTaggingSecret(currentSecret, currentIndex + 1); + newTaggingSecrets.push(newTaggingSecret); + } + }); + await this.db.setTaggingSecretsIndexesAsRecipient( + Object.keys(secretsToIncrement).map( + secret => new IndexedTaggingSecret(Fr.fromString(secret), secretsToIncrement[secret]), + ), + ); + currentTagggingSecrets = newTaggingSecrets; + } + + result.set( + recipient.toString(), + logs.filter(log => log.blockNumber <= maxBlockNumber), ); - appTaggingSecrets = newTaggingSecrets; } - return logs; + return result; } /** @@ -376,11 +454,7 @@ export class SimulatorOracle implements DBOracle { * @param simulator - The simulator to use for decryption. * @returns The decrypted notes. */ - async #decryptTaggedLogs( - scopedLogs: TxScopedEncryptedL2NoteLog[], - recipient: AztecAddress, - simulator: AcirSimulator, - ) { + async #decryptTaggedLogs(scopedLogs: TxScopedL2Log[], recipient: AztecAddress, simulator?: AcirSimulator) { const recipientCompleteAddress = await this.getCompleteAddress(recipient); const ivskM = await this.keyStore.getMasterSecretKey( recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey, @@ -394,11 +468,16 @@ export class SimulatorOracle implements DBOracle { const excludedIndices: Map> = new Map(); const incomingNotes: IncomingNoteDao[] = []; const outgoingNotes: OutgoingNoteDao[] = []; - const deferredIncomingNotes: DeferredNoteDao[] = []; - const deferredOutgoingNotes: DeferredNoteDao[] = []; + + const txEffectsCache = new Map(); + for (const scopedLog of scopedLogs) { - const incomingNotePayload = L1NotePayload.decryptAsIncoming(scopedLog.log.data, addressSecret); - const outgoingNotePayload = L1NotePayload.decryptAsOutgoing(scopedLog.log.data, ovskM); + const incomingNotePayload = L1NotePayload.decryptAsIncoming( + scopedLog.logData, + addressSecret, + scopedLog.isFromPublic, + ); + const outgoingNotePayload = L1NotePayload.decryptAsOutgoing(scopedLog.logData, ovskM, scopedLog.isFromPublic); if (incomingNotePayload || outgoingNotePayload) { if (incomingNotePayload && outgoingNotePayload && !incomingNotePayload.equals(outgoingNotePayload)) { @@ -407,19 +486,25 @@ export class SimulatorOracle implements DBOracle { incomingNotePayload, )}, Outgoing: ${JSON.stringify(outgoingNotePayload)}`, ); + continue; } const payload = incomingNotePayload || outgoingNotePayload; - const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash); + + const txEffect = + txEffectsCache.get(scopedLog.txHash.toString()) ?? (await this.aztecNode.getTxEffect(scopedLog.txHash)); if (!txEffect) { this.log.warn(`No tx effect found for ${scopedLog.txHash} while decrypting tagged logs`); continue; } + + txEffectsCache.set(scopedLog.txHash.toString(), txEffect); + if (!excludedIndices.has(scopedLog.txHash.toString())) { excludedIndices.set(scopedLog.txHash.toString(), new Set()); } - const { incomingNote, outgoingNote, incomingDeferredNote, outgoingDeferredNote } = await produceNoteDaos( + const { incomingNote, outgoingNote } = await produceNoteDaos( // I don't like this at all, but we need a simulator to run `computeNoteHashAndOptionallyANullifier`. This generates // a chicken-and-egg problem due to this oracle requiring a simulator, which in turn requires this oracle. Furthermore, since jest doesn't allow // mocking ESM exports, we have to pollute the method even more by providing a simulator parameter so tests can inject a fake one. @@ -433,7 +518,6 @@ export class SimulatorOracle implements DBOracle { scopedLog.dataStartIndexForTx, excludedIndices.get(scopedLog.txHash.toString())!, this.log, - txEffect.unencryptedLogs, ); if (incomingNote) { @@ -442,18 +526,8 @@ export class SimulatorOracle implements DBOracle { if (outgoingNote) { outgoingNotes.push(outgoingNote); } - if (incomingDeferredNote) { - deferredIncomingNotes.push(incomingDeferredNote); - } - if (outgoingDeferredNote) { - deferredOutgoingNotes.push(outgoingDeferredNote); - } } } - if (deferredIncomingNotes.length || deferredOutgoingNotes.length) { - this.log.warn('Found deferred notes when processing tagged logs. This should not happen.'); - } - return { incomingNotes, outgoingNotes }; } @@ -463,15 +537,11 @@ export class SimulatorOracle implements DBOracle { * @param recipient - The recipient of the logs. */ public async processTaggedLogs( - logs: TxScopedEncryptedL2NoteLog[], + logs: TxScopedL2Log[], recipient: AztecAddress, simulator?: AcirSimulator, ): Promise { - const { incomingNotes, outgoingNotes } = await this.#decryptTaggedLogs( - logs, - recipient, - simulator ?? getAcirSimulator(this.db, this.aztecNode, this.keyStore, this.contractDataOracle), - ); + const { incomingNotes, outgoingNotes } = await this.#decryptTaggedLogs(logs, recipient, simulator); if (incomingNotes.length || outgoingNotes.length) { await this.db.addNotes(incomingNotes, outgoingNotes, recipient); incomingNotes.forEach(noteDao => { @@ -486,21 +556,18 @@ export class SimulatorOracle implements DBOracle { }); } const nullifiedNotes: IncomingNoteDao[] = []; - for (const incomingNote of incomingNotes) { - // NOTE: this leaks information about the nullifiers I'm interested in to the node. - const found = await this.aztecNode.findLeafIndex( - 'latest', - MerkleTreeId.NULLIFIER_TREE, - incomingNote.siloedNullifier, - ); - if (found) { - nullifiedNotes.push(incomingNote); - } - } - await this.db.removeNullifiedNotes( - nullifiedNotes.map(note => note.siloedNullifier), - computePoint(recipient), + const currentNotesForRecipient = await this.db.getIncomingNotes({ owner: recipient }); + const nullifierIndexes = await this.aztecNode.findLeavesIndexes( + 'latest', + MerkleTreeId.NULLIFIER_TREE, + currentNotesForRecipient.map(note => note.siloedNullifier), ); + + const foundNullifiers = currentNotesForRecipient + .filter((_, i) => nullifierIndexes[i] !== undefined) + .map(note => note.siloedNullifier); + + await this.db.removeNullifiedNotes(foundNullifiers, computePoint(recipient)); nullifiedNotes.forEach(noteDao => { this.log.verbose( `Removed note for contract ${noteDao.contractAddress} at slot ${ diff --git a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts index a10c21271e09..f4630610b6e7 100644 --- a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts +++ b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts @@ -6,7 +6,7 @@ import { Note, type TxEffect, TxHash, - TxScopedEncryptedL2NoteLog, + TxScopedL2Log, } from '@aztec/circuit-types'; import { AztecAddress, @@ -15,9 +15,9 @@ import { Fr, GrumpkinScalar, INITIAL_L2_BLOCK_NUM, + IndexedTaggingSecret, KeyValidationRequest, MAX_NOTE_HASHES_PER_TX, - TaggingSecret, computeAddress, computeOvskApp, computeTaggingSecret, @@ -127,6 +127,7 @@ describe('Simulator oracle', () => { aztecNode = mock(); database = new KVPxeDatabase(db); contractDataOracle = new ContractDataOracle(database); + jest.spyOn(contractDataOracle, 'getDebugContractName').mockImplementation(() => Promise.resolve('TestContract')); keyStore = new KeyStore(db); const simulatorOracleModule = await import('../simulator_oracle/index.js'); simulatorOracle = new simulatorOracleModule.SimulatorOracle(contractDataOracle, database, keyStore, aztecNode); @@ -141,36 +142,26 @@ describe('Simulator oracle', () => { describe('sync tagged logs', () => { const NUM_SENDERS = 10; + const SENDER_OFFSET_WINDOW_SIZE = 10; let senders: { completeAddress: CompleteAddress; ivsk: Fq }[]; - beforeEach(async () => { - // Set up the address book - senders = times(NUM_SENDERS).map((_, index) => { - const keys = deriveKeys(new Fr(index)); - const partialAddress = Fr.random(); - const address = computeAddress(keys.publicKeys, partialAddress); - const completeAddress = new CompleteAddress(address, keys.publicKeys, partialAddress); - return { completeAddress, ivsk: keys.masterIncomingViewingSecretKey }; - }); - for (const sender of senders) { - await database.addContactAddress(sender.completeAddress.address); - } + function generateMockLogs(senderOffset: number) { + const logs: { [k: string]: TxScopedL2Log[] } = {}; - const logs: { [k: string]: TxScopedEncryptedL2NoteLog[] } = {}; - - // Add a random note from every address in the address book for our account with index 0 + // Add a random note from every address in the address book for our account with index senderOffset // Compute the tag as sender (knowledge of preaddress and ivsk) for (const sender of senders) { - const tag = computeTagForIndex(sender, recipient.address, contractAddress, 0); + const tag = computeTagForIndex(sender, recipient.address, contractAddress, senderOffset); + const blockNumber = 1; const randomNote = new MockNoteRequest( getRandomNoteLogPayload(tag, contractAddress), - 1, + blockNumber, 1, 1, recipient.address, recipientOvKeys, ); - const log = new TxScopedEncryptedL2NoteLog(TxHash.random(), 0, randomNote.encrypt()); + const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt().data); logs[tag.toString()] = [log]; } // Accumulated logs intended for recipient: NUM_SENDERS @@ -178,39 +169,41 @@ describe('Simulator oracle', () => { // Add a random note from the first sender in the address book, repeating the tag // Compute the tag as sender (knowledge of preaddress and ivsk) const firstSender = senders[0]; - const tag = computeTagForIndex(firstSender, recipient.address, contractAddress, 0); - const log = new TxScopedEncryptedL2NoteLog(TxHash.random(), 0, EncryptedL2NoteLog.random(tag)); + const tag = computeTagForIndex(firstSender, recipient.address, contractAddress, senderOffset); + const log = new TxScopedL2Log(TxHash.random(), 1, 0, false, EncryptedL2NoteLog.random(tag).data); logs[tag.toString()].push(log); // Accumulated logs intended for recipient: NUM_SENDERS + 1 - // Add a random note from half the address book for our account with index 1 + // Add a random note from half the address book for our account with index senderOffset + 1 // Compute the tag as sender (knowledge of preaddress and ivsk) for (let i = NUM_SENDERS / 2; i < NUM_SENDERS; i++) { const sender = senders[i]; - const tag = computeTagForIndex(sender, recipient.address, contractAddress, 1); + const tag = computeTagForIndex(sender, recipient.address, contractAddress, senderOffset + 1); + const blockNumber = 2; const randomNote = new MockNoteRequest( getRandomNoteLogPayload(tag, contractAddress), - 1, + blockNumber, 1, 1, recipient.address, recipientOvKeys, ); - const log = new TxScopedEncryptedL2NoteLog(TxHash.random(), 0, randomNote.encrypt()); + const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt().data); logs[tag.toString()] = [log]; } // Accumulated logs intended for recipient: NUM_SENDERS + 1 + NUM_SENDERS / 2 - // Add a random note from every address in the address book for a random recipient with index 0 + // Add a random note from every address in the address book for a random recipient with index senderOffset // Compute the tag as sender (knowledge of preaddress and ivsk) for (const sender of senders) { const keys = deriveKeys(Fr.random()); const partialAddress = Fr.random(); const randomRecipient = computeAddress(keys.publicKeys, partialAddress); - const tag = computeTagForIndex(sender, randomRecipient, contractAddress, 0); + const tag = computeTagForIndex(sender, randomRecipient, contractAddress, senderOffset); + const blockNumber = 3; const randomNote = new MockNoteRequest( getRandomNoteLogPayload(tag, contractAddress), - 1, + blockNumber, 1, 1, randomRecipient, @@ -219,7 +212,7 @@ describe('Simulator oracle', () => { computeOvskApp(keys.masterOutgoingViewingSecretKey, contractAddress), ), ); - const log = new TxScopedEncryptedL2NoteLog(TxHash.random(), 0, randomNote.encrypt()); + const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt().data); logs[tag.toString()] = [log]; } // Accumulated logs intended for recipient: NUM_SENDERS + 1 + NUM_SENDERS / 2 @@ -229,59 +222,147 @@ describe('Simulator oracle', () => { aztecNode.getLogsByTags.mockImplementation(tags => { return Promise.resolve(tags.map(tag => logs[tag.toString()] ?? [])); }); + } + + beforeEach(async () => { + // Set up the address book + senders = times(NUM_SENDERS).map((_, index) => { + const keys = deriveKeys(new Fr(index)); + const partialAddress = Fr.random(); + const address = computeAddress(keys.publicKeys, partialAddress); + const completeAddress = new CompleteAddress(address, keys.publicKeys, partialAddress); + return { completeAddress, ivsk: keys.masterIncomingViewingSecretKey }; + }); + for (const sender of senders) { + await database.addContactAddress(sender.completeAddress.address); + } + aztecNode.getLogsByTags.mockReset(); }); it('should sync tagged logs', async () => { - const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, recipient.address); + const senderOffset = 0; + generateMockLogs(senderOffset); + const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, 3); // We expect to have all logs intended for the recipient, one per sender + 1 with a duplicated tag for the first one + half of the logs for the second index - expect(syncedLogs).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); + expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); // Recompute the secrets (as recipient) to ensure indexes are updated const ivsk = await keyStore.getMasterIncomingViewingSecretKey(recipient.address); - const directionalSecrets = senders.map(sender => { + const secrets = senders.map(sender => { const firstSenderSharedSecret = computeTaggingSecret(recipient, ivsk, sender.completeAddress.address); - const siloedSecret = poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); - return new TaggingSecret(siloedSecret, recipient.address); + return poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); }); // First sender should have 2 logs, but keep index 1 since they were built using the same tag - // Next 4 senders hould also have index 1 - // Last 5 senders should have index 2 - const indexes = await database.getTaggingSecretsIndexes(directionalSecrets); + // Next 4 senders hould also have index 1 = offset + 1 + // Last 5 senders should have index 2 = offset + 2 + const indexes = await database.getTaggingSecretsIndexesAsRecipient(secrets); expect(indexes).toHaveLength(NUM_SENDERS); expect(indexes).toEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]); + + // We should have called the node 12 times: + // 2 times with logs (sliding the window) + 10 times with no results (window size) + expect(aztecNode.getLogsByTags.mock.calls.length).toBe(2 + SENDER_OFFSET_WINDOW_SIZE); + }); + + it('should sync tagged logs with a sender index offset', async () => { + const senderOffset = 5; + generateMockLogs(senderOffset); + const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, 3); + // We expect to have all logs intended for the recipient, one per sender + 1 with a duplicated tag for the first one + half of the logs for the second index + expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); + + // Recompute the secrets (as recipient) to ensure indexes are updated + const ivsk = await keyStore.getMasterIncomingViewingSecretKey(recipient.address); + const secrets = senders.map(sender => { + const firstSenderSharedSecret = computeTaggingSecret(recipient, ivsk, sender.completeAddress.address); + return poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); + }); + + // First sender should have 2 logs, but keep index 1 since they were built using the same tag + // Next 4 senders hould also have index 6 = offset + 1 + // Last 5 senders should have index 7 = offset + 2 + const indexes = await database.getTaggingSecretsIndexesAsRecipient(secrets); + + expect(indexes).toHaveLength(NUM_SENDERS); + expect(indexes).toEqual([6, 6, 6, 6, 6, 7, 7, 7, 7, 7]); + + // We should have called the node 17 times: + // 5 times with no results (sender offset) + 2 times with logs (slide the window) + 10 times with no results (window size) + expect(aztecNode.getLogsByTags.mock.calls.length).toBe(5 + 2 + SENDER_OFFSET_WINDOW_SIZE); }); - it('should only sync tagged logs for which indexes are not updated', async () => { + it("should sync tagged logs for which indexes are not updated if they're inside the window", async () => { + const senderOffset = 1; + generateMockLogs(senderOffset); + // Recompute the secrets (as recipient) to update indexes + const ivsk = await keyStore.getMasterIncomingViewingSecretKey(recipient.address); + const secrets = senders.map(sender => { + const firstSenderSharedSecret = computeTaggingSecret(recipient, ivsk, sender.completeAddress.address); + return poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); + }); + + await database.setTaggingSecretsIndexesAsRecipient(secrets.map(secret => new IndexedTaggingSecret(secret, 2))); + + const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, 3); + + // Even if our index as recipient is higher than what the recipient sent, we should be able to find the logs + expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1 + NUM_SENDERS / 2); + // We should have called the node 13 times: + // 1 time without logs + 2 times with logs (sliding the window) + 10 times with no results (window size) + expect(aztecNode.getLogsByTags.mock.calls.length).toBe(3 + SENDER_OFFSET_WINDOW_SIZE); + }); + + it("should sync not tagged logs for which indexes are not updated if they're outside the window", async () => { + const senderOffset = 0; + generateMockLogs(senderOffset); + + // Recompute the secrets (as recipient) to update indexes const ivsk = await keyStore.getMasterIncomingViewingSecretKey(recipient.address); - const directionalSecrets = senders.map(sender => { + const secrets = senders.map(sender => { const firstSenderSharedSecret = computeTaggingSecret(recipient, ivsk, sender.completeAddress.address); - const siloedSecret = poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); - return new TaggingSecret(siloedSecret, recipient.address); + return poseidon2Hash([firstSenderSharedSecret.x, firstSenderSharedSecret.y, contractAddress]); }); - await database.incrementTaggingSecretsIndexes(directionalSecrets); + await database.setTaggingSecretsIndexesAsRecipient( + secrets.map(secret => new IndexedTaggingSecret(secret, SENDER_OFFSET_WINDOW_SIZE + 1)), + ); + + const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, 3); + + // Only half of the logs should be synced since we start from index 1 = offset + 1, the other half should be skipped + expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS / 2); - const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, recipient.address); + // We should have called the node SENDER_OFFSET_WINDOW_SIZE + 1 (with logs) + SENDER_OFFSET_WINDOW_SIZE: + // Once for index 1 (NUM_SENDERS/2 logs) + 2 times the sliding window (no logs each time) + expect(aztecNode.getLogsByTags.mock.calls.length).toBe(1 + 2 * SENDER_OFFSET_WINDOW_SIZE); + }); - // Only half of the logs should be synced since we start from index 1, the other half should be skipped - expect(syncedLogs).toHaveLength(NUM_SENDERS / 2); + it('should not sync tagged logs with a blockNumber > maxBlockNumber', async () => { + const senderOffset = 0; + generateMockLogs(senderOffset); + const syncedLogs = await simulatorOracle.syncTaggedLogs(contractAddress, 1); - // We should have called the node twice, once for index 1 and once for index 2 (which should return no logs) - expect(aztecNode.getLogsByTags.mock.calls.length).toBe(2); + // Only NUM_SENDERS + 1 logs should be synched, since the rest have blockNumber > 1 + expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS + 1); }); }); describe('Process notes', () => { let addNotesSpy: any; + let getIncomingNotesSpy: any; + let removeNullifiedNotesSpy: any; let simulator: MockProxy; beforeEach(() => { addNotesSpy = jest.spyOn(database, 'addNotes'); + getIncomingNotesSpy = jest.spyOn(database, 'getIncomingNotes'); + removeNullifiedNotesSpy = jest.spyOn(database, 'removeNullifiedNotes'); + removeNullifiedNotesSpy.mockImplementation(() => Promise.resolve([])); simulator = mock(); simulator.computeNoteHashAndOptionallyANullifier.mockImplementation((...args: any) => Promise.resolve({ @@ -295,13 +376,15 @@ describe('Simulator oracle', () => { afterEach(() => { addNotesSpy.mockReset(); + getIncomingNotesSpy.mockReset(); + removeNullifiedNotesSpy.mockReset(); simulator.computeNoteHashAndOptionallyANullifier.mockReset(); aztecNode.getTxEffect.mockReset(); }); - function mockTaggedLogs(requests: MockNoteRequest[]) { + function mockTaggedLogs(requests: MockNoteRequest[], nullifiers: number = 0) { const txEffectsMap: { [k: string]: { noteHashes: Fr[]; txHash: TxHash } } = {}; - const taggedLogs: TxScopedEncryptedL2NoteLog[] = []; + const taggedLogs: TxScopedL2Log[] = []; const groupedByTx = requests.reduce<{ [i: number]: { [j: number]: MockNoteRequest[] } }>((acc, request) => { if (!acc[request.blockNumber]) { acc[request.blockNumber] = {}; @@ -330,7 +413,7 @@ describe('Simulator oracle', () => { } const dataStartIndex = (request.blockNumber - 1) * NUM_NOTE_HASHES_PER_BLOCK + request.txIndex * MAX_NOTE_HASHES_PER_TX; - const taggedLog = new TxScopedEncryptedL2NoteLog(txHash, dataStartIndex, request.encrypt()); + const taggedLog = new TxScopedL2Log(txHash, dataStartIndex, blockNumber, false, request.encrypt().data); const note = request.snippetOfNoteDao.note; const noteHash = pedersenHash(note.items); txEffectsMap[txHash.toString()].noteHashes[request.noteHashIndex] = noteHash; @@ -342,6 +425,13 @@ describe('Simulator oracle', () => { aztecNode.getTxEffect.mockImplementation(txHash => { return Promise.resolve(txEffectsMap[txHash.toString()] as TxEffect); }); + aztecNode.findLeavesIndexes.mockImplementation((_blockNumber, _treeId, leafValues) => + Promise.resolve( + Array(leafValues.length - nullifiers) + .fill(undefined) + .concat(Array(nullifiers).fill(1n)), + ), + ); return taggedLogs; } @@ -544,5 +634,68 @@ describe('Simulator oracle', () => { // Outgoing note daos do not have a nonce so we don't check it. } }); + + it('should not store nullified notes', async () => { + const requests = [ + new MockNoteRequest( + getRandomNoteLogPayload(Fr.random(), contractAddress), + 1, + 1, + 1, + recipient.address, + recipientOvKeys, + ), + new MockNoteRequest( + getRandomNoteLogPayload(Fr.random(), contractAddress), + 6, + 3, + 2, + recipient.address, + recipientOvKeys, + ), + new MockNoteRequest( + getRandomNoteLogPayload(Fr.random(), contractAddress), + 12, + 3, + 2, + recipient.address, + recipientOvKeys, + ), + ]; + + const taggedLogs = mockTaggedLogs(requests, 2); + + getIncomingNotesSpy.mockResolvedValueOnce(Promise.resolve(requests.map(request => request.snippetOfNoteDao))); + + await simulatorOracle.processTaggedLogs(taggedLogs, recipient.address, simulator); + + expect(addNotesSpy).toHaveBeenCalledTimes(1); + expect(addNotesSpy).toHaveBeenCalledWith( + // Incoming should contain notes from requests 0, 1, 2 because in those requests we set owner address point. + [ + expect.objectContaining({ + ...requests[0].snippetOfNoteDao, + index: requests[0].indexWithinNoteHashTree, + }), + expect.objectContaining({ + ...requests[1].snippetOfNoteDao, + index: requests[1].indexWithinNoteHashTree, + }), + expect.objectContaining({ + ...requests[2].snippetOfNoteDao, + index: requests[2].indexWithinNoteHashTree, + }), + ], + // Outgoing should contain notes from requests 0, 1, 2 because in those requests we set owner ovKeys. + [ + expect.objectContaining(requests[0].snippetOfNoteDao), + expect.objectContaining(requests[1].snippetOfNoteDao), + expect.objectContaining(requests[2].snippetOfNoteDao), + ], + recipient.address, + ); + + expect(removeNullifiedNotesSpy).toHaveBeenCalledTimes(1); + }, 30_000); }); }); diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts index 22c1b4a9c60d..8b0c6810edac 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts @@ -1,9 +1,8 @@ import { type AztecNode, L2Block } from '@aztec/circuit-types'; -import { Fr, type Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js'; +import { type Header } from '@aztec/circuits.js'; import { makeHeader } from '@aztec/circuits.js/testing'; import { randomInt } from '@aztec/foundation/crypto'; import { SerialQueue } from '@aztec/foundation/queue'; -import { KeyStore } from '@aztec/key-store'; import { openTmpStore } from '@aztec/kv-store/utils'; import { type MockProxy, mock } from 'jest-mock-extended'; @@ -82,66 +81,6 @@ describe('Synchronizer', () => { expect(header5).not.toEqual(headerBlock3); expect(header5).toEqual(block5.header); }); - - it('note processor successfully catches up', async () => { - const blocks = [L2Block.random(1, 4), L2Block.random(2, 4)]; - - aztecNode.getLogs - // called by synchronizer.work - .mockResolvedValueOnce([blocks[0].body.encryptedLogs]) - .mockResolvedValueOnce([blocks[0].body.unencryptedLogs]) - .mockResolvedValueOnce([blocks[1].body.encryptedLogs]) - .mockResolvedValueOnce([blocks[1].body.encryptedLogs]) - // called by synchronizer.workNoteProcessorCatchUp - .mockResolvedValueOnce([blocks[0].body.encryptedLogs]) - .mockResolvedValueOnce([blocks[1].body.encryptedLogs]); - - aztecNode.getBlocks - // called by synchronizer.work, - .mockResolvedValueOnce([blocks[0]]) - .mockResolvedValueOnce([blocks[1]]) - // called by synchronizer.workNoteProcessorCatchUp - .mockResolvedValueOnce([blocks[0]]) - .mockResolvedValueOnce([blocks[1]]); - - aztecNode.getBlockNumber.mockResolvedValue(INITIAL_L2_BLOCK_NUM + 1); - - // Sync the synchronizer so that note processor has something to catch up to - // There are two blocks, and we have a limit of 1 block per work call - await synchronizer.work(1); - expect(await synchronizer.isGlobalStateSynchronized()).toBe(false); - await synchronizer.work(1); - expect(await synchronizer.isGlobalStateSynchronized()).toBe(true); - - // Manually adding account to database so that we can call synchronizer.isAccountStateSynchronized - const keyStore = new KeyStore(openTmpStore()); - const addAddress = async (startingBlockNum: number) => { - const secretKey = Fr.random(); - const partialAddress = Fr.random(); - const completeAddress = await keyStore.addAccount(secretKey, partialAddress); - await database.addCompleteAddress(completeAddress); - synchronizer.addAccount(completeAddress, keyStore, startingBlockNum); - return completeAddress; - }; - - const [completeAddressA, completeAddressB, completeAddressC] = await Promise.all([ - addAddress(INITIAL_L2_BLOCK_NUM), - addAddress(INITIAL_L2_BLOCK_NUM), - addAddress(INITIAL_L2_BLOCK_NUM + 1), - ]); - - await synchronizer.workNoteProcessorCatchUp(); - - expect(await synchronizer.isAccountStateSynchronized(completeAddressA.address)).toBe(false); - expect(await synchronizer.isAccountStateSynchronized(completeAddressB.address)).toBe(false); - expect(await synchronizer.isAccountStateSynchronized(completeAddressC.address)).toBe(false); - - await synchronizer.workNoteProcessorCatchUp(); - - expect(await synchronizer.isAccountStateSynchronized(completeAddressA.address)).toBe(true); - expect(await synchronizer.isAccountStateSynchronized(completeAddressB.address)).toBe(true); - expect(await synchronizer.isAccountStateSynchronized(completeAddressC.address)).toBe(true); - }); }); class TestSynchronizer extends Synchronizer { @@ -152,8 +91,4 @@ class TestSynchronizer extends Synchronizer { public override initialSync(): Promise { return super.initialSync(); } - - public override workNoteProcessorCatchUp(limit = 1): Promise { - return super.workNoteProcessorCatchUp(limit); - } } diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index dfef4ccd49ec..3ed458b2db1b 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -1,21 +1,10 @@ -import { type AztecNode, type L2Block, MerkleTreeId, type TxHash } from '@aztec/circuit-types'; -import { type NoteProcessorCaughtUpStats } from '@aztec/circuit-types/stats'; -import { - type AztecAddress, - type CompleteAddress, - type Fr, - INITIAL_L2_BLOCK_NUM, - type PublicKey, -} from '@aztec/circuits.js'; +import { type AztecNode, type L2Block } from '@aztec/circuit-types'; +import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { type SerialQueue } from '@aztec/foundation/queue'; import { RunningPromise } from '@aztec/foundation/running-promise'; -import { type KeyStore } from '@aztec/key-store'; -import { type DeferredNoteDao } from '../database/deferred_note_dao.js'; -import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; import { type PxeDatabase } from '../database/index.js'; -import { NoteProcessor } from '../note_processor/index.js'; /** * The Synchronizer class manages the synchronization of note processors and interacts with the Aztec node @@ -26,11 +15,9 @@ import { NoteProcessor } from '../note_processor/index.js'; */ export class Synchronizer { private runningPromise?: RunningPromise; - private noteProcessors: NoteProcessor[] = []; private running = false; private initialSyncBlockNumber = INITIAL_L2_BLOCK_NUM - 1; private log: DebugLogger; - private noteProcessorsToCatchUp: NoteProcessor[] = []; constructor(private node: AztecNode, private db: PxeDatabase, private jobQueue: SerialQueue, logSuffix = '') { this.log = createDebugLogger(logSuffix ? `aztec:pxe_synchronizer_${logSuffix}` : 'aztec:pxe_synchronizer'); @@ -80,13 +67,7 @@ export class Synchronizer { let moreWork = true; // keep external this.running flag to interrupt greedy sync while (moreWork && this.running) { - if (this.noteProcessorsToCatchUp.length > 0) { - // There is a note processor that needs to catch up. We hijack the main loop to catch up the note processor. - moreWork = await this.workNoteProcessorCatchUp(limit); - } else { - // No note processor needs to catch up. We continue with the normal flow. - moreWork = await this.work(limit); - } + moreWork = await this.work(limit); } }); } @@ -108,11 +89,6 @@ export class Synchronizer { // Update latest tree roots from the most recent block const latestBlock = blocks[blocks.length - 1]; await this.setHeaderFromBlock(latestBlock); - - this.log.debug(`Forwarding ${blocks.length} blocks to ${this.noteProcessors.length} note processors`); - for (const noteProcessor of this.noteProcessors) { - await noteProcessor.process(blocks); - } return true; } catch (err) { this.log.error(`Error in synchronizer work`, err); @@ -120,104 +96,6 @@ export class Synchronizer { } } - /** - * Catch up note processors that are lagging behind the main sync. - * e.g. because we just added a new account. - * - * @param limit - the maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration. - * @returns true if there could be more work, false if there was an error which allows a retry with delay. - */ - protected async workNoteProcessorCatchUp(limit = 1): Promise { - const toBlockNumber = this.getSynchedBlockNumber(); - - // filter out note processors that are already caught up - // and sort them by the block number they are lagging behind in ascending order - const noteProcessorsToCatchUp: NoteProcessor[] = []; - - this.noteProcessorsToCatchUp.forEach(noteProcessor => { - if (noteProcessor.status.syncedToBlock >= toBlockNumber) { - // Note processor is ahead of main sync, nothing to do - this.noteProcessors.push(noteProcessor); - } else { - noteProcessorsToCatchUp.push(noteProcessor); - } - }); - - this.noteProcessorsToCatchUp = noteProcessorsToCatchUp; - - if (!this.noteProcessorsToCatchUp.length) { - // No note processors to catch up, nothing to do here, - // but we return true to continue with the normal flow. - return true; - } - - // create a copy so that: - // 1. we can modify the original array while iterating over it - // 2. we don't need to serialize insertions into the array - const catchUpGroup = this.noteProcessorsToCatchUp - .slice() - // sort by the block number they are lagging behind - .sort((a, b) => a.status.syncedToBlock - b.status.syncedToBlock); - - // grab the note processor that is lagging behind the most - const from = catchUpGroup[0].status.syncedToBlock + 1; - // Ensuring that the note processor does not sync further than the main sync. - limit = Math.min(limit, toBlockNumber - from + 1); - // this.log(`Catching up ${catchUpGroup.length} note processors by up to ${limit} blocks starting at block ${from}`); - - if (limit < 1) { - throw new Error(`Unexpected limit ${limit} for note processor catch up`); - } - - try { - const blocks = await this.node.getBlocks(from, limit); - if (!blocks.length) { - // This should never happen because this function should only be called when the note processor is lagging - // behind main sync. - throw new Error('No blocks in processor catch up mode'); - } - - for (const noteProcessor of catchUpGroup) { - // find the index of the first block that the note processor is not yet synced to - const index = blocks.findIndex(block => block.number > noteProcessor.status.syncedToBlock); - if (index === -1) { - // Due to the limit, we might not have fetched a new enough block for the note processor. - // And since the group is sorted, we break as soon as we find a note processor - // that needs blocks newer than the newest block we fetched. - break; - } - - this.log.debug( - `Catching up note processor ${noteProcessor.account.toString()} by processing ${ - blocks.length - index - } blocks`, - ); - await noteProcessor.process(blocks.slice(index)); - - if (noteProcessor.status.syncedToBlock === toBlockNumber) { - // Note processor caught up, move it to `noteProcessors` from `noteProcessorsToCatchUp`. - this.log.debug(`Note processor for ${noteProcessor.account.toString()} has caught up`, { - eventName: 'note-processor-caught-up', - account: noteProcessor.account.toString(), - duration: noteProcessor.timer.ms(), - dbSize: await this.db.estimateSize(), - ...noteProcessor.stats, - } satisfies NoteProcessorCaughtUpStats); - - this.noteProcessorsToCatchUp = this.noteProcessorsToCatchUp.filter( - np => !np.account.equals(noteProcessor.account), - ); - this.noteProcessors.push(noteProcessor); - } - } - - return true; // could be more work, immediately continue syncing - } catch (err) { - this.log.error(`Error in synchronizer workNoteProcessorCatchUp`, err); - return false; - } - } - private async setHeaderFromBlock(latestBlock: L2Block) { if (latestBlock.number < this.initialSyncBlockNumber) { return; @@ -239,46 +117,6 @@ export class Synchronizer { this.log.info('Stopped'); } - /** - * Add a new account to the Synchronizer with the specified private key. - * Creates a NoteProcessor instance for the account and pushes it into the noteProcessors array. - * The method resolves immediately after pushing the new note processor. - * - * @param publicKey - The public key for the account. - * @param keyStore - The key store. - * @param startingBlock - The block where to start scanning for notes for this accounts. - * @returns A promise that resolves once the account is added to the Synchronizer. - */ - public addAccount(account: CompleteAddress, keyStore: KeyStore, startingBlock: number) { - const predicate = (x: NoteProcessor) => x.account.equals(account); - const processor = this.noteProcessors.find(predicate) ?? this.noteProcessorsToCatchUp.find(predicate); - if (processor) { - return; - } - - this.noteProcessorsToCatchUp.push(NoteProcessor.create(account, keyStore, this.db, this.node, startingBlock)); - } - - /** - * Checks if the specified account is synchronized. - * @param account - The aztec address for which to query the sync status. - * @returns True if the account is fully synched, false otherwise. - * @remarks Checks whether all the notes from all the blocks have been processed. If it is not the case, the - * retrieved information from contracts might be old/stale (e.g. old token balance). - * @throws If checking a sync status of account which is not registered. - */ - public async isAccountStateSynchronized(account: AztecAddress) { - const findByAccountAddress = (x: NoteProcessor) => x.account.address.equals(account); - const processor = - this.noteProcessors.find(findByAccountAddress) ?? this.noteProcessorsToCatchUp.find(findByAccountAddress); - if (!processor) { - throw new Error( - `Checking if account is synched is not possible for ${account} because it is only registered as a recipient.`, - ); - } - return await processor.isSynchronized(); - } - private getSynchedBlockNumber() { return this.db.getBlockNumber() ?? this.initialSyncBlockNumber; } @@ -302,94 +140,6 @@ export class Synchronizer { const lastBlockNumber = this.getSynchedBlockNumber(); return { blocks: lastBlockNumber, - notes: Object.fromEntries(this.noteProcessors.map(n => [n.account.address.toString(), n.status.syncedToBlock])), }; } - - /** - * Returns the note processor stats. - * @returns The note processor stats for notes for each public key being tracked. - */ - public getSyncStats() { - return Object.fromEntries(this.noteProcessors.map(n => [n.account.address.toString(), n.stats])); - } - - /** - * Retry decoding any deferred notes for the specified contract address. - * @param contractAddress - the contract address that has just been added - */ - public reprocessDeferredNotesForContract(contractAddress: AztecAddress): Promise { - return this.jobQueue.put(() => this.#reprocessDeferredNotesForContract(contractAddress)); - } - - async #reprocessDeferredNotesForContract(contractAddress: AztecAddress): Promise { - const deferredNotes = await this.db.getDeferredNotesByContract(contractAddress); - - // group deferred notes by txHash to properly deal with possible duplicates - const txHashToDeferredNotes: Map = new Map(); - for (const note of deferredNotes) { - const notesForTx = txHashToDeferredNotes.get(note.txHash) ?? []; - notesForTx.push(note); - txHashToDeferredNotes.set(note.txHash, notesForTx); - } - - // keep track of decoded notes - const incomingNotes: IncomingNoteDao[] = []; - - // now process each txHash - for (const deferredNotes of txHashToDeferredNotes.values()) { - // to be safe, try each note processor in case the deferred notes are for different accounts. - for (const processor of this.noteProcessors) { - const { incomingNotes: inNotes, outgoingNotes: outNotes } = await processor.decodeDeferredNotes(deferredNotes); - incomingNotes.push(...inNotes); - - await this.db.addNotes(inNotes, outNotes, processor.account.address); - - inNotes.forEach(noteDao => { - this.log.debug( - `Decoded deferred incoming note under account ${processor.account.toString()} for contract ${ - noteDao.contractAddress - } at slot ${noteDao.storageSlot} with nullifier ${noteDao.siloedNullifier.toString()}`, - ); - }); - - outNotes.forEach(noteDao => { - this.log.debug( - `Decoded deferred outgoing note under account ${processor.account.toString()} for contract ${ - noteDao.contractAddress - } at slot ${noteDao.storageSlot}`, - ); - }); - } - } - - // now drop the deferred notes, and add the decoded notes - await this.db.removeDeferredNotesByContract(contractAddress); - - await this.#removeNullifiedNotes(incomingNotes); - } - - async #removeNullifiedNotes(notes: IncomingNoteDao[]) { - // now group the decoded incoming notes by public key - const addressPointToIncomingNotes: Map = new Map(); - for (const noteDao of notes) { - const notesForAddressPoint = addressPointToIncomingNotes.get(noteDao.addressPoint) ?? []; - notesForAddressPoint.push(noteDao); - addressPointToIncomingNotes.set(noteDao.addressPoint, notesForAddressPoint); - } - - // now for each group, look for the nullifiers in the nullifier tree - for (const [publicKey, notes] of addressPointToIncomingNotes.entries()) { - const nullifiers = notes.map(n => n.siloedNullifier); - const relevantNullifiers: Fr[] = []; - for (const nullifier of nullifiers) { - // NOTE: this leaks information about the nullifiers I'm interested in to the node. - const found = await this.node.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier); - if (found) { - relevantNullifiers.push(nullifier); - } - } - await this.db.removeNullifiedNotes(relevantNullifiers, publicKey); - } - } } diff --git a/yarn-project/scripts/src/benchmarks/aggregate.ts b/yarn-project/scripts/src/benchmarks/aggregate.ts index 4e8222bd11a4..5b82bd208ce1 100644 --- a/yarn-project/scripts/src/benchmarks/aggregate.ts +++ b/yarn-project/scripts/src/benchmarks/aggregate.ts @@ -24,7 +24,6 @@ import { type L2BlockHandledStats, type MetricName, type NodeSyncedChainHistoryStats, - type NoteProcessorCaughtUpStats, type ProofConstructed, type PublicDBAccessStats, type Stats, @@ -186,15 +185,6 @@ function processCircuitWitnessGeneration(entry: CircuitWitnessGenerationStats, r append(results, 'protocol_circuit_witness_generation_time_in_ms', bucket, entry.duration); } } -/** - * Processes an entry with event name 'note-processor-caught-up' and updates results - */ -function processNoteProcessorCaughtUp(entry: NoteProcessorCaughtUpStats, results: BenchmarkCollectedResults) { - const { decryptedIncoming, decryptedOutgoing, blocks, dbSize } = entry; - if (BENCHMARK_HISTORY_CHAIN_LENGTHS.includes(blocks) && (decryptedIncoming > 0 || decryptedOutgoing > 0)) { - append(results, 'pxe_database_size_in_bytes', blocks, dbSize); - } -} /** Processes an entry with event name 'l2-block-built' and updates results where buckets are rollup sizes */ function processL2BlockBuilt(entry: L2BlockBuiltStats, results: BenchmarkCollectedResults) { @@ -267,8 +257,6 @@ function processEntry(entry: Stats, results: BenchmarkCollectedResults) { return processCircuitWitnessGeneration(entry, results); case 'circuit-proving': return processCircuitProving(entry, results); - case 'note-processor-caught-up': - return processNoteProcessorCaughtUp(entry, results); case 'l2-block-built': return processL2BlockBuilt(entry, results); case 'node-synced-chain-history': diff --git a/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts b/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts index 7fc5647904e7..e7a47a7eced6 100644 --- a/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts +++ b/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts @@ -1,7 +1,7 @@ import { type Tx, TxExecutionPhase, type TxValidator } from '@aztec/circuit-types'; import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; -import { EnqueuedCallsProcessor, computeFeePayerBalanceStorageSlot } from '@aztec/simulator'; +import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator'; /** Provides a view into public contract state */ export interface PublicStateSource { @@ -58,7 +58,7 @@ export class GasTxValidator implements TxValidator { ); // If there is a claim in this tx that increases the fee payer balance in Fee Juice, add it to balance - const setupFns = EnqueuedCallsProcessor.getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP); + const setupFns = getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP); const claimFunctionCall = setupFns.find( fn => fn.callContext.contractAddress.equals(this.#feeJuiceAddress) && diff --git a/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts b/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts index 813c382a6a6c..4474b198afa2 100644 --- a/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts +++ b/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts @@ -7,7 +7,7 @@ import { } from '@aztec/circuit-types'; import { type ContractDataSource } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; -import { ContractsDataSourcePublicDB, EnqueuedCallsProcessor } from '@aztec/simulator'; +import { ContractsDataSourcePublicDB, getExecutionRequestsByPhase } from '@aztec/simulator'; export class PhasesTxValidator implements TxValidator { #log = createDebugLogger('aztec:sequencer:tx_validator:tx_phases'); @@ -45,7 +45,7 @@ export class PhasesTxValidator implements TxValidator { return true; } - const setupFns = EnqueuedCallsProcessor.getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP); + const setupFns = getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP); for (const setupFn of setupFns) { if (!(await this.isOnAllowList(setupFn, this.setupAllowList))) { this.#log.warn( diff --git a/yarn-project/simulator/src/acvm/oracle/oracle.ts b/yarn-project/simulator/src/acvm/oracle/oracle.ts index 77cd613cd3f6..f52db4237b05 100644 --- a/yarn-project/simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/oracle.ts @@ -336,15 +336,11 @@ export class Oracle { return toACVMField(0); } - emitContractClassUnencryptedLog( - [contractAddress]: ACVMField[], - message: ACVMField[], - [counter]: ACVMField[], - ): ACVMField { + emitContractClassLog([contractAddress]: ACVMField[], message: ACVMField[], [counter]: ACVMField[]): ACVMField { const logPayload = Buffer.concat(message.map(fromACVMField).map(f => f.toBuffer())); const log = new UnencryptedL2Log(AztecAddress.fromString(contractAddress), logPayload); - const logHash = this.typedOracle.emitContractClassUnencryptedLog(log, +counter); + const logHash = this.typedOracle.emitContractClassLog(log, +counter); return toACVMField(logHash); } @@ -409,22 +405,22 @@ export class Oracle { this.typedOracle.notifySetMinRevertibleSideEffectCounter(frToNumber(fromACVMField(minRevertibleSideEffectCounter))); } - async getAppTaggingSecret([sender]: ACVMField[], [recipient]: ACVMField[]): Promise { - const taggingSecret = await this.typedOracle.getAppTaggingSecret( + async getAppTaggingSecretAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise { + const taggingSecret = await this.typedOracle.getAppTaggingSecretAsSender( AztecAddress.fromString(sender), AztecAddress.fromString(recipient), ); return taggingSecret.toFields().map(toACVMField); } - async incrementAppTaggingSecret([sender]: ACVMField[], [recipient]: ACVMField[]) { - await this.typedOracle.incrementAppTaggingSecret( + async incrementAppTaggingSecretIndexAsSender([sender]: ACVMField[], [recipient]: ACVMField[]) { + await this.typedOracle.incrementAppTaggingSecretIndexAsSender( AztecAddress.fromString(sender), AztecAddress.fromString(recipient), ); } - async syncNotes([recipient]: ACVMField[]) { - await this.typedOracle.syncNotes(AztecAddress.fromString(recipient)); + async syncNotes() { + await this.typedOracle.syncNotes(); } } diff --git a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts index 4aa721d423a0..541774c59798 100644 --- a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts @@ -212,7 +212,7 @@ export abstract class TypedOracle { throw new OracleMethodNotAvailableError('emitUnencryptedLog'); } - emitContractClassUnencryptedLog(_log: UnencryptedL2Log, _counter: number): Fr { + emitContractClassLog(_log: UnencryptedL2Log, _counter: number): Fr { throw new OracleMethodNotAvailableError('emitContractClassUnencryptedLog'); } @@ -254,15 +254,15 @@ export abstract class TypedOracle { throw new OracleMethodNotAvailableError('debugLog'); } - getAppTaggingSecret(_sender: AztecAddress, _recipient: AztecAddress): Promise { - throw new OracleMethodNotAvailableError('getAppTaggingSecret'); + getAppTaggingSecretAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise { + throw new OracleMethodNotAvailableError('getAppTaggingSecretAsSender'); } - incrementAppTaggingSecret(_sender: AztecAddress, _recipient: AztecAddress): Promise { - throw new OracleMethodNotAvailableError('incrementAppTaggingSecret'); + incrementAppTaggingSecretIndexAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise { + throw new OracleMethodNotAvailableError('incrementAppTaggingSecretIndexAsSender'); } - syncNotes(_recipient: AztecAddress): Promise { + syncNotes(): Promise { throw new OracleMethodNotAvailableError('syncNotes'); } } diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index e8a44d0df61a..f05c18b3e019 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -1,24 +1,31 @@ +import { MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/circuit-types'; import { + type ContractDataSource, GasFees, GlobalVariables, + PublicDataTreeLeaf, + PublicDataTreeLeafPreimage, type PublicFunction, PublicKeys, SerializableContractInstance, } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; -import { computeVarArgsHash } from '@aztec/circuits.js/hash'; +import { computePublicDataTreeLeafSlot, computeVarArgsHash } from '@aztec/circuits.js/hash'; import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing'; import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { keccak256, keccakf1600, pedersenCommit, pedersenHash, poseidon2Hash, sha256 } from '@aztec/foundation/crypto'; import { Fq, Fr, Point } from '@aztec/foundation/fields'; import { type Fieldable } from '@aztec/foundation/serialize'; +import { openTmpStore } from '@aztec/kv-store/utils'; +import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; +import { MerkleTrees } from '@aztec/world-state'; import { randomInt } from 'crypto'; import { mock } from 'jest-mock-extended'; import { PublicEnqueuedCallSideEffectTrace } from '../public/enqueued_call_side_effect_trace.js'; -import { type WorldStateDB } from '../public/public_db_sources.js'; +import { WorldStateDB } from '../public/public_db_sources.js'; import { type PublicSideEffectTraceInterface } from '../public/side_effect_trace_interface.js'; import { type AvmContext } from './avm_context.js'; import { type AvmExecutionEnvironment } from './avm_execution_environment.js'; @@ -39,7 +46,7 @@ import { randomMemoryUint64s, resolveAvmTestContractAssertionMessage, } from './fixtures/index.js'; -import { type AvmPersistableStateManager } from './journal/journal.js'; +import { type AvmPersistableStateManager, getLeafOrLowLeaf } from './journal/journal.js'; import { Add, CalldataCopy, @@ -158,7 +165,10 @@ describe('AVM simulator: transpiled Noir contracts', () => { mockStorageRead(worldStateDB, storageValue); const trace = mock(); - const persistableState = initPersistableStateManager({ worldStateDB, trace }); + const telemetry = new NoopTelemetryClient(); + const merkleTrees = await (await MerkleTrees.new(openTmpStore(), telemetry)).fork(); + worldStateDB.getMerkleInterface.mockReturnValue(merkleTrees); + const persistableState = initPersistableStateManager({ worldStateDB, trace, merkleTrees }); const environment = initExecutionEnvironment({ functionSelector, calldata, @@ -582,14 +592,8 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(trace.traceNullifierCheck).toHaveBeenCalledTimes(1); const isPending = false; // leafIndex is returned from DB call for nullifiers, so it is absent on DB miss - const tracedLeafIndex = exists && !isPending ? leafIndex : Fr.ZERO; - expect(trace.traceNullifierCheck).toHaveBeenCalledWith( - address, - /*nullifier=*/ value0, - tracedLeafIndex, - exists, - isPending, - ); + const _tracedLeafIndex = exists && !isPending ? leafIndex : Fr.ZERO; + expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, /*nullifier=*/ value0, exists); }); }); @@ -673,13 +677,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(trace.traceNewNullifier).toHaveBeenCalledWith(expect.objectContaining(address), /*nullifier=*/ value0); expect(trace.traceNullifierCheck).toHaveBeenCalledTimes(1); // leafIndex is returned from DB call for nullifiers, so it is absent on DB miss - expect(trace.traceNullifierCheck).toHaveBeenCalledWith( - address, - /*nullifier=*/ value0, - /*leafIndex=*/ Fr.ZERO, - /*exists=*/ true, - /*isPending=*/ true, - ); + expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, /*nullifier=*/ value0, /*exists=*/ true); }); it(`Emits same nullifier twice (expect failure)`, async () => { const calldata = [value0]; @@ -746,13 +744,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(results.output).toEqual([value0]); expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - slot, - value0, - /*exists=*/ true, - /*cached=*/ false, - ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, slot, value0); }); it('Should set and read a value from storage (single)', async () => { @@ -768,13 +760,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(trace.tracePublicStorageWrite).toHaveBeenCalledTimes(1); expect(trace.tracePublicStorageWrite).toHaveBeenCalledWith(address, slot, value0); expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - slot, - value0, - /*exists=*/ true, - /*cached=*/ true, - ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, slot, value0); }); it('Should set a value in storage (list)', async () => { @@ -808,20 +794,9 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(results.reverted).toBe(false); expect(results.output).toEqual([value0, value1]); - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - listSlot0, - value0, - /*exists=*/ true, - /*cached=*/ false, - ); - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - listSlot1, - value1, - /*exists=*/ true, - /*cached=*/ false, - ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(2); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, listSlot0, value0); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, listSlot1, value1); }); it('Should set a value in storage (map)', async () => { @@ -859,13 +834,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(await context.persistableState.peekStorage(address, mapSlot)).toEqual(value0); expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - mapSlot, - Fr.ZERO, - /*exists=*/ false, - /*cached=*/ false, - ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, mapSlot, Fr.zero()); expect(trace.tracePublicStorageWrite).toHaveBeenCalledTimes(1); expect(trace.tracePublicStorageWrite).toHaveBeenCalledWith(address, mapSlot, value0); }); @@ -883,13 +852,7 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); // slot is the result of a pedersen hash and is therefore not known in the test - expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( - address, - expect.anything(), - value0, - /*exists=*/ true, - /*cached=*/ false, - ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith(address, expect.anything(), value0); }); }); @@ -1161,6 +1124,216 @@ describe('AVM simulator: transpiled Noir contracts', () => { }); }); }); + describe('Side effects including merkle checks', () => { + const address = AztecAddress.fromNumber(1); + const sender = AztecAddress.fromNumber(42); + + const value0 = new Fr(420); + const value1 = new Fr(69); + + const slotNumber0 = 1; // must update Noir contract if changing this + const slotNumber1 = 2; // must update Noir contract if changing this + const slot0 = new Fr(slotNumber0); + const slot1 = new Fr(slotNumber1); + const leafSlot0 = computePublicDataTreeLeafSlot(address, slot0); + const leafSlot1 = computePublicDataTreeLeafSlot(address, slot1); + const publicDataTreeLeaf0 = new PublicDataTreeLeaf(leafSlot0, value0); + const _publicDataTreeLeaf1 = new PublicDataTreeLeaf(leafSlot1, value1); + + const INTERNAL_PUBLIC_DATA_SUBTREE_HEIGHT = 0; + + const listSlotNumber0 = 2; // must update Noir contract if changing this + const listSlotNumber1 = listSlotNumber0 + 1; + const listSlot0 = new Fr(listSlotNumber0); + const listSlot1 = new Fr(listSlotNumber1); + const _leafListSlot0 = computePublicDataTreeLeafSlot(address, listSlot0); + const _leafListSlot1 = computePublicDataTreeLeafSlot(address, listSlot1); + + let worldStateDB: WorldStateDB; + let merkleTrees: MerkleTreeWriteOperations; + let trace: PublicSideEffectTraceInterface; + let persistableState: AvmPersistableStateManager; + + beforeEach(async () => { + trace = mock(); + + const telemetry = new NoopTelemetryClient(); + merkleTrees = await (await MerkleTrees.new(openTmpStore(), telemetry)).fork(); + worldStateDB = new WorldStateDB(merkleTrees, mock() as ContractDataSource); + + persistableState = initPersistableStateManager({ worldStateDB, trace, doMerkleOperations: true, merkleTrees }); + }); + + const createContext = (calldata: Fr[] = []) => { + return initContext({ + persistableState, + env: initExecutionEnvironment({ address, sender, calldata }), + }); + }; + + describe('Public storage accesses', () => { + it('Should set value in storage (single)', async () => { + const calldata = [value0]; + + const [lowLeafIndex, lowLeafPreimage, lowLeafPath, leafAlreadyPresent] = + await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot0.toBigInt(), + merkleTrees, + ); + // leafSlot0 should NOT be present in the tree! + expect(leafAlreadyPresent).toEqual(false); + expect(lowLeafPreimage.slot).not.toEqual(leafSlot0); + const newLeafPreimage = new PublicDataTreeLeafPreimage( + leafSlot0, + value0, + lowLeafPreimage.nextSlot, + lowLeafPreimage.nextIndex, + ); + + const context = createContext(calldata); + const bytecode = getAvmTestContractBytecode('set_storage_single'); + + const results = await new AvmSimulator(context).executeBytecode(bytecode); + expect(results.reverted).toBe(false); + + expect(await context.persistableState.peekStorage(address, slot0)).toEqual(value0); + + expect(trace.tracePublicStorageWrite).toHaveBeenCalledTimes(1); + expect(trace.tracePublicStorageWrite).toHaveBeenCalledWith( + address, + slot0, + value0, + lowLeafPreimage, + new Fr(lowLeafIndex), + lowLeafPath, + newLeafPreimage, + expect.anything(), // can't know path without performing test insertion + ); + }); + + it('Should read value in storage (single) - never written', async () => { + const context = createContext(); + + const [lowLeafIndex, lowLeafPreimage, lowLeafPath, leafAlreadyPresent] = + await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot0.toBigInt(), + merkleTrees, + ); + // leafSlot0 should NOT be present in the tree! + expect(leafAlreadyPresent).toEqual(false); + expect(lowLeafPreimage.slot).not.toEqual(leafSlot0); + + const bytecode = getAvmTestContractBytecode('read_storage_single'); + + const results = await new AvmSimulator(context).executeBytecode(bytecode); + expect(results.reverted).toBe(false); + expect(results.output).toEqual([Fr.zero()]); + + expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( + address, + slot0, + /*value=*/ Fr.zero(), + lowLeafPreimage, + new Fr(lowLeafIndex), + lowLeafPath, + ); + }); + + it('Should read value in storage (single) - written before, leaf exists', async () => { + const context = createContext(); + + await merkleTrees.batchInsert( + MerkleTreeId.PUBLIC_DATA_TREE, + [publicDataTreeLeaf0.toBuffer()], + INTERNAL_PUBLIC_DATA_SUBTREE_HEIGHT, + ); + const [leafIndex, leafPreimage, leafPath] = await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot0.toBigInt(), + merkleTrees, + ); + // leafSlot0 should be present in the tree! + expect(leafPreimage.slot).toEqual(leafSlot0); + expect(leafPreimage.value).toEqual(value0); + + const bytecode = getAvmTestContractBytecode('read_storage_single'); + + const results = await new AvmSimulator(context).executeBytecode(bytecode); + expect(results.reverted).toBe(false); + expect(results.output).toEqual([value0]); + + expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( + address, + slot0, + value0, + leafPreimage, + new Fr(leafIndex), + leafPath, + ); + }); + + it('Should set and read value in storage (single)', async () => { + const calldata = [value0]; + + const [lowLeafIndex, lowLeafPreimage, lowLeafPath, leafAlreadyPresent] = + await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot0.toBigInt(), + merkleTrees, + ); + // leafSlot0 should NOT be present in the tree! + expect(leafAlreadyPresent).toEqual(false); + expect(lowLeafPreimage.slot).not.toEqual(leafSlot0); + const newLeafPreimage = new PublicDataTreeLeafPreimage( + leafSlot0, + value0, + lowLeafPreimage.nextSlot, + lowLeafPreimage.nextIndex, + ); + + const context = createContext(calldata); + const bytecode = getAvmTestContractBytecode('set_read_storage_single'); + const results = await new AvmSimulator(context).executeBytecode(bytecode); + + expect(results.reverted).toBe(false); + expect(results.output).toEqual([value0]); + + const [leafIndex, leafPreimage, leafPath] = await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot0.toBigInt(), + merkleTrees, + ); + // leafSlot0 should now be present in the tree! + expect(leafPreimage.slot).toEqual(leafSlot0); + expect(leafPreimage.value).toEqual(value0); + + expect(trace.tracePublicStorageWrite).toHaveBeenCalledTimes(1); + expect(trace.tracePublicStorageWrite).toHaveBeenCalledWith( + address, + slot0, + value0, + lowLeafPreimage, + new Fr(lowLeafIndex), + lowLeafPath, + newLeafPreimage, + expect.anything(), // can't know path without performing test insertion + ); + expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(1); + expect(trace.tracePublicStorageRead).toHaveBeenCalledWith( + address, + slot0, + value0, + leafPreimage, + new Fr(leafIndex), + leafPath, + ); + }); + }); + }); }); function sha256FromMemoryBytes(bytes: Uint8[]): Fr[] { diff --git a/yarn-project/simulator/src/avm/avm_simulator.ts b/yarn-project/simulator/src/avm/avm_simulator.ts index 7b6f7e26aefc..dd97bf194dd6 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.ts @@ -30,8 +30,8 @@ type PcTally = { export class AvmSimulator { private log: DebugLogger; private bytecode: Buffer | undefined; - public opcodeTallies: Map = new Map(); - public pcTallies: Map = new Map(); + private opcodeTallies: Map = new Map(); + private pcTallies: Map = new Map(); constructor(private context: AvmContext) { assert( diff --git a/yarn-project/simulator/src/avm/fixtures/index.ts b/yarn-project/simulator/src/avm/fixtures/index.ts index 271fca8618ea..3a8d594e4b57 100644 --- a/yarn-project/simulator/src/avm/fixtures/index.ts +++ b/yarn-project/simulator/src/avm/fixtures/index.ts @@ -1,4 +1,4 @@ -import { isNoirCallStackUnresolved } from '@aztec/circuit-types'; +import { type MerkleTreeWriteOperations, isNoirCallStackUnresolved } from '@aztec/circuit-types'; import { GasFees, GlobalVariables, MAX_L2_GAS_PER_ENQUEUED_CALL } from '@aztec/circuits.js'; import { type FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -42,6 +42,8 @@ export function initPersistableStateManager(overrides?: { trace?: PublicSideEffectTraceInterface; publicStorage?: PublicStorage; nullifiers?: NullifierManager; + doMerkleOperations?: boolean; + merkleTrees?: MerkleTreeWriteOperations; }): AvmPersistableStateManager { const worldStateDB = overrides?.worldStateDB || mock(); return new AvmPersistableStateManager( @@ -49,6 +51,8 @@ export function initPersistableStateManager(overrides?: { overrides?.trace || mock(), overrides?.publicStorage || new PublicStorage(worldStateDB), overrides?.nullifiers || new NullifierManager(worldStateDB), + overrides?.doMerkleOperations || false, + overrides?.merkleTrees || mock(), ); } diff --git a/yarn-project/simulator/src/avm/journal/journal.test.ts b/yarn-project/simulator/src/avm/journal/journal.test.ts index d4dd745ab929..68c009a8afef 100644 --- a/yarn-project/simulator/src/avm/journal/journal.test.ts +++ b/yarn-project/simulator/src/avm/journal/journal.test.ts @@ -44,7 +44,7 @@ describe('journal', () => { expect(cacheMissResult).toEqual(storedValue); // Write to storage - persistableState.writeStorage(address, slot, cachedValue); + await persistableState.writeStorage(address, slot, cachedValue); // Get the storage value const cachedResult = await persistableState.readStorage(address, slot); @@ -54,22 +54,8 @@ describe('journal', () => { // We expect the journal to store the access in [storedVal, cachedVal] - [time0, time1] expect(trace.tracePublicStorageRead).toHaveBeenCalledTimes(2); - expect(trace.tracePublicStorageRead).toHaveBeenNthCalledWith( - /*nthCall=*/ 1, - address, - slot, - storedValue, - /*exists=*/ true, - /*cached=*/ false, - ); - expect(trace.tracePublicStorageRead).toHaveBeenNthCalledWith( - /*nthCall=*/ 2, - address, - slot, - cachedValue, - /*exists=*/ true, - /*cached=*/ true, - ); + expect(trace.tracePublicStorageRead).toHaveBeenNthCalledWith(/*nthCall=*/ 1, address, slot, storedValue); + expect(trace.tracePublicStorageRead).toHaveBeenNthCalledWith(/*nthCall=*/ 2, address, slot, cachedValue); }); }); @@ -89,8 +75,8 @@ describe('journal', () => { expect(trace.traceNoteHashCheck).toHaveBeenCalledWith(address, utxo, leafIndex, exists); }); - it('writeNoteHash works', () => { - persistableState.writeNoteHash(address, utxo); + it('writeNoteHash works', async () => { + await persistableState.writeNoteHash(address, utxo); expect(trace.traceNewNoteHash).toHaveBeenCalledTimes(1); expect(trace.traceNewNoteHash).toHaveBeenCalledWith(expect.objectContaining(address), /*noteHash=*/ utxo); }); @@ -99,13 +85,7 @@ describe('journal', () => { const exists = await persistableState.checkNullifierExists(address, utxo); expect(exists).toEqual(false); expect(trace.traceNullifierCheck).toHaveBeenCalledTimes(1); - expect(trace.traceNullifierCheck).toHaveBeenCalledWith( - address, - utxo, - /*leafIndex=*/ Fr.ZERO, - exists, - /*isPending=*/ false, - ); + expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, utxo, exists); }); it('checkNullifierExists works for existing nullifiers', async () => { @@ -113,12 +93,13 @@ describe('journal', () => { const exists = await persistableState.checkNullifierExists(address, utxo); expect(exists).toEqual(true); expect(trace.traceNullifierCheck).toHaveBeenCalledTimes(1); - expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, utxo, leafIndex, exists, /*isPending=*/ false); + expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, utxo, exists); }); it('writeNullifier works', async () => { await persistableState.writeNullifier(address, utxo); expect(trace.traceNewNullifier).toHaveBeenCalledWith(expect.objectContaining(address), /*nullifier=*/ utxo); + expect(trace.traceNewNullifier).toHaveBeenCalledWith(address, /*nullifier=*/ utxo); }); it('checkL1ToL2MessageExists works for missing message', async () => { diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index 38cbbf58f694..ac5e88104742 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -1,12 +1,18 @@ +import { type IndexedTreeId, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/circuit-types'; import { type AztecAddress, type Gas, + type NullifierLeafPreimage, type PublicCallRequest, + PublicDataTreeLeaf, + PublicDataTreeLeafPreimage, SerializableContractInstance, computePublicBytecodeCommitment, } from '@aztec/circuits.js'; +import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/circuits.js/hash'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; +import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import assert from 'assert'; @@ -30,6 +36,9 @@ import { PublicStorage } from './public_storage.js'; export class AvmPersistableStateManager { private readonly log = createDebugLogger('aztec:avm_simulator:state_manager'); + /** Interface to perform merkle tree operations */ + public merkleTrees: MerkleTreeWriteOperations; + constructor( /** Reference to node storage */ private readonly worldStateDB: WorldStateDB, @@ -40,7 +49,15 @@ export class AvmPersistableStateManager { private readonly publicStorage: PublicStorage = new PublicStorage(worldStateDB), /** Nullifier set, including cached/recently-emitted nullifiers */ private readonly nullifiers: NullifierManager = new NullifierManager(worldStateDB), - ) {} + private readonly doMerkleOperations: boolean = false, + merkleTrees?: MerkleTreeWriteOperations, + ) { + if (merkleTrees) { + this.merkleTrees = merkleTrees; + } else { + this.merkleTrees = worldStateDB.getMerkleInterface(); + } + } /** * Create a new state manager with some preloaded pending siloed nullifiers @@ -68,6 +85,7 @@ export class AvmPersistableStateManager { this.trace.fork(incrementSideEffectCounter), this.publicStorage.fork(), this.nullifiers.fork(), + this.doMerkleOperations, ); } @@ -78,11 +96,46 @@ export class AvmPersistableStateManager { * @param slot - the slot in the contract's storage being written to * @param value - the value being written to the slot */ - public writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr) { + public async writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr): Promise { this.log.debug(`Storage write (address=${contractAddress}, slot=${slot}): value=${value}`); // Cache storage writes for later reference/reads this.publicStorage.write(contractAddress, slot, value); - this.trace.tracePublicStorageWrite(contractAddress, slot, value); + const leafSlot = computePublicDataTreeLeafSlot(contractAddress, slot); + if (this.doMerkleOperations) { + const result = await this.merkleTrees.batchInsert( + MerkleTreeId.PUBLIC_DATA_TREE, + [new PublicDataTreeLeaf(leafSlot, value).toBuffer()], + 0, + ); + assert(result !== undefined, 'Public data tree insertion error. You might want to disable skipMerkleOperations.'); + this.log.debug(`Inserted public data tree leaf at leafSlot ${leafSlot}, value: ${value}`); + + const lowLeafInfo = result.lowLeavesWitnessData![0]; + const lowLeafPreimage = lowLeafInfo.leafPreimage as PublicDataTreeLeafPreimage; + const lowLeafIndex = lowLeafInfo.index; + const lowLeafPath = lowLeafInfo.siblingPath.toFields(); + + const insertionPath = result.newSubtreeSiblingPath.toFields(); + const newLeafPreimage = new PublicDataTreeLeafPreimage( + leafSlot, + value, + lowLeafPreimage.nextSlot, + lowLeafPreimage.nextIndex, + ); + // FIXME: Why do we need to hint both preimages for public data writes, but not for nullifier insertions? + this.trace.tracePublicStorageWrite( + contractAddress, + slot, + value, + lowLeafPreimage, + new Fr(lowLeafIndex), + lowLeafPath, + newLeafPreimage, + insertionPath, + ); + } else { + this.trace.tracePublicStorageWrite(contractAddress, slot, value); + } } /** @@ -97,7 +150,41 @@ export class AvmPersistableStateManager { this.log.debug( `Storage read (address=${contractAddress}, slot=${slot}): value=${value}, exists=${exists}, cached=${cached}`, ); - this.trace.tracePublicStorageRead(contractAddress, slot, value, exists, cached); + + const leafSlot = computePublicDataTreeLeafSlot(contractAddress, slot); + + if (this.doMerkleOperations) { + // Get leaf if present, low leaf if absent + // If leaf is present, hint/trace it. Otherwise, hint/trace the low leaf. + const [leafIndex, leafPreimage, leafPath, _alreadyPresent] = await getLeafOrLowLeaf( + MerkleTreeId.PUBLIC_DATA_TREE, + leafSlot.toBigInt(), + this.merkleTrees, + ); + // FIXME: cannot have this assertion until "caching" is done via ephemeral merkle writes + //assert(alreadyPresent == exists, 'WorldStateDB contains public data leaf, but merkle tree does not.... This is a bug!'); + this.log.debug( + `leafPreimage.nextSlot: ${leafPreimage.nextSlot}, leafPreimage.nextIndex: ${Number(leafPreimage.nextIndex)}`, + ); + this.log.debug(`leafPreimage.slot: ${leafPreimage.slot}, leafPreimage.value: ${leafPreimage.value}`); + + if (!exists) { + // Sanity check that the leaf slot is skipped by low leaf when it doesn't exist + assert( + leafSlot.toBigInt() > leafPreimage.slot.toBigInt() && leafSlot.toBigInt() < leafPreimage.nextSlot.toBigInt(), + 'Public data tree low leaf should skip the target leaf slot when the target leaf does not exist.', + ); + } + this.log.debug( + `Tracing storage leaf preimage slot=${slot}, leafSlot=${leafSlot}, value=${value}, nextKey=${leafPreimage.nextSlot}, nextIndex=${leafPreimage.nextIndex}`, + ); + // On non-existence, AVM circuit will need to recognize that leafPreimage.slot != leafSlot, + // prove that this is a low leaf that skips leafSlot, and then prove memebership of the leaf. + this.trace.tracePublicStorageRead(contractAddress, slot, value, leafPreimage, new Fr(leafIndex), leafPath); + } else { + this.trace.tracePublicStorageRead(contractAddress, slot, value); + } + return Promise.resolve(value); } @@ -131,9 +218,14 @@ export class AvmPersistableStateManager { this.log.debug( `noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`, ); - // TODO(8287): We still return exists here, but we need to transmit both the requested noteHash and the gotLeafValue - // such that the VM can constrain the equality and decide on exists based on that. - this.trace.traceNoteHashCheck(contractAddress, gotLeafValue, leafIndex, exists); + if (this.doMerkleOperations) { + // TODO(8287): We still return exists here, but we need to transmit both the requested noteHash and the gotLeafValue + // such that the VM can constrain the equality and decide on exists based on that. + const path = await this.merkleTrees.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex.toBigInt()); + this.trace.traceNoteHashCheck(contractAddress, gotLeafValue, leafIndex, exists, path.toFields()); + } else { + this.trace.traceNoteHashCheck(contractAddress, gotLeafValue, leafIndex, exists); + } return Promise.resolve(exists); } @@ -141,9 +233,22 @@ export class AvmPersistableStateManager { * Write a note hash, trace the write. * @param noteHash - the unsiloed note hash to write */ - public writeNoteHash(contractAddress: AztecAddress, noteHash: Fr) { + public async writeNoteHash(contractAddress: AztecAddress, noteHash: Fr): Promise { this.log.debug(`noteHashes(${contractAddress}) += @${noteHash}.`); - this.trace.traceNewNoteHash(contractAddress, noteHash); + + if (this.doMerkleOperations) { + // TODO: We should track this globally here in the state manager + const info = await this.merkleTrees.getTreeInfo(MerkleTreeId.NOTE_HASH_TREE); + const leafIndex = new Fr(info.size + 1n); + + const path = await this.merkleTrees.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex.toBigInt()); + const siloedNoteHash = siloNoteHash(contractAddress, noteHash); + + await this.merkleTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, [siloedNoteHash]); + this.trace.traceNewNoteHash(contractAddress, noteHash, leafIndex, path.toFields()); + } else { + this.trace.traceNewNoteHash(contractAddress, noteHash); + } } /** @@ -153,11 +258,51 @@ export class AvmPersistableStateManager { * @returns exists - whether the nullifier exists in the nullifier set */ public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise { - const [exists, isPending, leafIndex] = await this.nullifiers.checkExists(contractAddress, nullifier); - this.log.debug( - `nullifiers(${contractAddress})@${nullifier} ?? leafIndex: ${leafIndex}, exists: ${exists}, pending: ${isPending}.`, - ); - this.trace.traceNullifierCheck(contractAddress, nullifier, leafIndex, exists, isPending); + const [exists, isPending, _] = await this.nullifiers.checkExists(contractAddress, nullifier); + + const siloedNullifier = siloNullifier(contractAddress, nullifier); + + if (this.doMerkleOperations) { + // Get leaf if present, low leaf if absent + // If leaf is present, hint/trace it. Otherwise, hint/trace the low leaf. + const [leafIndex, leafPreimage, leafPath, alreadyPresent] = await getLeafOrLowLeaf( + MerkleTreeId.NULLIFIER_TREE, + siloedNullifier.toBigInt(), + this.merkleTrees, + ); + assert( + alreadyPresent == exists, + 'WorldStateDB contains nullifier leaf, but merkle tree does not.... This is a bug!', + ); + + this.log.debug( + `nullifiers(${contractAddress})@${nullifier} ?? leafIndex: ${leafIndex}, exists: ${exists}, pending: ${isPending}.`, + ); + + if (!exists) { + // Sanity check that the leaf value is skipped by low leaf when it doesn't exist + assert( + siloedNullifier.toBigInt() > leafPreimage.nullifier.toBigInt() && + siloedNullifier.toBigInt() < leafPreimage.nextNullifier.toBigInt(), + 'Nullifier tree low leaf should skip the target leaf nullifier when the target leaf does not exist.', + ); + } + + this.trace.traceNullifierCheck( + contractAddress, + nullifier, // FIXME: Should this be siloed? + exists, + leafPreimage, + new Fr(leafIndex), + leafPath, + ); + } else { + this.trace.traceNullifierCheck( + contractAddress, + nullifier, // FIXME: Should this be siloed? + exists, + ); + } return Promise.resolve(exists); } @@ -170,8 +315,40 @@ export class AvmPersistableStateManager { this.log.debug(`nullifiers(${contractAddress}) += ${nullifier}.`); // Cache pending nullifiers for later access await this.nullifiers.append(contractAddress, nullifier); - // Trace all nullifier creations (even reverted ones) - this.trace.traceNewNullifier(contractAddress, nullifier); + + const siloedNullifier = siloNullifier(contractAddress, nullifier); + + if (this.doMerkleOperations) { + // Trace all nullifier creations, even duplicate insertions that fail + const alreadyPresent = await this.merkleTrees.getPreviousValueIndex( + MerkleTreeId.NULLIFIER_TREE, + siloedNullifier.toBigInt(), + ); + if (alreadyPresent) { + this.log.verbose(`Nullifier already present in tree: ${nullifier} at index ${alreadyPresent.index}.`); + } + const insertionResult = await this.merkleTrees.batchInsert( + MerkleTreeId.NULLIFIER_TREE, + [siloedNullifier.toBuffer()], + 0, + ); + const lowLeafInfo = insertionResult.lowLeavesWitnessData![0]; + const lowLeafPreimage = lowLeafInfo.leafPreimage as NullifierLeafPreimage; + const lowLeafIndex = lowLeafInfo.index; + const lowLeafPath = lowLeafInfo.siblingPath.toFields(); + const insertionPath = insertionResult.newSubtreeSiblingPath.toFields(); + + this.trace.traceNewNullifier( + contractAddress, + nullifier, + lowLeafPreimage, + new Fr(lowLeafIndex), + lowLeafPath, + insertionPath, + ); + } else { + this.trace.traceNewNullifier(contractAddress, nullifier); + } } /** @@ -190,9 +367,15 @@ export class AvmPersistableStateManager { this.log.debug( `l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`, ); - // TODO(8287): We still return exists here, but we need to transmit both the requested msgHash and the value - // such that the VM can constrain the equality and decide on exists based on that. - this.trace.traceL1ToL2MessageCheck(contractAddress, valueAtIndex, msgLeafIndex, exists); + + if (this.doMerkleOperations) { + // TODO(8287): We still return exists here, but we need to transmit both the requested msgHash and the value + // such that the VM can constrain the equality and decide on exists based on that. + const path = await this.merkleTrees.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, msgLeafIndex.toBigInt()); + this.trace.traceL1ToL2MessageCheck(contractAddress, valueAtIndex, msgLeafIndex, exists, path.toFields()); + } else { + this.trace.traceL1ToL2MessageCheck(contractAddress, valueAtIndex, msgLeafIndex, exists); + } return Promise.resolve(exists); } @@ -228,6 +411,7 @@ export class AvmPersistableStateManager { const instanceWithAddress = await this.worldStateDB.getContractInstance(contractAddress); const exists = instanceWithAddress !== undefined; + // TODO: nullifier check! if (exists) { const instance = new SerializableContractInstance(instanceWithAddress); this.log.debug( @@ -246,9 +430,16 @@ export class AvmPersistableStateManager { /** * Accept nested world state modifications */ - public acceptForkedState(forkedState: AvmPersistableStateManager) { + public mergeForkedState(forkedState: AvmPersistableStateManager) { + this.publicStorage.acceptAndMerge(forkedState.publicStorage); + this.nullifiers.acceptAndMerge(forkedState.nullifiers); + this.trace.mergeSuccessfulForkedTrace(forkedState.trace); + } + + public rejectForkedState(forkedState: AvmPersistableStateManager) { this.publicStorage.acceptAndMerge(forkedState.publicStorage); this.nullifiers.acceptAndMerge(forkedState.nullifiers); + this.trace.mergeRevertedForkedTrace(forkedState.trace); } /** @@ -290,10 +481,8 @@ export class AvmPersistableStateManager { return undefined; } } - /** - * Accept the nested call's state and trace the nested call - */ - public async processNestedCall( + + public async traceNestedCall( forkedState: AvmPersistableStateManager, nestedEnvironment: AvmExecutionEnvironment, startGasLeft: Gas, @@ -301,9 +490,6 @@ export class AvmPersistableStateManager { bytecode: Buffer, avmCallResults: AvmContractCallResult, ) { - if (!avmCallResults.reverted) { - this.acceptForkedState(forkedState); - } const functionName = await getPublicFunctionDebugName( this.worldStateDB, nestedEnvironment.address, @@ -311,7 +497,7 @@ export class AvmPersistableStateManager { nestedEnvironment.calldata, ); - this.log.verbose(`[AVM] Calling nested function ${functionName}`); + this.log.verbose(`[AVM] Tracing nested external contract call ${functionName}`); this.trace.traceNestedCall( forkedState.trace, @@ -324,46 +510,34 @@ export class AvmPersistableStateManager { ); } - public async mergeStateForEnqueuedCall( - forkedState: AvmPersistableStateManager, - /** The call request from private that enqueued this call. */ - publicCallRequest: PublicCallRequest, - /** The call's calldata */ - calldata: Fr[], - /** Did the call revert? */ - reverted: boolean, - ) { - if (!reverted) { - this.acceptForkedState(forkedState); - } - const functionName = await getPublicFunctionDebugName( - this.worldStateDB, - publicCallRequest.contractAddress, - publicCallRequest.functionSelector, - calldata, - ); - - this.log.verbose(`[AVM] Encountered enqueued public call starting with function ${functionName}`); - - this.trace.traceEnqueuedCall(forkedState.trace, publicCallRequest, calldata, reverted); + public traceEnqueuedCall(publicCallRequest: PublicCallRequest, calldata: Fr[], reverted: boolean) { + this.trace.traceEnqueuedCall(publicCallRequest, calldata, reverted); } +} - public mergeStateForPhase( - /** The forked state manager used by app logic */ - forkedState: AvmPersistableStateManager, - /** The call requests for each enqueued call in app logic. */ - publicCallRequests: PublicCallRequest[], - /** The calldatas for each enqueued call in app logic */ - calldatas: Fr[][], - /** Did the any enqueued call in app logic revert? */ - reverted: boolean, - ) { - if (!reverted) { - this.acceptForkedState(forkedState); - } - - this.log.verbose(`[AVM] Encountered app logic phase`); - - this.trace.traceExecutionPhase(forkedState.trace, publicCallRequests, calldatas, reverted); - } +/** + * Get leaf if present, low leaf if absent + */ +export async function getLeafOrLowLeaf( + treeId: IndexedTreeId, + key: bigint, + merkleTrees: MerkleTreeWriteOperations, +) { + // "key" is siloed slot (leafSlot) or siloed nullifier + const previousValueIndex = await merkleTrees.getPreviousValueIndex(treeId, key); + assert( + previousValueIndex !== undefined, + `${MerkleTreeId[treeId]} low leaf index should always be found (even if target leaf does not exist)`, + ); + const { index: leafIndex, alreadyPresent } = previousValueIndex; + + const leafPreimage = await merkleTrees.getLeafPreimage(treeId, leafIndex); + assert( + leafPreimage !== undefined, + `${MerkleTreeId[treeId]} low leaf preimage should never be undefined (even if target leaf does not exist)`, + ); + + const leafPath = await merkleTrees.getSiblingPath(treeId, leafIndex); + + return [leafIndex, leafPreimage as TreePreimageType, leafPath.toFields(), alreadyPresent] as const; } diff --git a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts index 4c016542f99f..65210cf21579 100644 --- a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts @@ -169,14 +169,8 @@ describe('Accrued Substate', () => { expect(trace.traceNullifierCheck).toHaveBeenCalledTimes(1); const isPending = false; // leafIndex is returned from DB call for nullifiers, so it is absent on DB miss - const tracedLeafIndex = exists && !isPending ? leafIndex : Fr.ZERO; - expect(trace.traceNullifierCheck).toHaveBeenCalledWith( - address, - /*nullifier=*/ value0, - tracedLeafIndex, - exists, - isPending, - ); + const _tracedLeafIndex = exists && !isPending ? leafIndex : Fr.ZERO; + expect(trace.traceNullifierCheck).toHaveBeenCalledWith(address, /*nullifier=*/ value0, exists); }); }); }); diff --git a/yarn-project/simulator/src/avm/opcodes/accrued_substate.ts b/yarn-project/simulator/src/avm/opcodes/accrued_substate.ts index 0a8bd01f1409..b93bfa40de76 100644 --- a/yarn-project/simulator/src/avm/opcodes/accrued_substate.ts +++ b/yarn-project/simulator/src/avm/opcodes/accrued_substate.ts @@ -70,7 +70,7 @@ export class EmitNoteHash extends Instruction { } const noteHash = memory.get(noteHashOffset).toFr(); - context.persistableState.writeNoteHash(context.environment.address, noteHash); + await context.persistableState.writeNoteHash(context.environment.address, noteHash); memory.assert({ reads: 1, addressing }); } diff --git a/yarn-project/simulator/src/avm/opcodes/arithmetic.test.ts b/yarn-project/simulator/src/avm/opcodes/arithmetic.test.ts index 21d0ca370866..022957eb2d2a 100644 --- a/yarn-project/simulator/src/avm/opcodes/arithmetic.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/arithmetic.test.ts @@ -231,7 +231,6 @@ describe('Arithmetic Instructions', () => { }); describe.each([ - [new Field(200n), new Field(99n), new Field(2n), TypeTag.FIELD], [new Uint8(200n), new Uint8(99n), new Uint8(2n), TypeTag.UINT8], [new Uint16(200n), new Uint16(99n), new Uint16(2n), TypeTag.UINT16], [new Uint32(200n), new Uint32(99n), new Uint32(2n), TypeTag.UINT32], diff --git a/yarn-project/simulator/src/avm/opcodes/arithmetic.ts b/yarn-project/simulator/src/avm/opcodes/arithmetic.ts index 30a1ead0efa9..0b5c88a92cb3 100644 --- a/yarn-project/simulator/src/avm/opcodes/arithmetic.ts +++ b/yarn-project/simulator/src/avm/opcodes/arithmetic.ts @@ -1,5 +1,11 @@ import type { AvmContext } from '../avm_context.js'; -import { type Field, type MemoryValue } from '../avm_memory_types.js'; +import { + type Field, + type MemoryValue, + TaggedMemory, + type TaggedMemoryInterface, + TypeTag, +} from '../avm_memory_types.js'; import { ArithmeticError } from '../errors.js'; import { Opcode } from '../serialization/instruction_serialization.js'; import { Addressing } from './addressing_mode.js'; @@ -13,7 +19,7 @@ export abstract class ThreeOperandArithmeticInstruction extends ThreeOperandInst const operands = [this.aOffset, this.bOffset, this.dstOffset]; const addressing = Addressing.fromWire(this.indirect, operands.length); const [aOffset, bOffset, dstOffset] = addressing.resolve(operands, memory); - memory.checkTagsAreSame(aOffset, bOffset); + this.checkTags(memory, aOffset, bOffset); const a = memory.get(aOffset); const b = memory.get(bOffset); @@ -25,6 +31,9 @@ export abstract class ThreeOperandArithmeticInstruction extends ThreeOperandInst } protected abstract compute(a: MemoryValue, b: MemoryValue): MemoryValue; + protected checkTags(memory: TaggedMemoryInterface, aOffset: number, bOffset: number) { + memory.checkTagsAreSame(aOffset, bOffset); + } } export class Add extends ThreeOperandArithmeticInstruction { @@ -65,6 +74,11 @@ export class Div extends ThreeOperandArithmeticInstruction { return a.div(b); } + + protected override checkTags(memory: TaggedMemoryInterface, aOffset: number, bOffset: number) { + memory.checkTagsAreSame(aOffset, bOffset); + TaggedMemory.checkIsIntegralTag(memory.getTag(aOffset)); // Follows that bOffset tag is also of integral type + } } export class FieldDiv extends ThreeOperandArithmeticInstruction { @@ -75,4 +89,9 @@ export class FieldDiv extends ThreeOperandArithmeticInstruction { // return (a as Field).fdiv(b as Field); return a.fdiv(b); } + + protected override checkTags(memory: TaggedMemoryInterface, aOffset: number, bOffset: number) { + memory.checkTagsAreSame(aOffset, bOffset); + memory.checkTag(TypeTag.FIELD, aOffset); // Follows that bOffset has also tag of type Field + } } diff --git a/yarn-project/simulator/src/avm/opcodes/external_calls.ts b/yarn-project/simulator/src/avm/opcodes/external_calls.ts index 9b52a8ff160c..7bfbe5e8c714 100644 --- a/yarn-project/simulator/src/avm/opcodes/external_calls.ts +++ b/yarn-project/simulator/src/avm/opcodes/external_calls.ts @@ -98,7 +98,10 @@ abstract class ExternalCall extends Instruction { context.machineState.refundGas(gasLeftToGas(nestedContext.machineState)); // Accept the nested call's state and trace the nested call - await context.persistableState.processNestedCall( + if (success) { + context.persistableState.mergeForkedState(nestedContext.persistableState); + } + await context.persistableState.traceNestedCall( /*nestedState=*/ nestedContext.persistableState, /*nestedEnvironment=*/ nestedContext.environment, /*startGasLeft=*/ Gas.from(allocatedGas), diff --git a/yarn-project/simulator/src/avm/opcodes/storage.ts b/yarn-project/simulator/src/avm/opcodes/storage.ts index f01c573c93c3..318e4d130932 100644 --- a/yarn-project/simulator/src/avm/opcodes/storage.ts +++ b/yarn-project/simulator/src/avm/opcodes/storage.ts @@ -43,7 +43,7 @@ export class SStore extends BaseStorageInstruction { const slot = memory.get(slotOffset).toFr(); const value = memory.get(srcOffset).toFr(); - context.persistableState.writeStorage(context.environment.address, slot, value); + await context.persistableState.writeStorage(context.environment.address, slot, value); memory.assert({ reads: 2, addressing }); } diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index be7e8bcde19d..c933b4caeba2 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -24,7 +24,7 @@ import { } from '@aztec/circuits.js'; import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; import { type FunctionAbi, type FunctionArtifact, type NoteSelector, countArgumentsSize } from '@aztec/foundation/abi'; -import { type AztecAddress } from '@aztec/foundation/aztec-address'; +import { AztecAddress } from '@aztec/foundation/aztec-address'; import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; @@ -62,7 +62,7 @@ export class ClientExecutionContext extends ViewDataOracle { private noteHashNullifierCounterMap: Map = new Map(); private noteEncryptedLogs: CountedNoteLog[] = []; private encryptedLogs: CountedLog[] = []; - private unencryptedLogs: CountedLog[] = []; + private contractClassLogs: CountedLog[] = []; private nestedExecutions: PrivateExecutionResult[] = []; private enqueuedPublicFunctionCalls: CountedPublicExecutionRequest[] = []; private publicTeardownFunctionCall: PublicExecutionRequest = PublicExecutionRequest.empty(); @@ -151,10 +151,10 @@ export class ClientExecutionContext extends ViewDataOracle { } /** - * Return the encrypted logs emitted during this execution. + * Return the contract class logs emitted during this execution. */ - public getUnencryptedLogs() { - return this.unencryptedLogs; + public getContractClassLogs() { + return this.contractClassLogs; } /** @@ -360,16 +360,6 @@ export class ClientExecutionContext extends ViewDataOracle { this.noteEncryptedLogs.push(encryptedLog); } - /** - * Emit an unencrypted log. - * @param log - The unencrypted log to be emitted. - */ - public override emitUnencryptedLog(log: UnencryptedL2Log, counter: number) { - this.unencryptedLogs.push(new CountedLog(log, counter)); - const text = log.toHumanReadable(); - this.log.verbose(`Emitted unencrypted log: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`); - } - /** * Emit a contract class unencrypted log. * This fn exists separately from emitUnencryptedLog because sha hashing the preimage @@ -377,13 +367,11 @@ export class ClientExecutionContext extends ViewDataOracle { * See private_context.nr * @param log - The unencrypted log to be emitted. */ - public override emitContractClassUnencryptedLog(log: UnencryptedL2Log, counter: number) { - this.unencryptedLogs.push(new CountedLog(log, counter)); + public override emitContractClassLog(log: UnencryptedL2Log, counter: number) { + this.contractClassLogs.push(new CountedLog(log, counter)); const text = log.toHumanReadable(); this.log.verbose( - `Emitted unencrypted log from ContractClassRegisterer: "${ - text.length > 100 ? text.slice(0, 100) + '...' : text - }"`, + `Emitted log from ContractClassRegisterer: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`, ); return Fr.fromBuffer(log.hash()); } @@ -394,7 +382,7 @@ export class ClientExecutionContext extends ViewDataOracle { childExecutionResult.publicInputs.nullifiers.some(item => !item.isEmpty()) || childExecutionResult.publicInputs.l2ToL1Msgs.some(item => !item.isEmpty()) || childExecutionResult.publicInputs.encryptedLogsHashes.some(item => !item.isEmpty()) || - childExecutionResult.publicInputs.unencryptedLogsHashes.some(item => !item.isEmpty()) + childExecutionResult.publicInputs.contractClassLogsHashes.some(item => !item.isEmpty()) ) { throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`); } @@ -610,12 +598,18 @@ export class ClientExecutionContext extends ViewDataOracle { return this.db.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector); } - public override async incrementAppTaggingSecret(sender: AztecAddress, recipient: AztecAddress) { - await this.db.incrementAppTaggingSecret(this.contractAddress, sender, recipient); + public override async incrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress) { + await this.db.incrementAppTaggingSecretIndexAsSender(this.contractAddress, sender, recipient); } - public override async syncNotes(recipient: AztecAddress) { - const taggedLogs = await this.db.syncTaggedLogs(this.contractAddress, recipient); - await this.db.processTaggedLogs(taggedLogs, recipient); + public override async syncNotes() { + const taggedLogsByRecipient = await this.db.syncTaggedLogs( + this.contractAddress, + this.historicalHeader.globalVariables.blockNumber.toNumber(), + this.scopes, + ); + for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) { + await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient)); + } } } diff --git a/yarn-project/simulator/src/client/db_oracle.ts b/yarn-project/simulator/src/client/db_oracle.ts index 304ea84d76c0..4047c17d83bc 100644 --- a/yarn-project/simulator/src/client/db_oracle.ts +++ b/yarn-project/simulator/src/client/db_oracle.ts @@ -1,10 +1,11 @@ import { type L2Block, + type L2BlockNumber, type MerkleTreeId, type NoteStatus, type NullifierMembershipWitness, type PublicDataWitness, - type TxScopedEncryptedL2NoteLog, + type TxScopedL2Log, } from '@aztec/circuit-types'; import { type CompleteAddress, @@ -146,7 +147,7 @@ export interface DBOracle extends CommitmentsDB { * @param leafValue - The leaf value buffer. * @returns - The index of the leaf. Undefined if it does not exist in the tree. */ - findLeafIndex(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise; + findLeafIndex(blockNumber: L2BlockNumber, treeId: MerkleTreeId, leafValue: Fr): Promise; /** * Fetch the sibling path of the leaf in the respective tree @@ -204,7 +205,7 @@ export interface DBOracle extends CommitmentsDB { * @param recipient - The address receiving the note * @returns A tagging secret that can be used to tag notes. */ - getAppTaggingSecret( + getAppTaggingSecretAsSender( contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress, @@ -216,7 +217,7 @@ export interface DBOracle extends CommitmentsDB { * @param sender - The address sending the note * @param recipient - The address receiving the note */ - incrementAppTaggingSecret( + incrementAppTaggingSecretIndexAsSender( contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress, @@ -229,12 +230,16 @@ export interface DBOracle extends CommitmentsDB { * @param recipient - The address of the recipient * @returns A list of encrypted logs tagged with the recipient's address */ - syncTaggedLogs(contractAddress: AztecAddress, recipient: AztecAddress): Promise; + syncTaggedLogs( + contractAddress: AztecAddress, + maxBlockNumber: number, + scopes?: AztecAddress[], + ): Promise>; /** * Processes the tagged logs returned by syncTaggedLogs by decrypting them and storing them in the database. * @param logs - The logs to process. * @param recipient - The recipient of the logs. */ - processTaggedLogs(logs: TxScopedEncryptedL2NoteLog[], recipient: AztecAddress): Promise; + processTaggedLogs(logs: TxScopedL2Log[], recipient: AztecAddress): Promise; } diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 989c5ed70675..2d35d94c7f0e 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -27,7 +27,6 @@ import { PUBLIC_DISPATCH_SELECTOR, PartialStateReference, StateReference, - TaggingSecret, TxContext, computeAppNullifierSecretKey, computeOvskApp, @@ -259,10 +258,10 @@ describe('Private Execution test suite', () => { throw new Error(`Unknown address: ${address}. Recipient: ${recipient}, Owner: ${owner}`); }); - oracle.getAppTaggingSecret.mockImplementation( - (_contractAddress: AztecAddress, _sender: AztecAddress, recipient: AztecAddress) => { - const directionalSecret = new TaggingSecret(Fr.random(), recipient); - return Promise.resolve(IndexedTaggingSecret.fromTaggingSecret(directionalSecret, 0)); + oracle.getAppTaggingSecretAsSender.mockImplementation( + (_contractAddress: AztecAddress, _sender: AztecAddress, _recipient: AztecAddress) => { + const secret = Fr.random(); + return Promise.resolve(new IndexedTaggingSecret(secret, 0)); }, ); @@ -414,6 +413,8 @@ describe('Private Execution test suite', () => { buildNote(60n, ownerCompleteAddress.address, storageSlot, valueNoteTypeId), buildNote(80n, ownerCompleteAddress.address, storageSlot, valueNoteTypeId), ]; + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue(notes); const consumedNotes = await asyncMap(notes, ({ nonce, note }) => @@ -479,6 +480,8 @@ describe('Private Execution test suite', () => { const storageSlot = deriveStorageSlotInMap(new Fr(1n), owner); const notes = [buildNote(balance, ownerCompleteAddress.address, storageSlot, valueNoteTypeId)]; + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue(notes); const consumedNotes = await asyncMap(notes, ({ nonce, note }) => @@ -603,7 +606,7 @@ describe('Private Execution test suite', () => { const contractAddress = defaultContractAddress; describe('L1 to L2', () => { - const artifact = getFunctionArtifact(TestContractArtifact, 'consume_mint_private_message'); + const artifact = getFunctionArtifact(TestContractArtifact, 'consume_mint_to_private_message'); let bridgedAmount = 100n; const l1ToL2MessageIndex = 0; @@ -626,7 +629,7 @@ describe('Private Execution test suite', () => { const computePreimage = () => buildL1ToL2Message( - toFunctionSelector('mint_private(uint256)').substring(2), + toFunctionSelector('mint_to_private(uint256)').substring(2), [new Fr(bridgedAmount)], crossChainMsgRecipient ?? contractAddress, secretForL1ToL2MessageConsumption, @@ -812,6 +815,8 @@ describe('Private Execution test suite', () => { const secretHash = computeSecretHash(secret); const note = new Note([secretHash]); const storageSlot = TestContractArtifact.storageLayout['example_set'].slot; + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue([ { contractAddress, @@ -915,6 +920,8 @@ describe('Private Execution test suite', () => { }); it('should be able to insert, read, and nullify pending note hashes in one call', async () => { + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue([]); const amountToTransfer = 100n; @@ -976,6 +983,8 @@ describe('Private Execution test suite', () => { }); it('should be able to insert, read, and nullify pending note hashes in nested calls', async () => { + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue([]); const amountToTransfer = 100n; @@ -1058,6 +1067,8 @@ describe('Private Execution test suite', () => { }); it('cant read a commitment that is inserted later in same call', async () => { + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue([]); const amountToTransfer = 100n; @@ -1097,6 +1108,8 @@ describe('Private Execution test suite', () => { const artifact = getFunctionArtifact(TestContractArtifact, 'call_get_notes'); const args = [2n, true]; + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getNotes.mockResolvedValue([]); await expect(() => runSimulator({ artifact, args })).rejects.toThrow( diff --git a/yarn-project/simulator/src/client/private_execution.ts b/yarn-project/simulator/src/client/private_execution.ts index 2a4512be96c5..2e71194575f2 100644 --- a/yarn-project/simulator/src/client/private_execution.ts +++ b/yarn-project/simulator/src/client/private_execution.ts @@ -61,7 +61,7 @@ export async function executePrivateFunction( const noteEncryptedLogs = context.getNoteEncryptedLogs(); const encryptedLogs = context.getEncryptedLogs(); - const unencryptedLogs = context.getUnencryptedLogs(); + const contractClassLogs = context.getContractClassLogs(); const rawReturnValues = await context.unpackReturns(publicInputs.returnsHash); @@ -88,7 +88,7 @@ export async function executePrivateFunction( publicTeardownFunctionCall, noteEncryptedLogs, encryptedLogs, - unencryptedLogs, + contractClassLogs, ); } diff --git a/yarn-project/simulator/src/client/unconstrained_execution.test.ts b/yarn-project/simulator/src/client/unconstrained_execution.test.ts index b1eb64457a8e..99bb3e3842d2 100644 --- a/yarn-project/simulator/src/client/unconstrained_execution.test.ts +++ b/yarn-project/simulator/src/client/unconstrained_execution.test.ts @@ -53,6 +53,8 @@ describe('Unconstrained Execution test suite', () => { const notes: Note[] = [...Array(5).fill(buildNote(1n, owner)), ...Array(2).fill(buildNote(2n, owner))]; + oracle.syncTaggedLogs.mockResolvedValue(new Map()); + oracle.processTaggedLogs.mockResolvedValue(); oracle.getHeader.mockResolvedValue(Header.empty()); oracle.getNotes.mockResolvedValue( notes.map((note, index) => ({ diff --git a/yarn-project/simulator/src/client/view_data_oracle.ts b/yarn-project/simulator/src/client/view_data_oracle.ts index a6651c12f877..bd5633f2103e 100644 --- a/yarn-project/simulator/src/client/view_data_oracle.ts +++ b/yarn-project/simulator/src/client/view_data_oracle.ts @@ -14,7 +14,7 @@ import { type KeyValidationRequest, } from '@aztec/circuits.js'; import { siloNullifier } from '@aztec/circuits.js/hash'; -import { type AztecAddress } from '@aztec/foundation/aztec-address'; +import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; @@ -302,10 +302,21 @@ export class ViewDataOracle extends TypedOracle { * @param recipient - The address receiving the note * @returns A tagging secret that can be used to tag notes. */ - public override async getAppTaggingSecret( + public override async getAppTaggingSecretAsSender( sender: AztecAddress, recipient: AztecAddress, ): Promise { - return await this.db.getAppTaggingSecret(this.contractAddress, sender, recipient); + return await this.db.getAppTaggingSecretAsSender(this.contractAddress, sender, recipient); + } + + public override async syncNotes() { + const taggedLogsByRecipient = await this.db.syncTaggedLogs( + this.contractAddress, + await this.aztecNode.getBlockNumber(), + this.scopes, + ); + for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) { + await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient)); + } } } diff --git a/yarn-project/simulator/src/public/dual_side_effect_trace.ts b/yarn-project/simulator/src/public/dual_side_effect_trace.ts index c1c6bbcda596..15fa4b76456a 100644 --- a/yarn-project/simulator/src/public/dual_side_effect_trace.ts +++ b/yarn-project/simulator/src/public/dual_side_effect_trace.ts @@ -3,7 +3,9 @@ import { type CombinedConstantData, type ContractClassIdPreimage, type Gas, + type NullifierLeafPreimage, type PublicCallRequest, + type PublicDataTreeLeafPreimage, type SerializableContractInstance, type VMCircuitPublicInputs, } from '@aztec/circuits.js'; @@ -37,46 +39,116 @@ export class DualSideEffectTrace implements PublicSideEffectTraceInterface { return this.innerCallTrace.getCounter(); } - public tracePublicStorageRead(contractAddress: AztecAddress, slot: Fr, value: Fr, exists: boolean, cached: boolean) { - this.innerCallTrace.tracePublicStorageRead(contractAddress, slot, value, exists, cached); - this.enqueuedCallTrace.tracePublicStorageRead(contractAddress, slot, value, exists, cached); + public tracePublicStorageRead( + contractAddress: AztecAddress, + slot: Fr, + value: Fr, + leafPreimage: PublicDataTreeLeafPreimage, + leafIndex: Fr, + path: Fr[], + ) { + this.innerCallTrace.tracePublicStorageRead(contractAddress, slot, value, leafPreimage, leafIndex, path); + this.enqueuedCallTrace.tracePublicStorageRead(contractAddress, slot, value, leafPreimage, leafIndex, path); } - public tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, value: Fr) { - this.innerCallTrace.tracePublicStorageWrite(contractAddress, slot, value); - this.enqueuedCallTrace.tracePublicStorageWrite(contractAddress, slot, value); + public tracePublicStorageWrite( + contractAddress: AztecAddress, + slot: Fr, + value: Fr, + lowLeafPreimage: PublicDataTreeLeafPreimage, + lowLeafIndex: Fr, + lowLeafPath: Fr[], + newLeafPreimage: PublicDataTreeLeafPreimage, + insertionPath: Fr[], + ) { + this.innerCallTrace.tracePublicStorageWrite( + contractAddress, + slot, + value, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + newLeafPreimage, + insertionPath, + ); + this.enqueuedCallTrace.tracePublicStorageWrite( + contractAddress, + slot, + value, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + newLeafPreimage, + insertionPath, + ); } // TODO(8287): _exists can be removed once we have the vm properly handling the equality check - public traceNoteHashCheck(_contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean) { - this.innerCallTrace.traceNoteHashCheck(_contractAddress, noteHash, leafIndex, exists); - this.enqueuedCallTrace.traceNoteHashCheck(_contractAddress, noteHash, leafIndex, exists); + public traceNoteHashCheck(contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean, path: Fr[]) { + this.innerCallTrace.traceNoteHashCheck(contractAddress, noteHash, leafIndex, exists, path); + this.enqueuedCallTrace.traceNoteHashCheck(contractAddress, noteHash, leafIndex, exists, path); } - public traceNewNoteHash(_contractAddress: AztecAddress, noteHash: Fr) { - this.innerCallTrace.traceNewNoteHash(_contractAddress, noteHash); - this.enqueuedCallTrace.traceNewNoteHash(_contractAddress, noteHash); + public traceNewNoteHash(contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, path: Fr[]) { + this.innerCallTrace.traceNewNoteHash(contractAddress, noteHash, leafIndex, path); + this.enqueuedCallTrace.traceNewNoteHash(contractAddress, noteHash, leafIndex, path); } public traceNullifierCheck( contractAddress: AztecAddress, nullifier: Fr, - leafIndex: Fr, exists: boolean, - isPending: boolean, + lowLeafPreimage: NullifierLeafPreimage, + lowLeafIndex: Fr, + lowLeafPath: Fr[], ) { - this.innerCallTrace.traceNullifierCheck(contractAddress, nullifier, leafIndex, exists, isPending); - this.enqueuedCallTrace.traceNullifierCheck(contractAddress, nullifier, leafIndex, exists, isPending); + this.innerCallTrace.traceNullifierCheck( + contractAddress, + nullifier, + exists, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + ); + this.enqueuedCallTrace.traceNullifierCheck( + contractAddress, + nullifier, + exists, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + ); } - public traceNewNullifier(contractAddress: AztecAddress, nullifier: Fr) { - this.innerCallTrace.traceNewNullifier(contractAddress, nullifier); - this.enqueuedCallTrace.traceNewNullifier(contractAddress, nullifier); + public traceNewNullifier( + contractAddress: AztecAddress, + nullifier: Fr, + lowLeafPreimage: NullifierLeafPreimage, + lowLeafIndex: Fr, + lowLeafPath: Fr[], + insertionPath: Fr[], + ) { + this.innerCallTrace.traceNewNullifier( + contractAddress, + nullifier, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + insertionPath, + ); + this.enqueuedCallTrace.traceNewNullifier( + contractAddress, + nullifier, + lowLeafPreimage, + lowLeafIndex, + lowLeafPath, + insertionPath, + ); } - public traceL1ToL2MessageCheck(contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) { - this.innerCallTrace.traceL1ToL2MessageCheck(contractAddress, msgHash, msgLeafIndex, exists); - this.enqueuedCallTrace.traceL1ToL2MessageCheck(contractAddress, msgHash, msgLeafIndex, exists); + traceL1ToL2MessageCheck(contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean, path: Fr[]) { + this.innerCallTrace.traceL1ToL2MessageCheck(contractAddress, msgHash, msgLeafIndex, exists, path); + this.enqueuedCallTrace.traceL1ToL2MessageCheck(contractAddress, msgHash, msgLeafIndex, exists, path); } public traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) { @@ -150,8 +222,6 @@ export class DualSideEffectTrace implements PublicSideEffectTraceInterface { } public traceEnqueuedCall( - /** The trace of the enqueued call. */ - enqueuedCallTrace: this, /** The call request from private that enqueued this call. */ publicCallRequest: PublicCallRequest, /** The call's calldata */ @@ -159,30 +229,15 @@ export class DualSideEffectTrace implements PublicSideEffectTraceInterface { /** Did the call revert? */ reverted: boolean, ) { - this.enqueuedCallTrace.traceEnqueuedCall( - enqueuedCallTrace.enqueuedCallTrace, - publicCallRequest, - calldata, - reverted, - ); + this.enqueuedCallTrace.traceEnqueuedCall(publicCallRequest, calldata, reverted); } - public traceExecutionPhase( - /** The trace of the enqueued call. */ - appLogicTrace: this, - /** The call request from private that enqueued this call. */ - publicCallRequests: PublicCallRequest[], - /** The call's calldata */ - calldatas: Fr[][], - /** Did the any enqueued call in app logic revert? */ - reverted: boolean, - ) { - this.enqueuedCallTrace.traceExecutionPhase( - appLogicTrace.enqueuedCallTrace, - publicCallRequests, - calldatas, - reverted, - ); + public mergeSuccessfulForkedTrace(nestedTrace: this) { + this.enqueuedCallTrace.mergeSuccessfulForkedTrace(nestedTrace.enqueuedCallTrace); + } + + public mergeRevertedForkedTrace(nestedTrace: this) { + this.enqueuedCallTrace.mergeRevertedForkedTrace(nestedTrace.enqueuedCallTrace); } /** diff --git a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts index 4b32d350a18b..f5712effaf2f 100644 --- a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts @@ -18,10 +18,12 @@ import { MAX_UNENCRYPTED_LOGS_PER_TX, NoteHash, Nullifier, + NullifierLeafPreimage, PublicAccumulatedData, PublicAccumulatedDataArrayLengths, PublicCallRequest, PublicDataRead, + PublicDataTreeLeafPreimage, PublicDataUpdateRequest, PublicValidationRequestArrayLengths, PublicValidationRequests, @@ -106,9 +108,8 @@ describe('Enqueued-call Side Effect Trace', () => { }; it('Should trace storage reads', () => { - const exists = true; - const cached = false; - trace.tracePublicStorageRead(address, slot, value, exists, cached); + const leafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + trace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicValidationRequests.empty().publicDataReads; @@ -117,11 +118,14 @@ describe('Enqueued-call Side Effect Trace', () => { const circuitPublicInputs = toVMCircuitPublicInputs(trace); expect(circuitPublicInputs.validationRequests.publicDataReads).toEqual(expectedArray); - expect(trace.getAvmCircuitHints().storageValues.items).toEqual([{ key: startCounterFr, value: value }]); + expect(trace.getAvmCircuitHints().storageValues.items).toEqual([{ key: startCounterFr, value }]); }); it('Should trace storage writes', () => { - trace.tracePublicStorageWrite(address, slot, value); + const lowLeafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + const newLeafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + + trace.tracePublicStorageWrite(address, slot, value, lowLeafPreimage, Fr.ZERO, [], newLeafPreimage, []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicAccumulatedData.empty().publicDataUpdateRequests; @@ -134,7 +138,7 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should trace note hash checks', () => { const exists = true; - trace.traceNoteHashCheck(address, utxo, leafIndex, exists); + trace.traceNoteHashCheck(address, utxo, leafIndex, exists, []); const expectedArray = PublicValidationRequests.empty().noteHashReadRequests; expectedArray[0] = new TreeLeafReadRequest(utxo, leafIndex); @@ -146,7 +150,7 @@ describe('Enqueued-call Side Effect Trace', () => { }); it('Should trace note hashes', () => { - trace.traceNewNoteHash(address, utxo); + trace.traceNewNoteHash(address, utxo, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicAccumulatedData.empty().noteHashes; @@ -158,8 +162,8 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should trace nullifier checks', () => { const exists = true; - const isPending = false; - trace.traceNullifierCheck(address, utxo, leafIndex, exists, isPending); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNullifierCheck(address, utxo, exists, lowLeafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicValidationRequests.empty().nullifierReadRequests; @@ -176,8 +180,8 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should trace non-existent nullifier checks', () => { const exists = false; - const isPending = false; - trace.traceNullifierCheck(address, utxo, leafIndex, exists, isPending); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNullifierCheck(address, utxo, exists, lowLeafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicValidationRequests.empty().nullifierNonExistentReadRequests; @@ -193,7 +197,8 @@ describe('Enqueued-call Side Effect Trace', () => { }); it('Should trace nullifiers', () => { - trace.traceNewNullifier(address, utxo); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNewNullifier(address, utxo, lowLeafPreimage, Fr.ZERO, [], []); expect(trace.getCounter()).toBe(startCounterPlus1); const expectedArray = PublicAccumulatedData.empty().nullifiers; @@ -205,7 +210,7 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should trace L1ToL2 Message checks', () => { const exists = true; - trace.traceL1ToL2MessageCheck(address, utxo, leafIndex, exists); + trace.traceL1ToL2MessageCheck(address, utxo, leafIndex, exists, []); const expectedArray = PublicValidationRequests.empty().l1ToL2MsgReadRequests; expectedArray[0] = new TreeLeafReadRequest(utxo, leafIndex); @@ -268,82 +273,102 @@ describe('Enqueued-call Side Effect Trace', () => { describe('Maximum accesses', () => { it('Should enforce maximum number of public storage reads', () => { for (let i = 0; i < MAX_PUBLIC_DATA_READS_PER_TX; i++) { - trace.tracePublicStorageRead(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(i), new Fr(i), Fr.ZERO, 0n); + trace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); } - expect(() => - trace.tracePublicStorageRead(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true), - ).toThrow(SideEffectLimitReachedError); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(42), new Fr(42), Fr.ZERO, 0n); + expect(() => trace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, [])).toThrow( + SideEffectLimitReachedError, + ); }); it('Should enforce maximum number of public storage writes', () => { for (let i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { - trace.tracePublicStorageWrite(AztecAddress.fromNumber(i), new Fr(i), new Fr(i)); + const lowLeafPreimage = new PublicDataTreeLeafPreimage(new Fr(i), new Fr(i), Fr.ZERO, 0n); + const newLeafPreimage = new PublicDataTreeLeafPreimage(new Fr(i + 1), new Fr(i + 1), Fr.ZERO, 0n); + trace.tracePublicStorageWrite(address, slot, value, lowLeafPreimage, Fr.ZERO, [], newLeafPreimage, []); } - expect(() => trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( - SideEffectLimitReachedError, - ); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(42), new Fr(42), Fr.ZERO, 0n); + expect(() => + trace.tracePublicStorageWrite( + AztecAddress.fromNumber(42), + new Fr(42), + value, + leafPreimage, + Fr.ZERO, + [], + leafPreimage, + [], + ), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of note hash checks', () => { for (let i = 0; i < MAX_NOTE_HASH_READ_REQUESTS_PER_TX; i++) { - trace.traceNoteHashCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true); + trace.traceNoteHashCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, []); } - expect(() => trace.traceNoteHashCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true)).toThrow( + expect(() => trace.traceNoteHashCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, [])).toThrow( SideEffectLimitReachedError, ); }); it('Should enforce maximum number of new note hashes', () => { for (let i = 0; i < MAX_NOTE_HASHES_PER_TX; i++) { - trace.traceNewNoteHash(AztecAddress.fromNumber(i), new Fr(i)); + trace.traceNewNoteHash(AztecAddress.fromNumber(i), new Fr(i), Fr.ZERO, []); } - expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42))).toThrow( + expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42), Fr.ZERO, [])).toThrow( SideEffectLimitReachedError, ); }); it('Should enforce maximum number of nullifier checks', () => { for (let i = 0; i < MAX_NULLIFIER_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true)).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), true, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); // NOTE: also cannot do a non-existent check once existent checks have filled up - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false, true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), false, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of nullifier non-existent checks', () => { for (let i = 0; i < MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), false, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false, true)).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), false, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); // NOTE: also cannot do a existent check once non-existent checks have filled up - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), true, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of new nullifiers', () => { for (let i = 0; i < MAX_NULLIFIERS_PER_TX; i++) { - trace.traceNewNullifier(AztecAddress.fromNumber(i), new Fr(i)); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i + 1), Fr.ZERO, 0n); + trace.traceNewNullifier(AztecAddress.fromNumber(i), new Fr(i), lowLeafPreimage, Fr.ZERO, [], []); } - expect(() => trace.traceNewNullifier(AztecAddress.fromNumber(42), new Fr(42))).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNewNullifier(AztecAddress.fromNumber(42), new Fr(42), lowLeafPreimage, Fr.ZERO, [], []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of L1 to L2 message checks', () => { for (let i = 0; i < MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX; i++) { - trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true); + trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, []); } - expect(() => trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of new l2 to l1 messages', () => { @@ -366,7 +391,8 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should enforce maximum number of nullifier checks for GETCONTRACTINSTANCE', () => { for (let i = 0; i < MAX_NULLIFIER_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } expect(() => trace.traceGetContractInstance(address, /*exists=*/ true, contractInstance)).toThrow( SideEffectLimitReachedError, @@ -379,7 +405,8 @@ describe('Enqueued-call Side Effect Trace', () => { it('Should enforce maximum number of nullifier non-existent checks for GETCONTRACTINSTANCE', () => { for (let i = 0; i < MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), false, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } expect(() => trace.traceGetContractInstance(address, /*exists=*/ false, contractInstance)).toThrow( SideEffectLimitReachedError, @@ -411,22 +438,22 @@ describe('Enqueued-call Side Effect Trace', () => { 0, ), ); - expect(() => - trace.tracePublicStorageRead(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true), - ).toThrow(SideEffectLimitReachedError); + expect(() => trace.tracePublicStorageRead(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( + SideEffectLimitReachedError, + ); expect(() => trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( SideEffectLimitReachedError, ); expect(() => trace.traceNoteHashCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true)).toThrow( SideEffectLimitReachedError, ); - expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42))).toThrow( + expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( SideEffectLimitReachedError, ); - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false, true)).toThrow( + expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), false)).toThrow( SideEffectLimitReachedError, ); - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true)).toThrow( + expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), true)).toThrow( SideEffectLimitReachedError, ); expect(() => trace.traceNewNullifier(AztecAddress.fromNumber(42), new Fr(42))).toThrow( @@ -453,26 +480,26 @@ describe('Enqueued-call Side Effect Trace', () => { describe.each([avmCallResults, avmCallRevertedResults])('Should trace & absorb nested calls', callResults => { it(`${callResults.reverted ? 'Reverted' : 'Successful'} calls should be traced and absorbed properly`, () => { const existsDefault = true; - const cached = false; - const isPending = false; const nestedTrace = new PublicEnqueuedCallSideEffectTrace(startCounter); let testCounter = startCounter; - nestedTrace.tracePublicStorageRead(address, slot, value, existsDefault, cached); + const leafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + nestedTrace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.tracePublicStorageWrite(address, slot, value); + nestedTrace.tracePublicStorageWrite(address, slot, value, leafPreimage, Fr.ZERO, [], leafPreimage, []); testCounter++; - nestedTrace.traceNoteHashCheck(address, utxo, leafIndex, existsDefault); + nestedTrace.traceNoteHashCheck(address, utxo, leafIndex, existsDefault, []); // counter does not increment for note hash checks - nestedTrace.traceNewNoteHash(address, utxo); + nestedTrace.traceNewNoteHash(address, utxo, Fr.ZERO, []); testCounter++; - nestedTrace.traceNullifierCheck(address, utxo, leafIndex, /*exists=*/ true, isPending); + nestedTrace.traceNullifierCheck(address, utxo, true, lowLeafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.traceNullifierCheck(address, utxo, leafIndex, /*exists=*/ false, isPending); + nestedTrace.traceNullifierCheck(address, utxo, true, lowLeafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.traceNewNullifier(address, utxo); + nestedTrace.traceNewNullifier(address, utxo, lowLeafPreimage, Fr.ZERO, [], []); testCounter++; - nestedTrace.traceL1ToL2MessageCheck(address, utxo, leafIndex, existsDefault); + nestedTrace.traceL1ToL2MessageCheck(address, utxo, leafIndex, existsDefault, []); // counter does not increment for l1tol2 message checks nestedTrace.traceNewL2ToL1Message(address, recipient, content); testCounter++; @@ -491,17 +518,16 @@ describe('Enqueued-call Side Effect Trace', () => { // parent absorbs child's side effects const parentSideEffects = trace.getSideEffects(); const childSideEffects = nestedTrace.getSideEffects(); + // TODO(dbanks12): confirm that all hints were merged from child if (callResults.reverted) { - expect(parentSideEffects.publicDataReads).toEqual(childSideEffects.publicDataReads); - expect(parentSideEffects.publicDataWrites).toEqual(childSideEffects.publicDataWrites); - expect(parentSideEffects.noteHashReadRequests).toEqual(childSideEffects.noteHashReadRequests); + expect(parentSideEffects.publicDataReads).toEqual([]); + expect(parentSideEffects.publicDataWrites).toEqual([]); + expect(parentSideEffects.noteHashReadRequests).toEqual([]); expect(parentSideEffects.noteHashes).toEqual([]); - expect(parentSideEffects.nullifierReadRequests).toEqual(childSideEffects.nullifierReadRequests); - expect(parentSideEffects.nullifierNonExistentReadRequests).toEqual( - childSideEffects.nullifierNonExistentReadRequests, - ); - expect(parentSideEffects.nullifiers).toEqual(childSideEffects.nullifiers); - expect(parentSideEffects.l1ToL2MsgReadRequests).toEqual(childSideEffects.l1ToL2MsgReadRequests); + expect(parentSideEffects.nullifierReadRequests).toEqual([]); + expect(parentSideEffects.nullifierNonExistentReadRequests).toEqual([]); + expect(parentSideEffects.nullifiers).toEqual([]); + expect(parentSideEffects.l1ToL2MsgReadRequests).toEqual([]); expect(parentSideEffects.l2ToL1Msgs).toEqual([]); expect(parentSideEffects.unencryptedLogs).toEqual([]); expect(parentSideEffects.unencryptedLogsHashes).toEqual([]); diff --git a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts index cef43fb3d132..69815118b5f1 100644 --- a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts +++ b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts @@ -1,16 +1,26 @@ import { UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types'; import { + AvmAccumulatedData, + AvmAppendTreeHint, + AvmCircuitPublicInputs, AvmContractBytecodeHints, AvmContractInstanceHint, AvmEnqueuedCallHint, AvmExecutionHints, AvmExternalCallHint, AvmKeyValueHint, + AvmNullifierReadTreeHint, + AvmNullifierWriteTreeHint, + AvmPublicDataReadTreeHint, + AvmPublicDataWriteTreeHint, type AztecAddress, type CombinedConstantData, type ContractClassIdPreimage, EthAddress, Gas, + type GasSettings, + type GlobalVariables, + L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, LogHash, MAX_ENCRYPTED_LOGS_PER_TX, @@ -26,13 +36,21 @@ import { MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + NOTE_HASH_TREE_HEIGHT, + NULLIFIER_TREE_HEIGHT, NoteHash, Nullifier, + NullifierLeafPreimage, + PUBLIC_DATA_TREE_HEIGHT, + PrivateToAvmAccumulatedData, + PrivateToAvmAccumulatedDataArrayLengths, PublicAccumulatedData, PublicAccumulatedDataArrayLengths, PublicCallRequest, PublicDataRead, + PublicDataTreeLeafPreimage, PublicDataUpdateRequest, + PublicDataWrite, PublicInnerCallRequest, PublicValidationRequestArrayLengths, PublicValidationRequests, @@ -44,6 +62,7 @@ import { ScopedReadRequest, SerializableContractInstance, TreeLeafReadRequest, + type TreeSnapshots, VMCircuitPublicInputs, } from '@aztec/circuits.js'; import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/circuits.js/hash'; @@ -51,6 +70,9 @@ import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; +import { type Tuple } from '@aztec/foundation/serialize'; + +import { assert } from 'console'; import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js'; import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js'; @@ -59,6 +81,11 @@ import { type EnqueuedPublicCallExecutionResultWithSideEffects, type PublicFunct import { SideEffectLimitReachedError } from './side_effect_errors.js'; import { type PublicSideEffectTraceInterface } from './side_effect_trace_interface.js'; +const emptyPublicDataPath = () => new Array(PUBLIC_DATA_TREE_HEIGHT).fill(Fr.zero()); +const emptyNoteHashPath = () => new Array(NOTE_HASH_TREE_HEIGHT).fill(Fr.zero()); +const emptyNullifierPath = () => new Array(NULLIFIER_TREE_HEIGHT).fill(Fr.zero()); +const emptyL1ToL2MessagePath = () => new Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.zero()); + /** * A struct containing just the side effects as regular arrays * as opposed to "Tuple" arrays used by circuit public inputs. @@ -93,6 +120,9 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI /** The side effect counter increments with every call to the trace. */ private sideEffectCounter: number; + //private publicSetupCallRequests: PublicCallRequest[] = []; + //private publicAppLogicCallRequests: PublicCallRequest[] = []; + //private publicTeardownCallRequest: PublicCallRequest[] = []; private enqueuedCalls: PublicCallRequest[] = []; private publicDataReads: PublicDataRead[] = []; @@ -163,9 +193,14 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI contractAddress: AztecAddress, slot: Fr, value: Fr, - _exists: boolean, - _cached: boolean, + leafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + leafIndex: Fr = Fr.zero(), + path: Fr[] = emptyPublicDataPath(), ) { + if (!leafIndex.equals(Fr.zero())) { + // if we have real merkle hint content, make sure the value matches the the provided preimage + assert(leafPreimage.value.equals(value), 'Value mismatch when tracing in public data write'); + } // NOTE: exists and cached are unused for now but may be used for optimizations or kernel hints later if ( this.publicDataReads.length + this.previousValidationRequestArrayLengths.publicDataReads >= @@ -175,15 +210,31 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI } const leafSlot = computePublicDataTreeLeafSlot(contractAddress, slot); + this.publicDataReads.push(new PublicDataRead(leafSlot, value, this.sideEffectCounter)); + this.avmCircuitHints.storageValues.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ value), ); + this.avmCircuitHints.storageReadRequest.items.push(new AvmPublicDataReadTreeHint(leafPreimage, leafIndex, path)); this.log.debug(`SLOAD cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`); this.incrementSideEffectCounter(); } - public tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, value: Fr) { + public tracePublicStorageWrite( + contractAddress: AztecAddress, + slot: Fr, + value: Fr, + lowLeafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyPublicDataPath(), + newLeafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + insertionPath: Fr[] = emptyPublicDataPath(), + ) { + if (!lowLeafIndex.equals(Fr.zero())) { + // if we have real merkle hint content, make sure the value matches the the provided preimage + assert(newLeafPreimage.value.equals(value), 'Value mismatch when tracing in public data read'); + } if ( this.publicDataWrites.length + this.previousAccumulatedDataArrayLengths.publicDataUpdateRequests >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX @@ -196,12 +247,27 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI const leafSlot = computePublicDataTreeLeafSlot(contractAddress, slot); this.publicDataWrites.push(new PublicDataUpdateRequest(leafSlot, value, this.sideEffectCounter)); - this.log.debug(`SSTORE cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`); + + // New hinting + const readHint = new AvmPublicDataReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath); + this.avmCircuitHints.storageUpdateRequest.items.push( + new AvmPublicDataWriteTreeHint(readHint, newLeafPreimage, insertionPath), + ); + + this.log.debug( + `Traced public data write (address=${contractAddress}, slot=${slot}, leafSlot=${leafSlot}): value=${value} (counter=${this.sideEffectCounter})`, + ); this.incrementSideEffectCounter(); } // TODO(8287): _exists can be removed once we have the vm properly handling the equality check - public traceNoteHashCheck(_contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean) { + public traceNoteHashCheck( + _contractAddress: AztecAddress, + noteHash: Fr, + leafIndex: Fr, + exists: boolean, + path: Fr[] = emptyNoteHashPath(), + ) { // NOTE: contractAddress is unused because noteHash is an already-siloed leaf if ( this.noteHashReadRequests.length + this.previousValidationRequestArrayLengths.noteHashReadRequests >= @@ -215,10 +281,17 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI this.avmCircuitHints.noteHashExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(leafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); + // New Hinting + this.avmCircuitHints.noteHashReadRequest.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path)); // NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes) } - public traceNewNoteHash(contractAddress: AztecAddress, noteHash: Fr) { + public traceNewNoteHash( + contractAddress: AztecAddress, + noteHash: Fr, + leafIndex: Fr, + path: Fr[] = emptyNoteHashPath(), + ) { if (this.noteHashes.length + this.previousAccumulatedDataArrayLengths.noteHashes >= MAX_NOTE_HASHES_PER_TX) { throw new SideEffectLimitReachedError('note hash', MAX_NOTE_HASHES_PER_TX); } @@ -227,15 +300,17 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI //const siloedNoteHash = siloNoteHash(contractAddress, noteHash); this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter).scope(contractAddress)); this.log.debug(`NEW_NOTE_HASH cnt: ${this.sideEffectCounter}`); + this.avmCircuitHints.noteHashWriteRequest.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path)); this.incrementSideEffectCounter(); } public traceNullifierCheck( contractAddress: AztecAddress, nullifier: Fr, - _leafIndex: Fr, exists: boolean, - _isPending: boolean, + lowLeafPreimage: NullifierLeafPreimage = NullifierLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyNullifierPath(), ) { // NOTE: isPending and leafIndex are unused for now but may be used for optimizations or kernel hints later this.enforceLimitOnNullifierChecks(); @@ -252,23 +327,44 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI this.avmCircuitHints.nullifierExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), ); + // New Hints + this.avmCircuitHints.nullifierReadRequest.items.push( + new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath), + ); this.log.debug(`NULLIFIER_EXISTS cnt: ${this.sideEffectCounter}`); this.incrementSideEffectCounter(); } - public traceNewNullifier(contractAddress: AztecAddress, nullifier: Fr) { + public traceNewNullifier( + contractAddress: AztecAddress, + nullifier: Fr, + lowLeafPreimage: NullifierLeafPreimage = NullifierLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyNullifierPath(), + insertionPath: Fr[] = emptyNullifierPath(), + ) { if (this.nullifiers.length + this.previousAccumulatedDataArrayLengths.nullifiers >= MAX_NULLIFIERS_PER_TX) { throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX); } const siloedNullifier = siloNullifier(contractAddress, nullifier); this.nullifiers.push(new Nullifier(siloedNullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO)); + + // New hinting + const lowLeafReadHint = new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath); + this.avmCircuitHints.nullifierWriteHints.items.push(new AvmNullifierWriteTreeHint(lowLeafReadHint, insertionPath)); this.log.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`); this.incrementSideEffectCounter(); } // TODO(8287): _exists can be removed once we have the vm properly handling the equality check - public traceL1ToL2MessageCheck(_contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) { + public traceL1ToL2MessageCheck( + _contractAddress: AztecAddress, + msgHash: Fr, + msgLeafIndex: Fr, + exists: boolean, + path: Fr[] = emptyL1ToL2MessagePath(), + ) { // NOTE: contractAddress is unused because msgHash is an already-siloed leaf if ( this.l1ToL2MsgReadRequests.length + this.previousValidationRequestArrayLengths.l1ToL2MsgReadRequests >= @@ -281,6 +377,8 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI this.avmCircuitHints.l1ToL2MessageExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(msgLeafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); + // New Hinting + this.avmCircuitHints.l1ToL2MessageReadRequest.items.push(new AvmAppendTreeHint(msgLeafIndex, msgHash, path)); } public traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) { @@ -392,20 +490,11 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI /** Function name for logging */ _functionName: string = 'unknown', ) { + // TODO(4805): check if some threshold is reached for max nested calls (to unique contracts?) + // // Store end side effect counter before it gets updated by absorbing nested call trace const endSideEffectCounter = new Fr(this.sideEffectCounter); - // TODO(4805): check if some threshold is reached for max nested calls (to unique contracts?) - // TODO(dbanks12): should emit a nullifier read request. There should be two thresholds. - // one for max unique contract calls, and another based on max nullifier reads. - // Since this trace function happens _after_ a nested call, such threshold limits must take - // place in another trace function that occurs _before_ a nested call. - if (avmCallResults.reverted) { - this.mergeRevertedForkedTrace(nestedCallTrace); - } else { - this.mergeSuccessfulForkedTrace(nestedCallTrace); - } - const gasUsed = new Gas(startGasLeft.daGas - endGasLeft.daGas, startGasLeft.l2Gas - endGasLeft.l2Gas); this.avmCircuitHints.externalCalls.items.push( @@ -424,66 +513,25 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI * Accept some results from a finished call's trace into this one. */ public traceEnqueuedCall( - /** The trace of the enqueued call. */ - enqueuedCallTrace: this, /** The call request from private that enqueued this call. */ publicCallRequest: PublicCallRequest, /** The call's calldata */ calldata: Fr[], /** Did the call revert? */ - reverted: boolean, + _reverted: boolean, ) { + this.log.debug(`Tracing enqueued call`); // TODO(4805): check if some threshold is reached for max enqueued or nested calls (to unique contracts?) - // TODO(dbanks12): should emit a nullifier read request. There should be two thresholds. - // one for max unique contract calls, and another based on max nullifier reads. - // Since this trace function happens _after_ a nested call, such threshold limits must take - // place in another trace function that occurs _before_ a nested call. - if (reverted) { - this.mergeRevertedForkedTrace(enqueuedCallTrace); - } else { - this.mergeSuccessfulForkedTrace(enqueuedCallTrace); - } - this.enqueuedCalls.push(publicCallRequest); - this.avmCircuitHints.enqueuedCalls.items.push(new AvmEnqueuedCallHint(publicCallRequest.contractAddress, calldata)); } - /** - * Trace an enqueued call. - * Accept some results from a finished call's trace into this one. - */ - public traceExecutionPhase( - /** The trace of the enqueued call. */ - phaseTrace: this, - /** The call request from private that enqueued this call. */ - publicCallRequests: PublicCallRequest[], - /** The call's calldata */ - calldatas: Fr[][], - /** Did the any enqueued call in app logic revert? */ - reverted: boolean, - ) { - // We only merge in enqueued calls here at the top-level - // because enqueued calls cannot enqueue others. - this.enqueuedCalls.push(...phaseTrace.enqueuedCalls); - if (reverted) { - this.mergeRevertedForkedTrace(phaseTrace); - } else { - this.mergeSuccessfulForkedTrace(phaseTrace); - } - - for (let i = 0; i < publicCallRequests.length; i++) { - this.enqueuedCalls.push(publicCallRequests[i]); - - this.avmCircuitHints.enqueuedCalls.items.push( - new AvmEnqueuedCallHint(publicCallRequests[i].contractAddress, calldatas[i]), - ); - } - } - - private mergeSuccessfulForkedTrace(nestedTrace: this) { + public mergeSuccessfulForkedTrace(nestedTrace: this) { // TODO(dbanks12): accept & merge nested trace's hints! this.sideEffectCounter = nestedTrace.sideEffectCounter; + + this.enqueuedCalls.push(...nestedTrace.enqueuedCalls); + this.publicDataReads.push(...nestedTrace.publicDataReads); this.publicDataWrites.push(...nestedTrace.publicDataWrites); this.noteHashReadRequests.push(...nestedTrace.noteHashReadRequests); @@ -497,24 +545,14 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI this.unencryptedLogsHashes.push(...nestedTrace.unencryptedLogsHashes); } - private mergeRevertedForkedTrace(nestedTrace: this) { - // All read requests, and any writes (storage & nullifiers) that - // require complex validation in public kernel (with end lifetimes) - // must be absorbed even on revert. - + /** + * Discard accumulated side effects, but keep hints. + */ + public mergeRevertedForkedTrace(nestedTrace: this) { // TODO(dbanks12): accept & merge nested trace's hints! - // TODO(dbanks12): What should happen to side effect counter on revert? this.sideEffectCounter = nestedTrace.sideEffectCounter; - this.publicDataReads.push(...nestedTrace.publicDataReads); - this.publicDataWrites.push(...nestedTrace.publicDataWrites); - this.noteHashReadRequests.push(...nestedTrace.noteHashReadRequests); - // new noteHashes are tossed on revert - this.nullifierReadRequests.push(...nestedTrace.nullifierReadRequests); - this.nullifierNonExistentReadRequests.push(...nestedTrace.nullifierNonExistentReadRequests); - this.nullifiers.push(...nestedTrace.nullifiers); - this.l1ToL2MsgReadRequests.push(...nestedTrace.l1ToL2MsgReadRequests); - // new l2-to-l1 messages are tossed on revert - // new unencrypted logs are tossed on revert + + this.enqueuedCalls.push(...nestedTrace.enqueuedCalls); } public getSideEffects(): SideEffects { @@ -595,6 +633,53 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI ); } + public toAvmCircuitPublicInputs( + /** Globals. */ + globalVariables: GlobalVariables, + /** Start tree snapshots. */ + startTreeSnapshots: TreeSnapshots, + /** Gas used at start of TX. */ + startGasUsed: Gas, + /** How much gas was available for this public execution. */ + gasLimits: GasSettings, + /** Call requests for setup phase. */ + publicSetupCallRequests: Tuple, + /** Call requests for app logic phase. */ + publicAppLogicCallRequests: Tuple, + /** Call request for teardown phase. */ + publicTeardownCallRequest: PublicCallRequest, + /** End tree snapshots. */ + endTreeSnapshots: TreeSnapshots, + /** + * Gas used by the whole transaction, assuming entire teardown limit is used. + * This is the gas used when computing transaction fee. + */ + endGasUsed: Gas, + /** Transaction fee. */ + transactionFee: Fr, + /** The call's results */ + reverted: boolean, + ): AvmCircuitPublicInputs { + return new AvmCircuitPublicInputs( + globalVariables, + startTreeSnapshots, + startGasUsed, + gasLimits, + publicSetupCallRequests, + publicAppLogicCallRequests, + publicTeardownCallRequest, + /*previousNonRevertibleAccumulatedDataArrayLengths=*/ PrivateToAvmAccumulatedDataArrayLengths.empty(), + /*previousRevertibleAccumulatedDataArrayLengths=*/ PrivateToAvmAccumulatedDataArrayLengths.empty(), + /*previousNonRevertibleAccumulatedDataArray=*/ PrivateToAvmAccumulatedData.empty(), + /*previousRevertibleAccumulatedDataArray=*/ PrivateToAvmAccumulatedData.empty(), + endTreeSnapshots, + endGasUsed, + /*accumulatedData=*/ this.getAvmAccumulatedData(), + transactionFee, + reverted, + ); + } + public toPublicFunctionCallResult( /** The execution environment of the nested call. */ _avmEnvironment: AvmExecutionEnvironment, @@ -635,6 +720,28 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI ); } + private getAvmAccumulatedData() { + return new AvmAccumulatedData( + padArrayEnd( + this.noteHashes.map(n => n.value), + Fr.zero(), + MAX_NOTE_HASHES_PER_TX, + ), + padArrayEnd( + this.nullifiers.map(n => n.value), + Fr.zero(), + MAX_NULLIFIERS_PER_TX, + ), + padArrayEnd(this.l2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), + padArrayEnd(this.unencryptedLogsHashes, ScopedLogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_TX), + padArrayEnd( + this.publicDataWrites.map(w => new PublicDataWrite(w.leafSlot, w.newValue)), + PublicDataWrite.empty(), + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + ), + ); + } + private getAccumulatedData(gasUsed: Gas) { return new PublicAccumulatedData( padArrayEnd(this.noteHashes, ScopedNoteHash.empty(), MAX_NOTE_HASHES_PER_TX), diff --git a/yarn-project/simulator/src/public/enqueued_calls_processor.ts b/yarn-project/simulator/src/public/enqueued_calls_processor.ts deleted file mode 100644 index 1aaeef23cac3..000000000000 --- a/yarn-project/simulator/src/public/enqueued_calls_processor.ts +++ /dev/null @@ -1,540 +0,0 @@ -import { - type AvmProvingRequest, - type GasUsed, - type MerkleTreeReadOperations, - type NestedProcessReturnValues, - type PublicExecutionRequest, - type SimulationError, - type Tx, - TxExecutionPhase, -} from '@aztec/circuit-types'; -import { - AvmAccumulatedData, - AvmCircuitPublicInputs, - type CombinedAccumulatedData, - CombinedConstantData, - EnqueuedCallData, - Fr, - Gas, - type GlobalVariables, - type Header, - type KernelCircuitPublicInputs, - NESTED_RECURSIVE_PROOF_LENGTH, - type PrivateKernelTailCircuitPublicInputs, - PrivateToAvmAccumulatedData, - PrivateToAvmAccumulatedDataArrayLengths, - type PrivateToPublicAccumulatedData, - PublicAccumulatedData, - PublicAccumulatedDataArrayLengths, - type PublicCallRequest, - PublicKernelCircuitPrivateInputs, - PublicKernelCircuitPublicInputs, - PublicKernelData, - PublicValidationRequestArrayLengths, - PublicValidationRequests, - RevertCode, - TreeSnapshots, - type VMCircuitPublicInputs, - VerificationKeyData, - countAccumulatedItems, - makeEmptyProof, - makeEmptyRecursiveProof, -} from '@aztec/circuits.js'; -import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; -import { Timer } from '@aztec/foundation/timer'; -import { getVKSiblingPath } from '@aztec/noir-protocol-circuits-types'; - -import { inspect } from 'util'; - -import { AvmPersistableStateManager } from '../avm/journal/journal.js'; -import { DualSideEffectTrace } from './dual_side_effect_trace.js'; -import { PublicEnqueuedCallSideEffectTrace } from './enqueued_call_side_effect_trace.js'; -import { EnqueuedCallSimulator } from './enqueued_call_simulator.js'; -import { type PublicExecutor } from './executor.js'; -import { type WorldStateDB } from './public_db_sources.js'; -import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; -import { PublicKernelTailSimulator } from './public_kernel_tail_simulator.js'; -import { PublicSideEffectTrace } from './side_effect_trace.js'; - -const PhaseIsRevertible: Record = { - [TxExecutionPhase.SETUP]: false, - [TxExecutionPhase.APP_LOGIC]: true, - [TxExecutionPhase.TEARDOWN]: true, -}; - -type PublicPhaseResult = { - avmProvingRequest: AvmProvingRequest; - /** The output of the public kernel circuit simulation for this phase */ - publicKernelOutput: PublicKernelCircuitPublicInputs; - /** Return values of simulating complete callstack */ - returnValues: NestedProcessReturnValues[]; - /** Gas used during the execution of this phase */ - gasUsed: Gas; - /** Time spent for the execution this phase */ - durationMs: number; - /** Reverted */ - reverted: boolean; - /** Revert reason, if any */ - revertReason?: SimulationError; -}; - -type PhaseGasUsed = Record; - -export type ProcessedPhase = { - phase: TxExecutionPhase; - durationMs: number; - returnValues: NestedProcessReturnValues[]; - revertReason?: SimulationError; -}; - -export type TxPublicCallsResult = { - avmProvingRequest: AvmProvingRequest; - /** Gas used during the execution of this tx */ - gasUsed: GasUsed; - revertCode: RevertCode; - /** Revert reason, if any */ - revertReason?: SimulationError; - processedPhases: ProcessedPhase[]; -}; - -export class EnqueuedCallsProcessor { - private log: DebugLogger; - - constructor( - private publicKernelSimulator: PublicKernelCircuitSimulator, - private globalVariables: GlobalVariables, - private worldStateDB: WorldStateDB, - private enqueuedCallSimulator: EnqueuedCallSimulator, - private publicKernelTailSimulator: PublicKernelTailSimulator, - ) { - this.log = createDebugLogger(`aztec:sequencer`); - } - - static create( - db: MerkleTreeReadOperations, - publicExecutor: PublicExecutor, - publicKernelSimulator: PublicKernelCircuitSimulator, - globalVariables: GlobalVariables, - historicalHeader: Header, - worldStateDB: WorldStateDB, - realAvmProvingRequests: boolean = true, - ) { - const enqueuedCallSimulator = new EnqueuedCallSimulator( - db, - worldStateDB, - publicExecutor, - globalVariables, - historicalHeader, - realAvmProvingRequests, - ); - - const publicKernelTailSimulator = PublicKernelTailSimulator.create(db, publicKernelSimulator); - - return new EnqueuedCallsProcessor( - publicKernelSimulator, - globalVariables, - worldStateDB, - enqueuedCallSimulator, - publicKernelTailSimulator, - ); - } - - static getExecutionRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicExecutionRequest[] { - switch (phase) { - case TxExecutionPhase.SETUP: - return tx.getNonRevertiblePublicExecutionRequests(); - case TxExecutionPhase.APP_LOGIC: - return tx.getRevertiblePublicExecutionRequests(); - case TxExecutionPhase.TEARDOWN: { - const request = tx.getPublicTeardownExecutionRequest(); - return request ? [request] : []; - } - default: - throw new Error(`Unknown phase: ${phase}`); - } - } - - static getCallRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequest[] { - switch (phase) { - case TxExecutionPhase.SETUP: - return tx.data.getNonRevertiblePublicCallRequests(); - case TxExecutionPhase.APP_LOGIC: - return tx.data.getRevertiblePublicCallRequests(); - case TxExecutionPhase.TEARDOWN: { - const request = tx.data.getTeardownPublicCallRequest(); - return request ? [request] : []; - } - default: - throw new Error(`Unknown phase: ${phase}`); - } - } - - async process(tx: Tx): Promise { - this.log.verbose(`Processing tx ${tx.getTxHash()}`); - - const constants = CombinedConstantData.combine(tx.data.constants, this.globalVariables); - const phases: TxExecutionPhase[] = [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN]; - const processedPhases: ProcessedPhase[] = []; - let phaseGasUsed: PhaseGasUsed = { - [TxExecutionPhase.SETUP]: Gas.empty(), - [TxExecutionPhase.APP_LOGIC]: Gas.empty(), - [TxExecutionPhase.TEARDOWN]: Gas.empty(), - }; - let avmProvingRequest: AvmProvingRequest; - let publicKernelOutput = this.getPublicKernelCircuitPublicInputs(tx.data); - let revertReason: SimulationError | undefined; - - const nonRevertibleNullifiersFromPrivate = publicKernelOutput.endNonRevertibleData.nullifiers - .filter(n => !n.isEmpty()) - .map(n => n.value); - const _revertibleNullifiersFromPrivate = publicKernelOutput.end.nullifiers - .filter(n => !n.isEmpty()) - .map(n => n.value); - - // During SETUP, non revertible side effects from private are our "previous data" - const prevAccumulatedData = publicKernelOutput.endNonRevertibleData; - const previousValidationRequestArrayLengths = PublicValidationRequestArrayLengths.new( - publicKernelOutput.validationRequests, - ); - - const previousAccumulatedDataArrayLengths = PublicAccumulatedDataArrayLengths.new(prevAccumulatedData); - const innerCallTrace = new PublicSideEffectTrace(); - const enqueuedCallTrace = new PublicEnqueuedCallSideEffectTrace( - /*startSideEffectCounter=*/ 0, - previousValidationRequestArrayLengths, - previousAccumulatedDataArrayLengths, - ); - const trace = new DualSideEffectTrace(innerCallTrace, enqueuedCallTrace); - - // Transaction level state manager that will be forked for revertible phases. - const txStateManager = AvmPersistableStateManager.newWithPendingSiloedNullifiers( - this.worldStateDB, - trace, - nonRevertibleNullifiersFromPrivate, - ); - // TODO(dbanks12): insert all non-revertible side effects from private here. - - for (let i = 0; i < phases.length; i++) { - const phase = phases[i]; - let stateManagerForPhase: AvmPersistableStateManager; - if (phase === TxExecutionPhase.SETUP) { - // don't need to fork for setup since it's non-revertible - // (if setup fails, transaction is thrown out) - stateManagerForPhase = txStateManager; - } else { - // Fork the state manager so that we can rollback state if a revertible phase reverts. - stateManagerForPhase = txStateManager.fork(); - // NOTE: Teardown is revertible, but will run even if app logic reverts! - } - const callRequests = EnqueuedCallsProcessor.getCallRequestsByPhase(tx, phase); - if (callRequests.length) { - const allocatedGas = this.getAllocatedGasForPhase(phase, tx, phaseGasUsed); - const transactionFee = phase !== TxExecutionPhase.TEARDOWN ? Fr.ZERO : this.getTransactionFee(tx, phaseGasUsed); - - const executionRequests = EnqueuedCallsProcessor.getExecutionRequestsByPhase(tx, phase); - const result = await this.processPhase( - phase, - tx, - constants, - callRequests, - executionRequests, - publicKernelOutput, - allocatedGas, - transactionFee, - stateManagerForPhase, - ).catch(async err => { - await this.worldStateDB.rollbackToCommit(); - throw err; - }); - - publicKernelOutput = result.publicKernelOutput; - - // Propagate only one avmProvingRequest of a function call for now, so that we know it's still provable. - // Eventually this will be the proof for the entire public call stack. - avmProvingRequest = result.avmProvingRequest; - - if (phase !== TxExecutionPhase.SETUP) { - txStateManager.mergeStateForPhase( - stateManagerForPhase, - callRequests, - executionRequests.map(req => req.args), - /*reverted=*/ result.revertReason ? true : false, - ); - } - - processedPhases.push({ - phase, - durationMs: result.durationMs, - returnValues: result.returnValues, - revertReason: result.revertReason, - }); - - phaseGasUsed = { - ...phaseGasUsed, - [phase]: result.gasUsed, - }; - - revertReason ??= result.revertReason; - } - } - - const tailKernelOutput = await this.publicKernelTailSimulator.simulate(publicKernelOutput).catch( - // the abstract phase manager throws if simulation gives error in non-revertible phase - async err => { - await this.worldStateDB.rollbackToCommit(); - throw err; - }, - ); - - const transactionFee = this.getTransactionFee(tx, phaseGasUsed); - avmProvingRequest!.inputs.output = this.generateAvmCircuitPublicInputs(tx, tailKernelOutput, transactionFee); - - const gasUsed = { - totalGas: this.getActualGasUsed(tx, phaseGasUsed), - teardownGas: phaseGasUsed[TxExecutionPhase.TEARDOWN], - }; - - return { - avmProvingRequest: avmProvingRequest!, - gasUsed, - processedPhases, - revertCode: tailKernelOutput.revertCode, - revertReason, - }; - } - - private async processPhase( - phase: TxExecutionPhase, - tx: Tx, - constants: CombinedConstantData, - callRequests: PublicCallRequest[], - executionRequests: PublicExecutionRequest[], - previousPublicKernelOutput: PublicKernelCircuitPublicInputs, - allocatedGas: Gas, - transactionFee: Fr, - txStateManager: AvmPersistableStateManager, - ): Promise { - this.log.debug(`Beginning processing in phase ${TxExecutionPhase[phase]} for tx ${tx.getTxHash()}`); - - const phaseTimer = new Timer(); - const returnValues: NestedProcessReturnValues[] = []; - let availableGas = allocatedGas; - let avmProvingRequest: AvmProvingRequest; - let publicKernelOutput = previousPublicKernelOutput; - let reverted: boolean = false; - let revertReason: SimulationError | undefined; - for (let i = callRequests.length - 1; i >= 0; i--) { - if (reverted) { - break; - } - - const callRequest = callRequests[i]; - const executionRequest = executionRequests[i]; - - // add new contracts to the contracts db so that their functions may be found and called - // TODO(#4073): This is catching only private deployments, when we add public ones, we'll - // have to capture contracts emitted in that phase as well. - // TODO(@spalladino): Should we allow emitting contracts in the fee preparation phase? - // TODO(#6464): Should we allow emitting contracts in the private setup phase? - // if so, this should only add contracts that were deployed during private app logic. - await this.worldStateDB.addNewContracts(tx); - - // each enqueued call starts with an incremented side effect counter - const enqueuedCallStateManager = txStateManager.fork(/*incrementSideEffectCounter=*/ true); - const enqueuedCallResult = await this.enqueuedCallSimulator.simulate( - callRequest, - executionRequest, - constants, - availableGas, - transactionFee, - enqueuedCallStateManager, - ); - - if (enqueuedCallResult.revertReason && !PhaseIsRevertible[phase]) { - this.log.debug( - `Simulation error on ${executionRequest.callContext.contractAddress}:${executionRequest.callContext.functionSelector} with reason: ${enqueuedCallResult.revertReason}`, - ); - throw enqueuedCallResult.revertReason; - } - await txStateManager.mergeStateForEnqueuedCall( - enqueuedCallStateManager, - callRequest, - executionRequest.args, - enqueuedCallResult.reverted!, - ); - - availableGas = availableGas.sub(enqueuedCallResult.gasUsed); - avmProvingRequest = enqueuedCallResult.avmProvingRequest; - returnValues.push(enqueuedCallResult.returnValues); - reverted = enqueuedCallResult.reverted; - revertReason = enqueuedCallResult.revertReason; - - // Instead of operating on worldStateDB here, do we do AvmPersistableStateManager.revert() or return()? - if (reverted) { - // TODO(#6464): Should we allow emitting contracts in the private setup phase? - // if so, this is removing contracts deployed in private setup - // You can't submit contracts in public, so this is only relevant for private-created - // side effects - // Are we reverting here back to end of non-revertible insertions? - // What are we reverting back to? - await this.worldStateDB.removeNewContracts(tx); - tx.filterRevertedLogs(publicKernelOutput); - } else { - tx.unencryptedLogs.addFunctionLogs([enqueuedCallResult.newUnencryptedLogs]); - } - - const output = await this.runMergeKernelCircuit(publicKernelOutput, enqueuedCallResult.kernelOutput); - publicKernelOutput = output; - } - - return { - avmProvingRequest: avmProvingRequest!, - publicKernelOutput, - durationMs: phaseTimer.ms(), - gasUsed: allocatedGas.sub(availableGas), - returnValues, - reverted, - revertReason, - }; - } - - private getAllocatedGasForPhase(phase: TxExecutionPhase, tx: Tx, phaseGasUsed: PhaseGasUsed) { - const gasSettings = tx.data.constants.txContext.gasSettings; - if (phase === TxExecutionPhase.TEARDOWN) { - return gasSettings.teardownGasLimits; - } else { - return gasSettings.gasLimits - .sub(tx.data.gasUsed) - .sub(phaseGasUsed[TxExecutionPhase.SETUP]) - .sub(phaseGasUsed[TxExecutionPhase.APP_LOGIC]); - } - } - - private getTransactionFee(tx: Tx, phaseGasUsed: PhaseGasUsed): Fr { - const gasFees = this.globalVariables.gasFees; - const txFee = tx.data.gasUsed // This should've included teardown gas limits. - .add(phaseGasUsed[TxExecutionPhase.SETUP]) - .add(phaseGasUsed[TxExecutionPhase.APP_LOGIC]) - .computeFee(gasFees); - - this.log.debug(`Computed tx fee`, { txFee, gasUsed: inspect(phaseGasUsed), gasFees: inspect(gasFees) }); - - return txFee; - } - - private getActualGasUsed(tx: Tx, phaseGasUsed: PhaseGasUsed) { - const requireTeardown = tx.data.hasTeardownPublicCallRequest(); - const teardownGasLimits = tx.data.constants.txContext.gasSettings.teardownGasLimits; - const privateGasUsed = tx.data.gasUsed.sub(requireTeardown ? teardownGasLimits : Gas.empty()); - const publicGasUsed = Object.values(phaseGasUsed).reduce((accum, gasUsed) => accum.add(gasUsed), Gas.empty()); - return privateGasUsed.add(publicGasUsed); - } - - private async runMergeKernelCircuit( - previousOutput: PublicKernelCircuitPublicInputs, - enqueuedCallData: VMCircuitPublicInputs, - ): Promise { - const previousKernel = this.getPreviousKernelData(previousOutput); - - // The proof is not used in simulation. - const vmProof = makeEmptyProof(); - const callData = new EnqueuedCallData(enqueuedCallData, vmProof); - - const inputs = new PublicKernelCircuitPrivateInputs(previousKernel, callData); - - return await this.publicKernelSimulator.publicKernelCircuitMerge(inputs); - } - - private getPreviousKernelData(previousOutput: PublicKernelCircuitPublicInputs): PublicKernelData { - // The proof is not used in simulation. - const proof = makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH); - - const vk = VerificationKeyData.makeFakeHonk(); - const vkIndex = 0; - const siblingPath = getVKSiblingPath(vkIndex); - - return new PublicKernelData(previousOutput, proof, vk, vkIndex, siblingPath); - } - - // Temporary hack to create PublicKernelCircuitPublicInputs from PrivateKernelTailCircuitPublicInputs. - private getPublicKernelCircuitPublicInputs(data: PrivateKernelTailCircuitPublicInputs) { - const constants = CombinedConstantData.combine(data.constants, this.globalVariables); - - const validationRequest = PublicValidationRequests.empty(); - validationRequest.forRollup = data.rollupValidationRequests; - - const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) => { - const to = PublicAccumulatedData.empty(); - to.noteHashes.forEach((_, i) => (to.noteHashes[i].noteHash.value = from.noteHashes[i])); - to.nullifiers.forEach((_, i) => (to.nullifiers[i].value = from.nullifiers[i])); - to.l2ToL1Msgs.forEach((_, i) => (to.l2ToL1Msgs[i] = from.l2ToL1Msgs[i])); - to.noteEncryptedLogsHashes.forEach((_, i) => (to.noteEncryptedLogsHashes[i] = from.noteEncryptedLogsHashes[i])); - to.encryptedLogsHashes.forEach((_, i) => (to.encryptedLogsHashes[i] = from.encryptedLogsHashes[i])); - to.unencryptedLogsHashes.forEach((_, i) => (to.unencryptedLogsHashes[i] = from.unencryptedLogsHashes[i])); - to.publicCallStack.forEach((_, i) => (to.publicCallStack[i] = from.publicCallRequests[i])); - return to; - }; - - return new PublicKernelCircuitPublicInputs( - constants, - validationRequest, - convertAccumulatedData(data.forPublic!.nonRevertibleAccumulatedData), - convertAccumulatedData(data.forPublic!.revertibleAccumulatedData), - 0, - data.forPublic!.publicTeardownCallRequest, - data.feePayer, - RevertCode.OK, - ); - } - - // Temporary hack to create the AvmCircuitPublicInputs from public tail's public inputs. - private generateAvmCircuitPublicInputs(tx: Tx, tailOutput: KernelCircuitPublicInputs, transactionFee: Fr) { - const startTreeSnapshots = new TreeSnapshots( - tailOutput.constants.historicalHeader.state.l1ToL2MessageTree, - tailOutput.startState.noteHashTree, - tailOutput.startState.nullifierTree, - tailOutput.startState.publicDataTree, - ); - - const getArrayLengths = (from: PrivateToPublicAccumulatedData) => - new PrivateToAvmAccumulatedDataArrayLengths( - countAccumulatedItems(from.noteHashes), - countAccumulatedItems(from.nullifiers), - countAccumulatedItems(from.l2ToL1Msgs), - ); - - const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) => - new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs); - - const convertAvmAccumulatedData = (from: CombinedAccumulatedData) => - new AvmAccumulatedData( - from.noteHashes, - from.nullifiers, - from.l2ToL1Msgs, - from.unencryptedLogsHashes, - from.publicDataWrites, - ); - - // This is wrong. But this is not used or checked in the rollup at the moment. - // Should fetch the updated roots from db. - const endTreeSnapshots = startTreeSnapshots; - - return new AvmCircuitPublicInputs( - tailOutput.constants.globalVariables, - startTreeSnapshots, - tx.data.gasUsed, - tx.data.constants.txContext.gasSettings, - tx.data.forPublic!.nonRevertibleAccumulatedData.publicCallRequests, - tx.data.forPublic!.revertibleAccumulatedData.publicCallRequests, - tx.data.forPublic!.publicTeardownCallRequest, - getArrayLengths(tx.data.forPublic!.nonRevertibleAccumulatedData), - getArrayLengths(tx.data.forPublic!.revertibleAccumulatedData), - convertAccumulatedData(tx.data.forPublic!.nonRevertibleAccumulatedData), - convertAccumulatedData(tx.data.forPublic!.revertibleAccumulatedData), - endTreeSnapshots, - convertAvmAccumulatedData(tailOutput.end), - transactionFee, - !tailOutput.revertCode.equals(RevertCode.OK), - ); - } -} diff --git a/yarn-project/simulator/src/public/index.ts b/yarn-project/simulator/src/public/index.ts index 1145e23e7b0b..dddb427855fa 100644 --- a/yarn-project/simulator/src/public/index.ts +++ b/yarn-project/simulator/src/public/index.ts @@ -1,6 +1,6 @@ export * from './db_interfaces.js'; export { EnqueuedCallSimulator } from './enqueued_call_simulator.js'; -export * from './enqueued_calls_processor.js'; +export * from './public_tx_processor.js'; export { type EnqueuedPublicCallExecutionResult as PublicExecutionResult, type PublicFunctionCallResult, @@ -15,3 +15,4 @@ export { PublicProcessor, PublicProcessorFactory } from './public_processor.js'; export { PublicSideEffectTrace } from './side_effect_trace.js'; export { PublicEnqueuedCallSideEffectTrace } from './enqueued_call_side_effect_trace.js'; export { DualSideEffectTrace } from './dual_side_effect_trace.js'; +export { getExecutionRequestsByPhase } from './utils.js'; diff --git a/yarn-project/simulator/src/public/public_db_sources.ts b/yarn-project/simulator/src/public/public_db_sources.ts index 553a483b4c95..ce9b66b0da60 100644 --- a/yarn-project/simulator/src/public/public_db_sources.ts +++ b/yarn-project/simulator/src/public/public_db_sources.ts @@ -49,12 +49,14 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB { */ public addNewContracts(tx: Tx): Promise { // Extract contract class and instance data from logs and add to cache for this block - const logs = tx.unencryptedLogs.unrollLogs(); + const logs = tx.contractClassLogs.unrollLogs(); ContractClassRegisteredEvent.fromLogs(logs, ProtocolContractAddress.ContractClassRegisterer).forEach(e => { this.log.debug(`Adding class ${e.contractClassId.toString()} to public execution contract cache`); this.classCache.set(e.contractClassId.toString(), e.toContractClassPublic()); }); - ContractInstanceDeployedEvent.fromLogs(logs).forEach(e => { + // We store the contract instance deployed event log in enc logs, contract_instance_deployer_contract/src/main.nr + const encLogs = tx.encryptedLogs.unrollLogs(); + ContractInstanceDeployedEvent.fromLogs(encLogs).forEach(e => { this.log.debug( `Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to public execution contract cache`, ); @@ -72,11 +74,13 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB { // TODO(@spalladino): Can this inadvertently delete a valid contract added by another tx? // Let's say we have two txs adding the same contract on the same block. If the 2nd one reverts, // wouldn't that accidentally remove the contract added on the first one? - const logs = tx.unencryptedLogs.unrollLogs(); + const logs = tx.contractClassLogs.unrollLogs(); ContractClassRegisteredEvent.fromLogs(logs, ProtocolContractAddress.ContractClassRegisterer).forEach(e => this.classCache.delete(e.contractClassId.toString()), ); - ContractInstanceDeployedEvent.fromLogs(logs).forEach(e => this.instanceCache.delete(e.address.toString())); + // We store the contract instance deployed event log in enc logs, contract_instance_deployer_contract/src/main.nr + const encLogs = tx.encryptedLogs.unrollLogs(); + ContractInstanceDeployedEvent.fromLogs(encLogs).forEach(e => this.instanceCache.delete(e.address.toString())); return Promise.resolve(); } @@ -131,6 +135,10 @@ export class WorldStateDB extends ContractsDataSourcePublicDB implements PublicS super(dataSource); } + public getMerkleInterface(): MerkleTreeWriteOperations { + return this.db; + } + /** * Reads a value from public storage, returning zero if none. * @param contract - Owner of the storage. diff --git a/yarn-project/simulator/src/public/public_processor.test.ts b/yarn-project/simulator/src/public/public_processor.test.ts index b15932abf088..87b17cfe4fd8 100644 --- a/yarn-project/simulator/src/public/public_processor.test.ts +++ b/yarn-project/simulator/src/public/public_processor.test.ts @@ -26,19 +26,19 @@ import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { type MockProxy, mock } from 'jest-mock-extended'; -import { type EnqueuedCallsProcessor, type TxPublicCallsResult } from './enqueued_calls_processor.js'; import { computeFeePayerBalanceLeafSlot } from './fee_payment.js'; import { type WorldStateDB } from './public_db_sources.js'; import { PublicProcessor } from './public_processor.js'; +import { type PublicTxProcessor, type PublicTxResult } from './public_tx_processor.js'; describe('public_processor', () => { let db: MockProxy; let worldStateDB: MockProxy; - let enqueuedCallsProcessor: MockProxy; + let publicTxProcessor: MockProxy; let handler: MockProxy; let root: Buffer; - let mockedEnqueuedCallsResult: TxPublicCallsResult; + let mockedEnqueuedCallsResult: PublicTxResult; let mockedAvmOutput: AvmCircuitPublicInputs; let processor: PublicProcessor; @@ -55,7 +55,7 @@ describe('public_processor', () => { beforeEach(() => { db = mock(); worldStateDB = mock(); - enqueuedCallsProcessor = mock(); + publicTxProcessor = mock(); handler = mock(); root = Buffer.alloc(32, 5); @@ -79,7 +79,7 @@ describe('public_processor', () => { worldStateDB.storageRead.mockResolvedValue(Fr.ZERO); - enqueuedCallsProcessor.process.mockImplementation(() => { + publicTxProcessor.process.mockImplementation(() => { return Promise.resolve(mockedEnqueuedCallsResult); }); @@ -88,7 +88,7 @@ describe('public_processor', () => { globalVariables, Header.empty(), worldStateDB, - enqueuedCallsProcessor, + publicTxProcessor, new NoopTelemetryClient(), ); }); @@ -136,7 +136,7 @@ describe('public_processor', () => { }); it('returns failed txs without aborting entire operation', async function () { - enqueuedCallsProcessor.process.mockRejectedValue(new SimulationError(`Failed`, [])); + publicTxProcessor.process.mockRejectedValue(new SimulationError(`Failed`, [])); const tx = mockTxWithPublicCalls(); const [processed, failed] = await processor.process([tx], 1, handler); diff --git a/yarn-project/simulator/src/public/public_processor.ts b/yarn-project/simulator/src/public/public_processor.ts index f248c965e3a1..05eec306e384 100644 --- a/yarn-project/simulator/src/public/public_processor.ts +++ b/yarn-project/simulator/src/public/public_processor.ts @@ -32,13 +32,13 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client'; import { type SimulationProvider } from '../providers/index.js'; -import { EnqueuedCallsProcessor } from './enqueued_calls_processor.js'; import { PublicExecutor } from './executor.js'; import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from './fee_payment.js'; import { WorldStateDB } from './public_db_sources.js'; import { RealPublicKernelCircuitSimulator } from './public_kernel.js'; import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; import { PublicProcessorMetrics } from './public_processor_metrics.js'; +import { PublicTxProcessor } from './public_tx_processor.js'; /** * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source. @@ -91,7 +91,7 @@ export class PublicProcessor { protected globalVariables: GlobalVariables, protected historicalHeader: Header, protected worldStateDB: WorldStateDB, - protected enqueuedCallsProcessor: EnqueuedCallsProcessor, + protected enqueuedCallsProcessor: PublicTxProcessor, telemetryClient: TelemetryClient, private log = createDebugLogger('aztec:sequencer:public-processor'), ) { @@ -107,7 +107,7 @@ export class PublicProcessor { worldStateDB: WorldStateDB, telemetryClient: TelemetryClient, ) { - const enqueuedCallsProcessor = EnqueuedCallsProcessor.create( + const enqueuedCallsProcessor = PublicTxProcessor.create( db, publicExecutor, publicKernelSimulator, @@ -316,7 +316,7 @@ export class PublicProcessor { this.metrics.recordClassRegistration( ...ContractClassRegisteredEvent.fromLogs( - tx.unencryptedLogs.unrollLogs(), + tx.contractClassLogs.unrollLogs(), ProtocolContractAddress.ContractClassRegisterer, ), ); diff --git a/yarn-project/simulator/src/public/public_tx_context.ts b/yarn-project/simulator/src/public/public_tx_context.ts new file mode 100644 index 000000000000..a3be696a019c --- /dev/null +++ b/yarn-project/simulator/src/public/public_tx_context.ts @@ -0,0 +1,269 @@ +import { + type AvmProvingRequest, + type MerkleTreeReadOperations, + type PublicExecutionRequest, + type SimulationError, + type Tx, + TxExecutionPhase, +} from '@aztec/circuit-types'; +import { + CombinedConstantData, + Fr, + Gas, + type GasSettings, + type GlobalVariables, + PublicAccumulatedDataArrayLengths, + type PublicCallRequest, + type PublicKernelCircuitPublicInputs, + PublicValidationRequestArrayLengths, + RevertCode, + type StateReference, +} from '@aztec/circuits.js'; + +import { assert } from 'console'; + +import { AvmPersistableStateManager } from '../avm/index.js'; +import { DualSideEffectTrace } from './dual_side_effect_trace.js'; +import { PublicEnqueuedCallSideEffectTrace } from './enqueued_call_side_effect_trace.js'; +import { type WorldStateDB } from './public_db_sources.js'; +import { PublicSideEffectTrace } from './side_effect_trace.js'; +import { getCallRequestsByPhase, getExecutionRequestsByPhase, getPublicKernelCircuitPublicInputs } from './utils.js'; + +class PhaseStateManager { + private currentlyActiveStateManager: AvmPersistableStateManager | undefined; + + constructor(private readonly txStateManager: AvmPersistableStateManager) {} + + fork() { + assert(!this.currentlyActiveStateManager, 'Cannot fork when already forked'); + this.currentlyActiveStateManager = this.txStateManager.fork(); + } + + getActiveStateManager() { + return this.currentlyActiveStateManager || this.txStateManager; + } + + isForked() { + return !!this.currentlyActiveStateManager; + } + + mergeForkedState() { + assert(this.currentlyActiveStateManager, 'No forked state to merge'); + this.txStateManager.mergeForkedState(this.currentlyActiveStateManager!); + // Drop the forked state manager now that it is merged + this.currentlyActiveStateManager = undefined; + } + + discardForkedState() { + assert(this.currentlyActiveStateManager, 'No forked state to discard'); + this.txStateManager.rejectForkedState(this.currentlyActiveStateManager!); + // Drop the forked state manager. We don't want it! + this.currentlyActiveStateManager = undefined; + } +} + +export class PublicTxContext { + private currentPhase: TxExecutionPhase = TxExecutionPhase.SETUP; + + /* Gas used including private, teardown gas _limit_, setup and app logic */ + private gasUsed: Gas; + /* Gas actually used during teardown (different from limit) */ + public teardownGasUsed: Gas = Gas.empty(); + + public revertCode: RevertCode = RevertCode.OK; + public revertReason: SimulationError | undefined; + + public avmProvingRequest: AvmProvingRequest | undefined; // tmp hack + + constructor( + public readonly state: PhaseStateManager, + public readonly tx: Tx, // tmp hack + public readonly globalVariables: GlobalVariables, + public readonly constants: CombinedConstantData, // tmp hack + public readonly startStateReference: StateReference, + startGasUsed: Gas, + private readonly gasSettings: GasSettings, + private readonly setupCallRequests: PublicCallRequest[], + private readonly appLogicCallRequests: PublicCallRequest[], + private readonly teardownCallRequests: PublicCallRequest[], + private readonly setupExecutionRequests: PublicExecutionRequest[], + private readonly appLogicExecutionRequests: PublicExecutionRequest[], + private readonly teardownExecutionRequests: PublicExecutionRequest[], + public latestPublicKernelOutput: PublicKernelCircuitPublicInputs, + ) { + this.gasUsed = startGasUsed; + } + + public static async create( + db: MerkleTreeReadOperations, + worldStateDB: WorldStateDB, + tx: Tx, + globalVariables: GlobalVariables, + ) { + const privateKernelOutput = tx.data; + const latestPublicKernelOutput = getPublicKernelCircuitPublicInputs(privateKernelOutput, globalVariables); + + const nonRevertibleNullifiersFromPrivate = latestPublicKernelOutput.endNonRevertibleData.nullifiers + .filter(n => !n.isEmpty()) + .map(n => n.value); + const _revertibleNullifiersFromPrivate = latestPublicKernelOutput.end.nullifiers + .filter(n => !n.isEmpty()) + .map(n => n.value); + + // During SETUP, non revertible side effects from private are our "previous data" + const prevAccumulatedData = latestPublicKernelOutput.endNonRevertibleData; + const previousValidationRequestArrayLengths = PublicValidationRequestArrayLengths.new( + latestPublicKernelOutput.validationRequests, + ); + + const previousAccumulatedDataArrayLengths = PublicAccumulatedDataArrayLengths.new(prevAccumulatedData); + + const innerCallTrace = new PublicSideEffectTrace(); + const enqueuedCallTrace = new PublicEnqueuedCallSideEffectTrace( + /*startSideEffectCounter=*/ 0, + previousValidationRequestArrayLengths, + previousAccumulatedDataArrayLengths, + ); + const trace = new DualSideEffectTrace(innerCallTrace, enqueuedCallTrace); + + // Transaction level state manager that will be forked for revertible phases. + const txStateManager = AvmPersistableStateManager.newWithPendingSiloedNullifiers( + worldStateDB, + trace, + nonRevertibleNullifiersFromPrivate, + ); + + return new PublicTxContext( + new PhaseStateManager(txStateManager), + tx, + globalVariables, + CombinedConstantData.combine(tx.data.constants, globalVariables), + await db.getStateReference(), + tx.data.gasUsed, + tx.data.constants.txContext.gasSettings, + getCallRequestsByPhase(tx, TxExecutionPhase.SETUP), + getCallRequestsByPhase(tx, TxExecutionPhase.APP_LOGIC), + getCallRequestsByPhase(tx, TxExecutionPhase.TEARDOWN), + getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP), + getExecutionRequestsByPhase(tx, TxExecutionPhase.APP_LOGIC), + getExecutionRequestsByPhase(tx, TxExecutionPhase.TEARDOWN), + latestPublicKernelOutput, + ); + } + + getCurrentPhase(): TxExecutionPhase { + return this.currentPhase; + } + + hasPhase(phase: TxExecutionPhase = this.currentPhase): boolean { + if (phase === TxExecutionPhase.SETUP) { + return this.setupCallRequests.length > 0; + } else if (phase === TxExecutionPhase.APP_LOGIC) { + return this.appLogicCallRequests.length > 0; + } else { + // phase === TxExecutionPhase.TEARDOWN + return this.teardownCallRequests.length > 0; + } + } + + progressToNextPhase() { + assert(this.currentPhase !== TxExecutionPhase.TEARDOWN, 'Cannot progress past teardown'); + if (this.currentPhase === TxExecutionPhase.SETUP) { + this.currentPhase = TxExecutionPhase.APP_LOGIC; + } else { + this.currentPhase = TxExecutionPhase.TEARDOWN; + } + } + + revert(revertReason: SimulationError | undefined = undefined, culprit = '') { + if (revertReason && !this.revertReason) { + // don't override revertReason + // (if app logic and teardown both revert, we want app logic's reason) + this.revertReason = revertReason; + } + if (this.currentPhase === TxExecutionPhase.SETUP) { + throw new Error( + `Setup phase reverted! The transaction will be thrown out. ${culprit} failed with reason: ${revertReason}`, + ); + } else if (this.currentPhase === TxExecutionPhase.APP_LOGIC) { + this.revertCode = RevertCode.APP_LOGIC_REVERTED; + } else if (this.currentPhase === TxExecutionPhase.TEARDOWN) { + if (this.revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) { + this.revertCode = RevertCode.BOTH_REVERTED; + } else { + this.revertCode = RevertCode.TEARDOWN_REVERTED; + } + } + } + + getCallRequestsForCurrentPhase(): PublicCallRequest[] { + switch (this.currentPhase) { + case TxExecutionPhase.SETUP: + return this.setupCallRequests; + case TxExecutionPhase.APP_LOGIC: + return this.appLogicCallRequests; + case TxExecutionPhase.TEARDOWN: + return this.teardownCallRequests; + } + } + + getExecutionRequestsForCurrentPhase(): PublicExecutionRequest[] { + switch (this.currentPhase) { + case TxExecutionPhase.SETUP: + return this.setupExecutionRequests; + case TxExecutionPhase.APP_LOGIC: + return this.appLogicExecutionRequests; + case TxExecutionPhase.TEARDOWN: + return this.teardownExecutionRequests; + } + } + + getGasLeftForCurrentPhase(): Gas { + if (this.currentPhase === TxExecutionPhase.TEARDOWN) { + return this.gasSettings.teardownGasLimits; + } else { + return this.gasSettings.gasLimits.sub(this.gasUsed); + } + } + + consumeGas(gas: Gas) { + if (this.currentPhase === TxExecutionPhase.TEARDOWN) { + // track teardown gas used separately + this.teardownGasUsed = this.teardownGasUsed.add(gas); + } else { + this.gasUsed = this.gasUsed.add(gas); + } + } + + /** + * Compute the gas used using the actual gas used during teardown instead + * of the teardown gas limit. + * Note that this.startGasUsed comes from private and private includes + * teardown gas limit in its output gasUsed. + */ + getActualGasUsed(): Gas { + assert(this.currentPhase === TxExecutionPhase.TEARDOWN, 'Can only compute actual gas used after app logic'); + const requireTeardown = this.teardownCallRequests.length > 0; + const teardownGasLimits = requireTeardown ? this.gasSettings.teardownGasLimits : Gas.empty(); + return this.gasUsed.sub(teardownGasLimits).add(this.teardownGasUsed); + } + + getGasUsedForFee(): Gas { + return this.gasUsed; + } + + getTransactionFeeAtCurrentPhase(): Fr { + if (this.currentPhase === TxExecutionPhase.TEARDOWN) { + //this.log.debug(`Computed tx fee`, { txFee, gasUsed: inspect(phaseGasUsed), gasFees: inspect(gasFees) }); + return this.gasUsed.computeFee(this.globalVariables.gasFees); + } else { + return Fr.zero(); + } + } + + getTransactionFee(): Fr { + assert(this.currentPhase === TxExecutionPhase.TEARDOWN, 'Transaction fee is only known during/after teardown'); + //this.log.debug(`Computed tx fee`, { txFee, gasUsed: inspect(phaseGasUsed), gasFees: inspect(gasFees) }); + return this.gasUsed.computeFee(this.globalVariables.gasFees); + } +} diff --git a/yarn-project/simulator/src/public/enqueued_calls_processor.test.ts b/yarn-project/simulator/src/public/public_tx_processor.test.ts similarity index 92% rename from yarn-project/simulator/src/public/enqueued_calls_processor.test.ts rename to yarn-project/simulator/src/public/public_tx_processor.test.ts index dfccb2e12167..a449adb461ef 100644 --- a/yarn-project/simulator/src/public/enqueued_calls_processor.test.ts +++ b/yarn-project/simulator/src/public/public_tx_processor.test.ts @@ -32,13 +32,13 @@ import { type MockProxy, mock } from 'jest-mock-extended'; import { type AvmPersistableStateManager } from '../avm/journal/journal.js'; import { PublicExecutionResultBuilder } from '../mocks/fixtures.js'; import { WASMSimulator } from '../providers/acvm_wasm.js'; -import { EnqueuedCallsProcessor } from './enqueued_calls_processor.js'; import { type PublicExecutor } from './executor.js'; import { type WorldStateDB } from './public_db_sources.js'; import { RealPublicKernelCircuitSimulator } from './public_kernel.js'; import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; +import { PublicTxProcessor } from './public_tx_processor.js'; -describe('enqueued_calls_processor', () => { +describe('public_tx_processor', () => { // Gas settings. const gasFees = GasFees.from({ feePerDaGas: new Fr(2), feePerL2Gas: new Fr(3) }); const gasLimits = Gas.from({ daGas: 100, l2Gas: 150 }); @@ -59,7 +59,7 @@ describe('enqueued_calls_processor', () => { let root: Buffer; let publicDataTree: AppendOnlyTree; - let processor: EnqueuedCallsProcessor; + let processor: PublicTxProcessor; const mockTxWithPublicCalls = ({ numberOfSetupCalls = 0, @@ -165,7 +165,7 @@ describe('enqueued_calls_processor', () => { publicKernel = new RealPublicKernelCircuitSimulator(new WASMSimulator()); - processor = EnqueuedCallsProcessor.create( + processor = PublicTxProcessor.create( db, publicExecutor, publicKernel, @@ -202,7 +202,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; + const expectedGasUsedForFee = expectedTotalGas; const expectedTxFee = expectedTotalGas.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // We keep all data. @@ -235,7 +237,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; + const expectedGasUsedForFee = expectedTotalGas; const expectedTxFee = expectedTotalGas.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // We keep all data. @@ -266,8 +270,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; - const expectedTotalGasForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); - const expectedTxFee = expectedTotalGasForFee.computeFee(gasFees); + const expectedGasUsedForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); + const expectedTxFee = expectedGasUsedForFee.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // We keep all data. @@ -313,8 +318,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; - const expectedTotalGasForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); - const expectedTxFee = expectedTotalGasForFee.computeFee(gasFees); + const expectedGasUsedForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); + const expectedTxFee = expectedGasUsedForFee.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // We keep all data. @@ -343,17 +349,17 @@ describe('enqueued_calls_processor', () => { // APP LOGIC async (stateManager: AvmPersistableStateManager) => { // mock storage writes on the state manager - stateManager.writeStorage(contractAddress, contractSlotA, fr(0x101)); - stateManager.writeStorage(contractAddress, contractSlotB, fr(0x151)); + await stateManager.writeStorage(contractAddress, contractSlotA, fr(0x101)); + await stateManager.writeStorage(contractAddress, contractSlotB, fr(0x151)); await stateManager.readStorage(contractAddress, contractSlotA); }, async (stateManager: AvmPersistableStateManager) => { // mock storage writes on the state manager - stateManager.writeStorage(contractAddress, contractSlotA, fr(0x103)); - stateManager.writeStorage(contractAddress, contractSlotC, fr(0x201)); + await stateManager.writeStorage(contractAddress, contractSlotA, fr(0x103)); + await stateManager.writeStorage(contractAddress, contractSlotC, fr(0x201)); await stateManager.readStorage(contractAddress, contractSlotA); - stateManager.writeStorage(contractAddress, contractSlotC, fr(0x102)); - stateManager.writeStorage(contractAddress, contractSlotC, fr(0x152)); + await stateManager.writeStorage(contractAddress, contractSlotC, fr(0x102)); + await stateManager.writeStorage(contractAddress, contractSlotC, fr(0x152)); await stateManager.readStorage(contractAddress, contractSlotA); }, ]); @@ -370,6 +376,7 @@ describe('enqueued_calls_processor', () => { // squashed // new PublicDataWrite(computePublicDataTreeLeafSlot(contractAddress, contractSlotA), fr(0x101)), new PublicDataWrite(computePublicDataTreeLeafSlot(contractAddress, contractSlotB), fr(0x151)), + new PublicDataWrite(computePublicDataTreeLeafSlot(contractAddress, contractSlotA), fr(0x103)), // squashed // new PublicDataWrite(computePublicDataTreeLeafSlot(contractAddress, contractSlotC), fr(0x201)), @@ -459,8 +466,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; - const expectedTotalGasForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); - const expectedTxFee = expectedTotalGasForFee.computeFee(gasFees); + const expectedGasUsedForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); + const expectedTxFee = expectedGasUsedForFee.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // we keep the non-revertible data. @@ -535,8 +543,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; // Should still charge the full teardownGasLimits for fee even though teardown reverted. - const expectedTotalGasForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); - const expectedTxFee = expectedTotalGasForFee.computeFee(gasFees); + const expectedGasUsedForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); + const expectedTxFee = expectedGasUsedForFee.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // We keep the non-revertible data. @@ -618,8 +627,9 @@ describe('enqueued_calls_processor', () => { const output = txResult.avmProvingRequest!.inputs.output; // Should still charge the full teardownGasLimits for fee even though teardown reverted. - const expectedTotalGasForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); - const expectedTxFee = expectedTotalGasForFee.computeFee(gasFees); + const expectedGasUsedForFee = expectedTotalGas.sub(expectedTeardownGasUsed).add(teardownGasLimits); + const expectedTxFee = expectedGasUsedForFee.computeFee(gasFees); + expect(output.endGasUsed).toEqual(expectedGasUsedForFee); expect(output.transactionFee).toEqual(expectedTxFee); // we keep the non-revertible data diff --git a/yarn-project/simulator/src/public/public_tx_processor.ts b/yarn-project/simulator/src/public/public_tx_processor.ts new file mode 100644 index 000000000000..fe73cdb195e5 --- /dev/null +++ b/yarn-project/simulator/src/public/public_tx_processor.ts @@ -0,0 +1,261 @@ +import { + type AvmProvingRequest, + type GasUsed, + type MerkleTreeReadOperations, + type NestedProcessReturnValues, + type SimulationError, + type Tx, + TxExecutionPhase, +} from '@aztec/circuit-types'; +import { type GlobalVariables, type Header, type RevertCode } from '@aztec/circuits.js'; +import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; +import { Timer } from '@aztec/foundation/timer'; + +import { EnqueuedCallSimulator } from './enqueued_call_simulator.js'; +import { type PublicExecutor } from './executor.js'; +import { type WorldStateDB } from './public_db_sources.js'; +import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; +import { PublicKernelTailSimulator } from './public_kernel_tail_simulator.js'; +import { PublicTxContext } from './public_tx_context.js'; +import { generateAvmCircuitPublicInputs, runMergeKernelCircuit } from './utils.js'; + +export type ProcessedPhase = { + phase: TxExecutionPhase; + durationMs: number; + returnValues: NestedProcessReturnValues[]; + reverted: boolean; + revertReason?: SimulationError; +}; + +export type PublicTxResult = { + avmProvingRequest: AvmProvingRequest; + /** Gas used during the execution of this tx */ + gasUsed: GasUsed; + revertCode: RevertCode; + /** Revert reason, if any */ + revertReason?: SimulationError; + processedPhases: ProcessedPhase[]; +}; + +export class PublicTxProcessor { + private log: DebugLogger; + + constructor( + private db: MerkleTreeReadOperations, + private publicKernelSimulator: PublicKernelCircuitSimulator, + private globalVariables: GlobalVariables, + private worldStateDB: WorldStateDB, + private enqueuedCallSimulator: EnqueuedCallSimulator, + private publicKernelTailSimulator: PublicKernelTailSimulator, + ) { + this.log = createDebugLogger(`aztec:sequencer`); + } + + static create( + db: MerkleTreeReadOperations, + publicExecutor: PublicExecutor, + publicKernelSimulator: PublicKernelCircuitSimulator, + globalVariables: GlobalVariables, + historicalHeader: Header, + worldStateDB: WorldStateDB, + realAvmProvingRequests: boolean = true, + ) { + const enqueuedCallSimulator = new EnqueuedCallSimulator( + db, + worldStateDB, + publicExecutor, + globalVariables, + historicalHeader, + realAvmProvingRequests, + ); + + const publicKernelTailSimulator = PublicKernelTailSimulator.create(db, publicKernelSimulator); + + return new PublicTxProcessor( + db, + publicKernelSimulator, + globalVariables, + worldStateDB, + enqueuedCallSimulator, + publicKernelTailSimulator, + ); + } + + async process(tx: Tx): Promise { + this.log.verbose(`Processing tx ${tx.getTxHash()}`); + + const context = await PublicTxContext.create(this.db, this.worldStateDB, tx, this.globalVariables); + + const setupResult = await this.processSetupPhase(context); + const appLogicResult = await this.processAppLogicPhase(context); + const teardownResult = await this.processTeardownPhase(context); + + const processedPhases = [setupResult, appLogicResult, teardownResult].filter( + result => result !== undefined, + ) as ProcessedPhase[]; + + const _endStateReference = await this.db.getStateReference(); + const transactionFee = context.getTransactionFee(); + + const tailKernelOutput = await this.publicKernelTailSimulator.simulate(context.latestPublicKernelOutput); + + context.avmProvingRequest!.inputs.output = generateAvmCircuitPublicInputs( + tx, + tailKernelOutput, + context.getGasUsedForFee(), + transactionFee, + ); + + const gasUsed = { + totalGas: context.getActualGasUsed(), + teardownGas: context.teardownGasUsed, + }; + return { + avmProvingRequest: context.avmProvingRequest!, + gasUsed, + revertCode: context.revertCode, + revertReason: context.revertReason, + processedPhases: processedPhases, + }; + } + + private async processSetupPhase(context: PublicTxContext): Promise { + // Start in phase TxExecutionPhase.SETUP; + if (context.hasPhase()) { + return await this.processPhase(context); + } + } + + private async processAppLogicPhase(context: PublicTxContext): Promise { + context.progressToNextPhase(); // to app logic + if (context.hasPhase()) { + // Fork the state manager so that we can rollback state if app logic or teardown reverts. + // Don't need to fork for setup since it's non-revertible (if setup fails, transaction is thrown out). + context.state.fork(); + + const result = await this.processPhase(context); + + if (result.reverted) { + // Drop the currently active forked state manager and rollback to end of setup. + // Fork again for teardown so that if teardown fails we can again rollback to end of setup. + context.state.discardForkedState(); + } else { + if (!context.hasPhase(TxExecutionPhase.TEARDOWN)) { + // Nothing to do after this (no teardown), so merge state in now instead of letting teardown handle it. + context.state.mergeForkedState(); + } + } + + return result; + } + } + + private async processTeardownPhase(context: PublicTxContext): Promise { + context.progressToNextPhase(); // to teardown + if (context.hasPhase()) { + if (!context.state.isForked()) { + // if state isn't forked (app logic was empty or reverted), fork now + // so we can rollback to the end of setup on teardown revert + context.state.fork(); + } + + const result = await this.processPhase(context); + + if (result.reverted) { + // Drop the currently active forked state manager and rollback to end of setup. + context.state.discardForkedState(); + } else { + context.state.mergeForkedState(); + } + + return result; + } + } + + private async processPhase(context: PublicTxContext): Promise { + const tx = context.tx; + const callRequests = context.getCallRequestsForCurrentPhase(); + const executionRequests = context.getExecutionRequestsForCurrentPhase(); + const txStateManager = context.state.getActiveStateManager(); + + this.log.debug( + `Beginning processing in phase ${TxExecutionPhase[context.getCurrentPhase()]} for tx ${tx.getTxHash()}`, + ); + + const returnValues: NestedProcessReturnValues[] = []; + let reverted = false; + let revertReason: SimulationError | undefined; + const phaseTimer = new Timer(); + for (let i = callRequests.length - 1; i >= 0; i--) { + const callRequest = callRequests[i]; + const executionRequest = executionRequests[i]; + + // add new contracts to the contracts db so that their functions may be found and called + // TODO(#4073): This is catching only private deployments, when we add public ones, we'll + // have to capture contracts emitted in that phase as well. + // TODO(@spalladino): Should we allow emitting contracts in the fee preparation phase? + // TODO(#6464): Should we allow emitting contracts in the private setup phase? + // if so, this should only add contracts that were deployed during private app logic. + // FIXME: we shouldn't need to directly modify worldStateDb here! + await this.worldStateDB.addNewContracts(tx); + + // each enqueued call starts with an incremented side effect counter + // FIXME: should be able to stop forking here and just trace the enqueued call (for hinting) + // and proceed with the same state manager for the entire phase + const enqueuedCallStateManager = txStateManager.fork(/*incrementSideEffectCounter=*/ true); + const enqueuedCallResult = await this.enqueuedCallSimulator.simulate( + callRequest, + executionRequest, + context.constants, + /*availableGas=*/ context.getGasLeftForCurrentPhase(), + /*transactionFee=*/ context.getTransactionFeeAtCurrentPhase(), + enqueuedCallStateManager, + ); + + txStateManager.traceEnqueuedCall(callRequest, executionRequest.args, enqueuedCallResult.reverted!); + + context.consumeGas(enqueuedCallResult.gasUsed); + returnValues.push(enqueuedCallResult.returnValues); + // Propagate only one avmProvingRequest of a function call for now, so that we know it's still provable. + // Eventually this will be the proof for the entire public portion of the transaction. + context.avmProvingRequest = enqueuedCallResult.avmProvingRequest; + if (enqueuedCallResult.reverted) { + reverted = true; + const culprit = `${executionRequest.callContext.contractAddress}:${executionRequest.callContext.functionSelector}`; + revertReason = enqueuedCallResult.revertReason; + context.revert(enqueuedCallResult.revertReason, culprit); // throws if in setup (non-revertible) phase + + // TODO(#6464): Should we allow emitting contracts in the private setup phase? + // if so, this is removing contracts deployed in private setup + // You can't submit contracts in public, so this is only relevant for private-created side effects + // FIXME: we shouldn't need to directly modify worldStateDb here! + await this.worldStateDB.removeNewContracts(tx); + // FIXME: we shouldn't be modifying the transaction here! + tx.filterRevertedLogs(context.latestPublicKernelOutput); + // Enqueeud call reverted. Discard state updates and accumulated side effects, but keep hints traced for the circuit. + txStateManager.rejectForkedState(enqueuedCallStateManager); + break; + } else { + // FIXME: we shouldn't be modifying the transaction here! + tx.unencryptedLogs.addFunctionLogs([enqueuedCallResult.newUnencryptedLogs]); + // Enqueued call succeeded! Merge in any state updates made in the forked state manager. + txStateManager.mergeForkedState(enqueuedCallStateManager); + } + + context.latestPublicKernelOutput = await runMergeKernelCircuit( + context.latestPublicKernelOutput, + enqueuedCallResult.kernelOutput, + this.publicKernelSimulator, + ); + + } + + return { + phase: context.getCurrentPhase(), + durationMs: phaseTimer.ms(), + returnValues, + reverted: reverted, + revertReason, + }; + } +} diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index 55f152079018..2a57e7df088a 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -14,6 +14,8 @@ import { MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + NullifierLeafPreimage, + PublicDataTreeLeafPreimage, SerializableContractInstance, } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; @@ -68,9 +70,8 @@ describe('Side Effect Trace', () => { }; it('Should trace storage reads', () => { - const exists = true; - const cached = false; - trace.tracePublicStorageRead(address, slot, value, exists, cached); + const leafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + trace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -88,7 +89,10 @@ describe('Side Effect Trace', () => { }); it('Should trace storage writes', () => { - trace.tracePublicStorageWrite(address, slot, value); + const lowLeafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + const newLeafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + + trace.tracePublicStorageWrite(address, slot, value, lowLeafPreimage, Fr.ZERO, [], newLeafPreimage, []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -104,7 +108,7 @@ describe('Side Effect Trace', () => { it('Should trace note hash checks', () => { const exists = true; - trace.traceNoteHashCheck(address, utxo, leafIndex, exists); + trace.traceNoteHashCheck(address, utxo, leafIndex, exists, []); const pxResult = toPxResult(trace); expect(pxResult.noteHashReadRequests).toEqual([ @@ -120,7 +124,7 @@ describe('Side Effect Trace', () => { }); it('Should trace note hashes', () => { - trace.traceNewNoteHash(address, utxo); + trace.traceNewNoteHash(address, utxo, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -135,8 +139,8 @@ describe('Side Effect Trace', () => { it('Should trace nullifier checks', () => { const exists = true; - const isPending = false; - trace.traceNullifierCheck(address, utxo, leafIndex, exists, isPending); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNullifierCheck(address, utxo, exists, lowLeafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -152,8 +156,8 @@ describe('Side Effect Trace', () => { it('Should trace non-existent nullifier checks', () => { const exists = false; - const isPending = false; - trace.traceNullifierCheck(address, utxo, leafIndex, exists, isPending); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNullifierCheck(address, utxo, exists, lowLeafPreimage, Fr.ZERO, []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -168,7 +172,8 @@ describe('Side Effect Trace', () => { }); it('Should trace nullifiers', () => { - trace.traceNewNullifier(address, utxo); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + trace.traceNewNullifier(address, utxo, lowLeafPreimage, Fr.ZERO, [], []); expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); @@ -183,7 +188,7 @@ describe('Side Effect Trace', () => { it('Should trace L1ToL2 Message checks', () => { const exists = true; - trace.traceL1ToL2MessageCheck(address, utxo, leafIndex, exists); + trace.traceL1ToL2MessageCheck(address, utxo, leafIndex, exists, []); const pxResult = toPxResult(trace); expect(pxResult.l1ToL2MsgReadRequests).toEqual([ @@ -245,82 +250,102 @@ describe('Side Effect Trace', () => { describe('Maximum accesses', () => { it('Should enforce maximum number of public storage reads', () => { for (let i = 0; i < MAX_PUBLIC_DATA_READS_PER_TX; i++) { - trace.tracePublicStorageRead(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(i), new Fr(i), Fr.ZERO, 0n); + trace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); } - expect(() => - trace.tracePublicStorageRead(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true), - ).toThrow(SideEffectLimitReachedError); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(42), new Fr(42), Fr.ZERO, 0n); + expect(() => trace.tracePublicStorageRead(address, new Fr(42), value, leafPreimage, Fr.ZERO, [])).toThrow( + SideEffectLimitReachedError, + ); }); it('Should enforce maximum number of public storage writes', () => { for (let i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { - trace.tracePublicStorageWrite(AztecAddress.fromNumber(i), new Fr(i), new Fr(i)); + const lowLeafPreimage = new PublicDataTreeLeafPreimage(new Fr(i), new Fr(i), Fr.ZERO, 0n); + const newLeafPreimage = new PublicDataTreeLeafPreimage(new Fr(i + 1), new Fr(i + 1), Fr.ZERO, 0n); + trace.tracePublicStorageWrite(address, slot, value, lowLeafPreimage, Fr.ZERO, [], newLeafPreimage, []); } - expect(() => trace.tracePublicStorageWrite(AztecAddress.fromNumber(42), new Fr(42), new Fr(42))).toThrow( - SideEffectLimitReachedError, - ); + const leafPreimage = new PublicDataTreeLeafPreimage(new Fr(42), new Fr(42), Fr.ZERO, 0n); + expect(() => + trace.tracePublicStorageWrite( + AztecAddress.fromNumber(42), + new Fr(42), + value, + leafPreimage, + Fr.ZERO, + [], + leafPreimage, + [], + ), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of note hash checks', () => { for (let i = 0; i < MAX_NOTE_HASH_READ_REQUESTS_PER_TX; i++) { - trace.traceNoteHashCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true); + trace.traceNoteHashCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, []); } - expect(() => trace.traceNoteHashCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true)).toThrow( + expect(() => trace.traceNoteHashCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, [])).toThrow( SideEffectLimitReachedError, ); }); it('Should enforce maximum number of new note hashes', () => { for (let i = 0; i < MAX_NOTE_HASHES_PER_TX; i++) { - trace.traceNewNoteHash(AztecAddress.fromNumber(i), new Fr(i)); + trace.traceNewNoteHash(AztecAddress.fromNumber(i), new Fr(i), Fr.ZERO, []); } - expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42))).toThrow( + expect(() => trace.traceNewNoteHash(AztecAddress.fromNumber(42), new Fr(42), Fr.ZERO, [])).toThrow( SideEffectLimitReachedError, ); }); it('Should enforce maximum number of nullifier checks', () => { for (let i = 0; i < MAX_NULLIFIER_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true)).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), true, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); // NOTE: also cannot do a non-existent check once existent checks have filled up - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false, true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), false, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of nullifier non-existent checks', () => { for (let i = 0; i < MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), false, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), false, true)).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), false, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); // NOTE: also cannot do a existent check once non-existent checks have filled up - expect(() => trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceNullifierCheck(AztecAddress.fromNumber(42), new Fr(42), true, lowLeafPreimage, Fr.ZERO, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of new nullifiers', () => { for (let i = 0; i < MAX_NULLIFIERS_PER_TX; i++) { - trace.traceNewNullifier(AztecAddress.fromNumber(i), new Fr(i)); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i + 1), Fr.ZERO, 0n); + trace.traceNewNullifier(AztecAddress.fromNumber(i), new Fr(i), lowLeafPreimage, Fr.ZERO, [], []); } - expect(() => trace.traceNewNullifier(AztecAddress.fromNumber(42), new Fr(42))).toThrow( - SideEffectLimitReachedError, - ); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(41), Fr.ZERO, 0n); + expect(() => + trace.traceNewNullifier(AztecAddress.fromNumber(42), new Fr(42), lowLeafPreimage, Fr.ZERO, [], []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of L1 to L2 message checks', () => { for (let i = 0; i < MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX; i++) { - trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true); + trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, []); } - expect(() => trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true)).toThrow( - SideEffectLimitReachedError, - ); + expect(() => + trace.traceL1ToL2MessageCheck(AztecAddress.fromNumber(42), new Fr(42), new Fr(42), true, []), + ).toThrow(SideEffectLimitReachedError); }); it('Should enforce maximum number of new l2 to l1 messages', () => { @@ -343,7 +368,8 @@ describe('Side Effect Trace', () => { it('Should enforce maximum number of nullifier checks for GETCONTRACTINSTANCE', () => { for (let i = 0; i < MAX_NULLIFIER_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), true, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } expect(() => trace.traceGetContractInstance(address, /*exists=*/ true, contractInstance)).toThrow( SideEffectLimitReachedError, @@ -356,7 +382,8 @@ describe('Side Effect Trace', () => { it('Should enforce maximum number of nullifier non-existent checks for GETCONTRACTINSTANCE', () => { for (let i = 0; i < MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX; i++) { - trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i), new Fr(i), false, true); + const lowLeafPreimage = new NullifierLeafPreimage(new Fr(i), Fr.ZERO, 0n); + trace.traceNullifierCheck(AztecAddress.fromNumber(i), new Fr(i + 1), true, lowLeafPreimage, Fr.ZERO, []); } expect(() => trace.traceGetContractInstance(address, /*exists=*/ false, contractInstance)).toThrow( SideEffectLimitReachedError, @@ -370,26 +397,26 @@ describe('Side Effect Trace', () => { it('Should trace nested calls', () => { const existsDefault = true; - const cached = false; - const isPending = false; const nestedTrace = new PublicSideEffectTrace(startCounter); let testCounter = startCounter; - nestedTrace.tracePublicStorageRead(address, slot, value, existsDefault, cached); + const leafPreimage = new PublicDataTreeLeafPreimage(slot, value, Fr.ZERO, 0n); + const lowLeafPreimage = new NullifierLeafPreimage(utxo, Fr.ZERO, 0n); + nestedTrace.tracePublicStorageRead(address, slot, value, leafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.tracePublicStorageWrite(address, slot, value); + nestedTrace.tracePublicStorageWrite(address, slot, value, leafPreimage, Fr.ZERO, [], leafPreimage, []); testCounter++; - nestedTrace.traceNoteHashCheck(address, utxo, leafIndex, existsDefault); + nestedTrace.traceNoteHashCheck(address, utxo, leafIndex, existsDefault, []); // counter does not increment for note hash checks - nestedTrace.traceNewNoteHash(address, utxo); + nestedTrace.traceNewNoteHash(address, utxo, Fr.ZERO, []); testCounter++; - nestedTrace.traceNullifierCheck(address, utxo, leafIndex, /*exists=*/ true, isPending); + nestedTrace.traceNullifierCheck(address, utxo, true, lowLeafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.traceNullifierCheck(address, utxo, leafIndex, /*exists=*/ false, isPending); + nestedTrace.traceNullifierCheck(address, utxo, true, lowLeafPreimage, Fr.ZERO, []); testCounter++; - nestedTrace.traceNewNullifier(address, utxo); + nestedTrace.traceNewNullifier(address, utxo, lowLeafPreimage, Fr.ZERO, [], []); testCounter++; - nestedTrace.traceL1ToL2MessageCheck(address, utxo, leafIndex, existsDefault); + nestedTrace.traceL1ToL2MessageCheck(address, utxo, leafIndex, existsDefault, []); // counter does not increment for l1tol2 message checks nestedTrace.traceNewL2ToL1Message(address, recipient, content); testCounter++; diff --git a/yarn-project/simulator/src/public/side_effect_trace.ts b/yarn-project/simulator/src/public/side_effect_trace.ts index 4a1c2e15da39..efe7a3afa6b9 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.ts @@ -1,10 +1,15 @@ import { PublicExecutionRequest, UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types'; import { + AvmAppendTreeHint, AvmContractBytecodeHints, AvmContractInstanceHint, AvmExecutionHints, AvmExternalCallHint, AvmKeyValueHint, + AvmNullifierReadTreeHint, + AvmNullifierWriteTreeHint, + AvmPublicDataReadTreeHint, + AvmPublicDataWriteTreeHint, type AztecAddress, CallContext, type CombinedConstantData, @@ -14,6 +19,7 @@ import { ContractStorageUpdateRequest, EthAddress, Gas, + L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, LogHash, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, @@ -26,9 +32,14 @@ import { MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + NOTE_HASH_TREE_HEIGHT, + NULLIFIER_TREE_HEIGHT, NoteHash, Nullifier, + NullifierLeafPreimage, + PUBLIC_DATA_TREE_HEIGHT, type PublicCallRequest, + PublicDataTreeLeafPreimage, type PublicInnerCallRequest, ReadRequest, SerializableContractInstance, @@ -38,6 +49,8 @@ import { import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; +import { assert } from 'console'; + import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js'; import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js'; import { createSimulationError } from '../common/errors.js'; @@ -51,6 +64,11 @@ import { type PublicSideEffectTraceInterface } from './side_effect_trace_interfa export type TracedContractInstance = { exists: boolean } & ContractInstanceWithAddress; +const emptyPublicDataPath = () => new Array(PUBLIC_DATA_TREE_HEIGHT).fill(Fr.zero()); +const emptyNoteHashPath = () => new Array(NOTE_HASH_TREE_HEIGHT).fill(Fr.zero()); +const emptyNullifierPath = () => new Array(NULLIFIER_TREE_HEIGHT).fill(Fr.zero()); +const emptyL1ToL2MessagePath = () => new Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.zero()); + export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { public log = createDebugLogger('aztec:public_side_effect_trace'); @@ -104,60 +122,107 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { contractAddress: AztecAddress, slot: Fr, value: Fr, - _exists: boolean, - _cached: boolean, + leafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + leafIndex: Fr = Fr.zero(), + path: Fr[] = emptyPublicDataPath(), ) { - // NOTE: exists and cached are unused for now but may be used for optimizations or kernel hints later + if (!leafIndex.equals(Fr.zero())) { + // if we have real merkle hint content, make sure the value matches the the provided preimage + assert(leafPreimage.value.equals(value), 'Value mismatch when tracing in public data write'); + } if (this.contractStorageReads.length >= MAX_PUBLIC_DATA_READS_PER_TX) { throw new SideEffectLimitReachedError('contract storage read', MAX_PUBLIC_DATA_READS_PER_TX); } + this.contractStorageReads.push(new ContractStorageRead(slot, value, this.sideEffectCounter, contractAddress)); this.avmCircuitHints.storageValues.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ value), ); + + // New hinting + this.avmCircuitHints.storageReadRequest.items.push(new AvmPublicDataReadTreeHint(leafPreimage, leafIndex, path)); + this.log.debug(`SLOAD cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`); this.incrementSideEffectCounter(); } - public tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, value: Fr) { + public tracePublicStorageWrite( + contractAddress: AztecAddress, + slot: Fr, + value: Fr, + lowLeafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyPublicDataPath(), + newLeafPreimage: PublicDataTreeLeafPreimage = PublicDataTreeLeafPreimage.empty(), + insertionPath: Fr[] = emptyPublicDataPath(), + ) { + if (!lowLeafIndex.equals(Fr.zero())) { + // if we have real merkle hint content, make sure the value matches the the provided preimage + assert(newLeafPreimage.value.equals(value), 'Value mismatch when tracing in public data read'); + } if (this.contractStorageUpdateRequests.length >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) { throw new SideEffectLimitReachedError('contract storage write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); } + this.contractStorageUpdateRequests.push( new ContractStorageUpdateRequest(slot, value, this.sideEffectCounter, contractAddress), ); + + // New hinting + const readHint = new AvmPublicDataReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath); + this.avmCircuitHints.storageUpdateRequest.items.push( + new AvmPublicDataWriteTreeHint(readHint, newLeafPreimage, insertionPath), + ); this.log.debug(`SSTORE cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`); this.incrementSideEffectCounter(); } // TODO(8287): _exists can be removed once we have the vm properly handling the equality check - public traceNoteHashCheck(_contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean) { + public traceNoteHashCheck( + _contractAddress: AztecAddress, + noteHash: Fr, + leafIndex: Fr, + exists: boolean, + path: Fr[] = emptyNoteHashPath(), + ) { // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call if (this.noteHashReadRequests.length >= MAX_NOTE_HASH_READ_REQUESTS_PER_TX) { throw new SideEffectLimitReachedError('note hash read request', MAX_NOTE_HASH_READ_REQUESTS_PER_TX); } + // Temp for backward compatibility this.noteHashReadRequests.push(new TreeLeafReadRequest(noteHash, leafIndex)); this.avmCircuitHints.noteHashExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(leafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); + // New Hinting + this.avmCircuitHints.noteHashReadRequest.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path)); // NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes) } - public traceNewNoteHash(_contractAddress: AztecAddress, noteHash: Fr) { + public traceNewNoteHash( + _contractAddress: AztecAddress, + noteHash: Fr, + leafIndex: Fr, + path: Fr[] = emptyNoteHashPath(), + ) { if (this.noteHashes.length >= MAX_NOTE_HASHES_PER_TX) { throw new SideEffectLimitReachedError('note hash', MAX_NOTE_HASHES_PER_TX); } this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter)); this.log.debug(`NEW_NOTE_HASH cnt: ${this.sideEffectCounter}`); + + // New Hinting + this.avmCircuitHints.noteHashWriteRequest.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path)); this.incrementSideEffectCounter(); } public traceNullifierCheck( _contractAddress: AztecAddress, nullifier: Fr, - _leafIndex: Fr, exists: boolean, - _isPending: boolean, + lowLeafPreimage: NullifierLeafPreimage = NullifierLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyNullifierPath(), ) { // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call // NOTE: isPending and leafIndex are unused for now but may be used for optimizations or kernel hints later @@ -173,22 +238,43 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.avmCircuitHints.nullifierExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), ); + + // New Hints + this.avmCircuitHints.nullifierReadRequest.items.push( + new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath), + ); this.log.debug(`NULLIFIER_EXISTS cnt: ${this.sideEffectCounter}`); this.incrementSideEffectCounter(); } - public traceNewNullifier(_contractAddress: AztecAddress, nullifier: Fr) { + public traceNewNullifier( + _contractAddress: AztecAddress, + nullifier: Fr, + lowLeafPreimage: NullifierLeafPreimage = NullifierLeafPreimage.empty(), + lowLeafIndex: Fr = Fr.zero(), + lowLeafPath: Fr[] = emptyNullifierPath(), + insertionPath: Fr[] = emptyNullifierPath(), + ) { // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call if (this.nullifiers.length >= MAX_NULLIFIERS_PER_TX) { throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX); } this.nullifiers.push(new Nullifier(nullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO)); + // New hinting + const lowLeafReadHint = new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath); + this.avmCircuitHints.nullifierWriteHints.items.push(new AvmNullifierWriteTreeHint(lowLeafReadHint, insertionPath)); this.log.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`); this.incrementSideEffectCounter(); } // TODO(8287): _exists can be removed once we have the vm properly handling the equality check - public traceL1ToL2MessageCheck(_contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) { + public traceL1ToL2MessageCheck( + _contractAddress: AztecAddress, + msgHash: Fr, + msgLeafIndex: Fr, + exists: boolean, + path: Fr[] = emptyL1ToL2MessagePath(), + ) { // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call if (this.l1ToL2MsgReadRequests.length >= MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX) { throw new SideEffectLimitReachedError('l1 to l2 message read request', MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX); @@ -197,6 +283,9 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.avmCircuitHints.l1ToL2MessageExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(msgLeafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); + + // New Hinting + this.avmCircuitHints.l1ToL2MessageReadRequest.items.push(new AvmAppendTreeHint(msgLeafIndex, msgHash, path)); // NOTE: counter does not increment for l1tol2 message checks (because it doesn't rely on pending messages) } @@ -250,6 +339,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { // This tracing function gets called everytime we start simulation/execution. // This happens both when starting a new top-level trace and the start of every nested trace // We use this to collect the AvmContractBytecodeHints + // We need to trace teh merkle tree as well here public traceGetBytecode( contractAddress: AztecAddress, exists: boolean, @@ -340,8 +430,6 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { } public traceEnqueuedCall( - /** The trace of the enqueued call. */ - _enqueuedCallTrace: this, /** The call request from private that enqueued this call. */ _publicCallRequest: PublicCallRequest, /** The call's calldata */ @@ -352,16 +440,11 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { throw new Error('Not implemented'); } - public traceExecutionPhase( - /** The trace of the enqueued call. */ - _appLogicTrace: this, - /** The call request from private that enqueued this call. */ - _publicCallRequests: PublicCallRequest[], - /** The call's calldata */ - _calldatas: Fr[][], - /** Did the any enqueued call in app logic revert? */ - _reverted: boolean, - ) { + public mergeSuccessfulForkedTrace(_nestedTrace: this) { + throw new Error('Not implemented'); + } + + public mergeRevertedForkedTrace(_nestedTrace: this) { throw new Error('Not implemented'); } diff --git a/yarn-project/simulator/src/public/side_effect_trace_interface.ts b/yarn-project/simulator/src/public/side_effect_trace_interface.ts index 9092c1834279..021791570710 100644 --- a/yarn-project/simulator/src/public/side_effect_trace_interface.ts +++ b/yarn-project/simulator/src/public/side_effect_trace_interface.ts @@ -3,7 +3,9 @@ import { type CombinedConstantData, type ContractClassIdPreimage, type Gas, + type NullifierLeafPreimage, type PublicCallRequest, + type PublicDataTreeLeafPreimage, type SerializableContractInstance, type VMCircuitPublicInputs, } from '@aztec/circuits.js'; @@ -18,19 +20,49 @@ export interface PublicSideEffectTraceInterface { fork(incrementSideEffectCounter?: boolean): PublicSideEffectTraceInterface; getCounter(): number; // all "trace*" functions can throw SideEffectLimitReachedError - tracePublicStorageRead(contractAddress: AztecAddress, slot: Fr, value: Fr, exists: boolean, cached: boolean): void; - tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, value: Fr): void; - traceNoteHashCheck(contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean): void; - traceNewNoteHash(contractAddress: AztecAddress, noteHash: Fr): void; + tracePublicStorageRead( + contractAddress: AztecAddress, + slot: Fr, + value: Fr, + leafPreimage?: PublicDataTreeLeafPreimage, + leafIndex?: Fr, + path?: Fr[], + ): void; + tracePublicStorageWrite( + contractAddress: AztecAddress, + slot: Fr, // This is the storage slot not the computed leaf slot + value: Fr, + lowLeafPreimage?: PublicDataTreeLeafPreimage, + lowLeafIndex?: Fr, + lowLeafPath?: Fr[], + newLeafPreimage?: PublicDataTreeLeafPreimage, + insertionPath?: Fr[], + ): void; + traceNoteHashCheck(contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, exists: boolean, path?: Fr[]): void; + traceNewNoteHash(contractAddress: AztecAddress, noteHash: Fr, leafIndex?: Fr, path?: Fr[]): void; traceNullifierCheck( contractAddress: AztecAddress, nullifier: Fr, - leafIndex: Fr, exists: boolean, - isPending: boolean, + lowLeafPreimage?: NullifierLeafPreimage, + lowLeafIndex?: Fr, + lowLeafPath?: Fr[], + ): void; + traceNewNullifier( + contractAddress: AztecAddress, + nullifier: Fr, + lowLeafPreimage?: NullifierLeafPreimage, + lowLeafIndex?: Fr, + lowLeafPath?: Fr[], + insertionPath?: Fr[], + ): void; + traceL1ToL2MessageCheck( + contractAddress: AztecAddress, + msgHash: Fr, + msgLeafIndex: Fr, + exists: boolean, + path?: Fr[], ): void; - traceNewNullifier(contractAddress: AztecAddress, nullifier: Fr): void; - traceL1ToL2MessageCheck(contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean): void; traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void; traceUnencryptedLog(contractAddress: AztecAddress, log: Fr[]): void; traceGetContractInstance( @@ -62,8 +94,6 @@ export interface PublicSideEffectTraceInterface { functionName: string, ): void; traceEnqueuedCall( - /** The trace of the enqueued call. */ - enqueuedCallTrace: this, /** The call request from private that enqueued this call. */ publicCallRequest: PublicCallRequest, /** The call's calldata */ @@ -71,16 +101,8 @@ export interface PublicSideEffectTraceInterface { /** Did the call revert? */ reverted: boolean, ): void; - traceExecutionPhase( - /** The trace of the enqueued call. */ - appLogicTrace: this, - /** The call request from private that enqueued this call. */ - publicCallRequests: PublicCallRequest[], - /** The call's calldata */ - calldatas: Fr[][], - /** Did the any enqueued call in app logic revert? */ - reverted: boolean, - ): void; + mergeSuccessfulForkedTrace(nestedTrace: PublicSideEffectTraceInterface): void; + mergeRevertedForkedTrace(nestedTrace: PublicSideEffectTraceInterface): void; toPublicEnqueuedCallExecutionResult( /** How much gas was left after this public execution. */ endGasLeft: Gas, diff --git a/yarn-project/simulator/src/public/utils.ts b/yarn-project/simulator/src/public/utils.ts new file mode 100644 index 000000000000..8d3f6093f758 --- /dev/null +++ b/yarn-project/simulator/src/public/utils.ts @@ -0,0 +1,182 @@ +import { type PublicExecutionRequest, type Tx, TxExecutionPhase } from '@aztec/circuit-types'; +import { + AvmAccumulatedData, + AvmCircuitPublicInputs, + type CombinedAccumulatedData, + CombinedConstantData, + EnqueuedCallData, + type Fr, + type Gas, + type GlobalVariables, + type KernelCircuitPublicInputs, + NESTED_RECURSIVE_PROOF_LENGTH, + type PrivateKernelTailCircuitPublicInputs, + PrivateToAvmAccumulatedData, + PrivateToAvmAccumulatedDataArrayLengths, + type PrivateToPublicAccumulatedData, + PublicAccumulatedData, + type PublicCallRequest, + PublicKernelCircuitPrivateInputs, + PublicKernelCircuitPublicInputs, + PublicKernelData, + PublicValidationRequests, + RevertCode, + TreeSnapshots, + type VMCircuitPublicInputs, + VerificationKeyData, + countAccumulatedItems, + makeEmptyProof, + makeEmptyRecursiveProof, +} from '@aztec/circuits.js'; +import { getVKSiblingPath } from '@aztec/noir-protocol-circuits-types'; + +import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js'; + +export function getExecutionRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicExecutionRequest[] { + switch (phase) { + case TxExecutionPhase.SETUP: + return tx.getNonRevertiblePublicExecutionRequests(); + case TxExecutionPhase.APP_LOGIC: + return tx.getRevertiblePublicExecutionRequests(); + case TxExecutionPhase.TEARDOWN: { + const request = tx.getPublicTeardownExecutionRequest(); + return request ? [request] : []; + } + default: + throw new Error(`Unknown phase: ${phase}`); + } +} + +export function getCallRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequest[] { + switch (phase) { + case TxExecutionPhase.SETUP: + return tx.data.getNonRevertiblePublicCallRequests(); + case TxExecutionPhase.APP_LOGIC: + return tx.data.getRevertiblePublicCallRequests(); + case TxExecutionPhase.TEARDOWN: { + const request = tx.data.getTeardownPublicCallRequest(); + return request ? [request] : []; + } + default: + throw new Error(`Unknown phase: ${phase}`); + } +} + +// Temporary hack to create PublicKernelCircuitPublicInputs from PrivateKernelTailCircuitPublicInputs. +export function getPublicKernelCircuitPublicInputs( + data: PrivateKernelTailCircuitPublicInputs, + globalVariables: GlobalVariables, +) { + const constants = CombinedConstantData.combine(data.constants, globalVariables); + + const validationRequest = PublicValidationRequests.empty(); + validationRequest.forRollup = data.rollupValidationRequests; + + const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) => { + const to = PublicAccumulatedData.empty(); + to.noteHashes.forEach((_, i) => (to.noteHashes[i].noteHash.value = from.noteHashes[i])); + to.nullifiers.forEach((_, i) => (to.nullifiers[i].value = from.nullifiers[i])); + to.l2ToL1Msgs.forEach((_, i) => (to.l2ToL1Msgs[i] = from.l2ToL1Msgs[i])); + to.noteEncryptedLogsHashes.forEach((_, i) => (to.noteEncryptedLogsHashes[i] = from.noteEncryptedLogsHashes[i])); + to.encryptedLogsHashes.forEach((_, i) => (to.encryptedLogsHashes[i] = from.encryptedLogsHashes[i])); + to.publicCallStack.forEach((_, i) => (to.publicCallStack[i] = from.publicCallRequests[i])); + return to; + }; + + return new PublicKernelCircuitPublicInputs( + constants, + validationRequest, + convertAccumulatedData(data.forPublic!.nonRevertibleAccumulatedData), + convertAccumulatedData(data.forPublic!.revertibleAccumulatedData), + 0, + data.forPublic!.publicTeardownCallRequest, + data.feePayer, + RevertCode.OK, + ); +} + +// Temporary hack to create the AvmCircuitPublicInputs from public tail's public inputs. +export function generateAvmCircuitPublicInputs( + tx: Tx, + tailOutput: KernelCircuitPublicInputs, + gasUsedForFee: Gas, + transactionFee: Fr, +) { + const startTreeSnapshots = new TreeSnapshots( + tailOutput.constants.historicalHeader.state.l1ToL2MessageTree, + tailOutput.startState.noteHashTree, + tailOutput.startState.nullifierTree, + tailOutput.startState.publicDataTree, + ); + + const getArrayLengths = (from: PrivateToPublicAccumulatedData) => + new PrivateToAvmAccumulatedDataArrayLengths( + countAccumulatedItems(from.noteHashes), + countAccumulatedItems(from.nullifiers), + countAccumulatedItems(from.l2ToL1Msgs), + ); + + const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) => + new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs); + + const convertAvmAccumulatedData = (from: CombinedAccumulatedData) => + new AvmAccumulatedData( + from.noteHashes, + from.nullifiers, + from.l2ToL1Msgs, + from.unencryptedLogsHashes, + from.publicDataWrites, + ); + + // This is wrong. But this is not used or checked in the rollup at the moment. + // Should fetch the updated roots from db. + const endTreeSnapshots = startTreeSnapshots; + + const avmCircuitpublicInputs = new AvmCircuitPublicInputs( + tailOutput.constants.globalVariables, + startTreeSnapshots, + tx.data.gasUsed, + tx.data.constants.txContext.gasSettings, + tx.data.forPublic!.nonRevertibleAccumulatedData.publicCallRequests, + tx.data.forPublic!.revertibleAccumulatedData.publicCallRequests, + tx.data.forPublic!.publicTeardownCallRequest, + getArrayLengths(tx.data.forPublic!.nonRevertibleAccumulatedData), + getArrayLengths(tx.data.forPublic!.revertibleAccumulatedData), + convertAccumulatedData(tx.data.forPublic!.nonRevertibleAccumulatedData), + convertAccumulatedData(tx.data.forPublic!.revertibleAccumulatedData), + endTreeSnapshots, + gasUsedForFee, + convertAvmAccumulatedData(tailOutput.end), + transactionFee, + !tailOutput.revertCode.equals(RevertCode.OK), + ); + //console.log(`[FROM TAIL] AVM: ${inspect(avmCircuitpublicInputs, { depth: 5 })}`); + return avmCircuitpublicInputs; +} + +function getPreviousKernelData(previousOutput: PublicKernelCircuitPublicInputs): PublicKernelData { + // The proof is not used in simulation. + const proof = makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH); + + const vk = VerificationKeyData.makeFakeHonk(); + const vkIndex = 0; + const siblingPath = getVKSiblingPath(vkIndex); + + return new PublicKernelData(previousOutput, proof, vk, vkIndex, siblingPath); +} + +export async function runMergeKernelCircuit( + previousOutput: PublicKernelCircuitPublicInputs, + enqueuedCallData: VMCircuitPublicInputs, + publicKernelSimulator: PublicKernelCircuitSimulator, +): Promise { + const previousKernel = getPreviousKernelData(previousOutput); + + // The proof is not used in simulation. + const vmProof = makeEmptyProof(); + const callData = new EnqueuedCallData(enqueuedCallData, vmProof); + + const inputs = new PublicKernelCircuitPrivateInputs(previousKernel, callData); + + return await publicKernelSimulator.publicKernelCircuitMerge(inputs); +} diff --git a/yarn-project/txe/package.json b/yarn-project/txe/package.json index e109bd499251..47e82bd74285 100644 --- a/yarn-project/txe/package.json +++ b/yarn-project/txe/package.json @@ -18,7 +18,7 @@ "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests", - "dev": "DEBUG='aztec:*' LOG_LEVEL=debug node ./dest/bin/index.js", + "dev": "DEBUG='aztec:*,-aztec:avm_simulator:*' LOG_LEVEL=debug node ./dest/bin/index.js", "start": "node ./dest/bin/index.js" }, "inherits": [ diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 3eeb80cf35da..b6c0f55b7ece 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -26,6 +26,7 @@ import { NULLIFIER_SUBTREE_HEIGHT, type NULLIFIER_TREE_HEIGHT, type NullifierLeafPreimage, + PRIVATE_CONTEXT_INPUTS_LENGTH, PUBLIC_DATA_SUBTREE_HEIGHT, type PUBLIC_DATA_TREE_HEIGHT, PUBLIC_DISPATCH_SELECTOR, @@ -33,7 +34,6 @@ import { PublicDataTreeLeaf, type PublicDataTreeLeafPreimage, type PublicDataUpdateRequest, - TaggingSecret, computeContractClassId, computeTaggingSecret, deriveKeys, @@ -348,16 +348,16 @@ export class TXE implements TypedOracle { } async getPublicDataTreeWitness(blockNumber: number, leafSlot: Fr): Promise { - const committedDb = new MerkleTreeSnapshotOperationsFacade(this.trees, blockNumber); - const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt()); + const db = await this.#getTreesAt(blockNumber); + const lowLeafResult = await db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt()); if (!lowLeafResult) { return undefined; } else { - const preimage = (await committedDb.getLeafPreimage( + const preimage = (await db.getLeafPreimage( MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index, )) as PublicDataTreeLeafPreimage; - const path = await committedDb.getSiblingPath( + const path = await db.getSiblingPath( MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index, ); @@ -531,7 +531,7 @@ export class TXE implements TypedOracle { return; } - emitContractClassUnencryptedLog(_log: UnencryptedL2Log, _counter: number): Fr { + emitContractClassLog(_log: UnencryptedL2Log, _counter: number): Fr { throw new Error('Method not implemented.'); } @@ -563,55 +563,53 @@ export class TXE implements TypedOracle { const initialWitness = await this.getInitialWitness(artifact, argsHash, sideEffectCounter, isStaticCall); const acvmCallback = new Oracle(this); const timer = new Timer(); - try { - const acirExecutionResult = await acvm(acir, initialWitness, acvmCallback).catch((err: Error) => { - err.message = resolveAssertionMessageFromError(err, artifact); - - const execError = new ExecutionError( - err.message, - { - contractAddress: targetContractAddress, - functionSelector, - }, - extractCallStack(err, artifact.debug), - { cause: err }, - ); - this.logger.debug(`Error executing private function ${targetContractAddress}:${functionSelector}`); - throw createSimulationError(execError); - }); - const duration = timer.ms(); - const publicInputs = extractPrivateCircuitPublicInputs(artifact, acirExecutionResult.partialWitness); - - const initialWitnessSize = witnessMapToFields(initialWitness).length * Fr.SIZE_IN_BYTES; - this.logger.debug(`Ran external function ${targetContractAddress.toString()}:${functionSelector}`, { - circuitName: 'app-circuit', - duration, - eventName: 'circuit-witness-generation', - inputSize: initialWitnessSize, - outputSize: publicInputs.toBuffer().length, - appCircuitName: 'noname', - } satisfies CircuitWitnessGenerationStats); - - // Apply side effects - const endSideEffectCounter = publicInputs.endSideEffectCounter; - this.sideEffectCounter = endSideEffectCounter.toNumber() + 1; - - await this.addNullifiers( - targetContractAddress, - publicInputs.nullifiers.filter(nullifier => !nullifier.isEmpty()).map(nullifier => nullifier.value), + const acirExecutionResult = await acvm(acir, initialWitness, acvmCallback).catch((err: Error) => { + err.message = resolveAssertionMessageFromError(err, artifact); + + const execError = new ExecutionError( + err.message, + { + contractAddress: targetContractAddress, + functionSelector, + }, + extractCallStack(err, artifact.debug), + { cause: err }, ); + this.logger.debug(`Error executing private function ${targetContractAddress}:${functionSelector}`); + throw createSimulationError(execError); + }); + const duration = timer.ms(); + const publicInputs = extractPrivateCircuitPublicInputs(artifact, acirExecutionResult.partialWitness); + + const initialWitnessSize = witnessMapToFields(initialWitness).length * Fr.SIZE_IN_BYTES; + this.logger.debug(`Ran external function ${targetContractAddress.toString()}:${functionSelector}`, { + circuitName: 'app-circuit', + duration, + eventName: 'circuit-witness-generation', + inputSize: initialWitnessSize, + outputSize: publicInputs.toBuffer().length, + appCircuitName: 'noname', + } satisfies CircuitWitnessGenerationStats); - await this.addNoteHashes( - targetContractAddress, - publicInputs.noteHashes.filter(noteHash => !noteHash.isEmpty()).map(noteHash => noteHash.value), - ); + // Apply side effects + const endSideEffectCounter = publicInputs.endSideEffectCounter; + this.sideEffectCounter = endSideEffectCounter.toNumber() + 1; - return { endSideEffectCounter, returnsHash: publicInputs.returnsHash }; - } finally { - this.setContractAddress(currentContractAddress); - this.setMsgSender(currentMessageSender); - this.setFunctionSelector(currentFunctionSelector); - } + await this.addNullifiers( + targetContractAddress, + publicInputs.nullifiers.filter(nullifier => !nullifier.isEmpty()).map(nullifier => nullifier.value), + ); + + await this.addNoteHashes( + targetContractAddress, + publicInputs.noteHashes.filter(noteHash => !noteHash.isEmpty()).map(noteHash => noteHash.value), + ); + + this.setContractAddress(currentContractAddress); + this.setMsgSender(currentMessageSender); + this.setFunctionSelector(currentFunctionSelector); + + return { endSideEffectCounter, returnsHash: publicInputs.returnsHash }; } async getInitialWitness(abi: FunctionAbi, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean) { @@ -628,9 +626,12 @@ export class TXE implements TypedOracle { sideEffectCounter, isStaticCall, ); + const privateContextInputsAsFields = privateContextInputs.toFields(); + if (privateContextInputsAsFields.length !== PRIVATE_CONTEXT_INPUTS_LENGTH) { + throw new Error('Invalid private context inputs size'); + } - const fields = [...privateContextInputs.toFields(), ...args]; - + const fields = [...privateContextInputsAsFields, ...args]; return toACVMWitness(0, fields); } @@ -783,47 +784,27 @@ export class TXE implements TypedOracle { return; } - async incrementAppTaggingSecret(sender: AztecAddress, recipient: AztecAddress): Promise { - const directionalSecret = await this.#calculateDirectionalSecret(this.contractAddress, sender, recipient); - await this.txeDatabase.incrementTaggingSecretsIndexes([directionalSecret]); + async incrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress): Promise { + const directionalSecret = await this.#calculateTaggingSecret(this.contractAddress, sender, recipient); + await this.txeDatabase.incrementTaggingSecretsIndexesAsSender([directionalSecret]); } - async getAppTaggingSecret(sender: AztecAddress, recipient: AztecAddress): Promise { - const directionalSecret = await this.#calculateDirectionalSecret(this.contractAddress, sender, recipient); - const [index] = await this.txeDatabase.getTaggingSecretsIndexes([directionalSecret]); - return IndexedTaggingSecret.fromTaggingSecret(directionalSecret, index); + async getAppTaggingSecretAsSender(sender: AztecAddress, recipient: AztecAddress): Promise { + const secret = await this.#calculateTaggingSecret(this.contractAddress, sender, recipient); + const [index] = await this.txeDatabase.getTaggingSecretsIndexesAsSender([secret]); + return new IndexedTaggingSecret(secret, index); } - async #calculateDirectionalSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) { + async #calculateTaggingSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) { const senderCompleteAddress = await this.getCompleteAddress(sender); const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender); const sharedSecret = computeTaggingSecret(senderCompleteAddress, senderIvsk, recipient); // Silo the secret to the app so it can't be used to track other app's notes const siloedSecret = poseidon2Hash([sharedSecret.x, sharedSecret.y, contractAddress]); - // Get the index of the secret, ensuring the directionality (sender -> recipient) - const directionalSecret = new TaggingSecret(siloedSecret, recipient); - return directionalSecret; - } - - async #getAppTaggingSecretsForSenders(recipient: AztecAddress): Promise { - const recipientCompleteAddress = await this.getCompleteAddress(recipient); - const completeAddresses = await this.txeDatabase.getCompleteAddresses(); - // Filter out the addresses corresponding to accounts - const accounts = await this.keyStore.getAccounts(); - const senders = completeAddresses.filter( - completeAddress => !accounts.find(account => account.equals(completeAddress.address)), - ); - const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient); - const secrets = senders.map(({ address: sender }) => { - const sharedSecret = computeTaggingSecret(recipientCompleteAddress, recipientIvsk, sender); - return poseidon2Hash([sharedSecret.x, sharedSecret.y, this.contractAddress]); - }); - const directionalSecrets = secrets.map(secret => new TaggingSecret(secret, recipient)); - const indexes = await this.txeDatabase.getTaggingSecretsIndexes(directionalSecrets); - return secrets.map((secret, i) => new IndexedTaggingSecret(secret, recipient, indexes[i])); + return siloedSecret; } - syncNotes(_recipient: AztecAddress) { + syncNotes() { // TODO: Implement return Promise.resolve(); } diff --git a/yarn-project/txe/src/txe_service/txe_service.ts b/yarn-project/txe/src/txe_service/txe_service.ts index f5bb2fc80fb9..75c7f5b5a20b 100644 --- a/yarn-project/txe/src/txe_service/txe_service.ts +++ b/yarn-project/txe/src/txe_service/txe_service.ts @@ -601,16 +601,16 @@ export class TXEService { return toForeignCallResult([]); } - async getAppTaggingSecret(sender: ForeignCallSingle, recipient: ForeignCallSingle) { - const secret = await this.typedOracle.getAppTaggingSecret( + async getAppTaggingSecretAsSender(sender: ForeignCallSingle, recipient: ForeignCallSingle) { + const secret = await this.typedOracle.getAppTaggingSecretAsSender( AztecAddress.fromField(fromSingle(sender)), AztecAddress.fromField(fromSingle(recipient)), ); return toForeignCallResult([toArray(secret.toFields())]); } - async syncNotes(recipient: ForeignCallSingle) { - await this.typedOracle.syncNotes(AztecAddress.fromField(fromSingle(recipient))); + async syncNotes() { + await this.typedOracle.syncNotes(); return toForeignCallResult([]); } diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index b1e7319c4ef3..449d4424f8ec 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -288,10 +288,12 @@ __metadata: "@aztec/circuits.js": "workspace:^" "@aztec/ethereum": "workspace:^" "@aztec/foundation": "workspace:^" + "@aztec/kv-store": "workspace:^" "@aztec/noir-protocol-circuits-types": "workspace:^" "@aztec/simulator": "workspace:^" "@aztec/telemetry-client": "workspace:^" "@aztec/types": "workspace:^" + "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 "@msgpack/msgpack": ^3.0.0-beta2 "@noir-lang/noirc_abi": "portal:../../noir/packages/noirc_abi" @@ -700,8 +702,11 @@ __metadata: "@aztec/bb.js": ../../ts "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" + "@aztec/kv-store": "workspace:^" "@aztec/simulator": "workspace:^" + "@aztec/telemetry-client": "workspace:^" "@aztec/types": "workspace:^" + "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 "@msgpack/msgpack": ^3.0.0-beta2 "@noir-lang/noir_codegen": "portal:../../noir/packages/noir_codegen" @@ -3492,7 +3497,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noir_codegen@portal:../noir/packages/noir_codegen::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/types": 0.37.0 + "@noir-lang/types": 0.38.0 glob: ^10.3.10 ts-command-line-args: ^2.5.1 bin: @@ -3501,13 +3506,13 @@ __metadata: linkType: soft "@noir-lang/noir_js@file:../noir/packages/noir_js::locator=%40aztec%2Faztec3-packages%40workspace%3A.": - version: 0.37.0 - resolution: "@noir-lang/noir_js@file:../noir/packages/noir_js#../noir/packages/noir_js::hash=7257df&locator=%40aztec%2Faztec3-packages%40workspace%3A." + version: 0.38.0 + resolution: "@noir-lang/noir_js@file:../noir/packages/noir_js#../noir/packages/noir_js::hash=9fc813&locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/acvm_js": 0.53.0 - "@noir-lang/noirc_abi": 0.37.0 - "@noir-lang/types": 0.37.0 - checksum: 50419bebe0146ec664232712abb190148a9bb4e9bcfe538a13a0107192e31045ec22efddeeb8eac3eb5ac6cb50f52782adddaaeb87df328ebea3caf55579a3c8 + "@noir-lang/acvm_js": 0.54.0 + "@noir-lang/noirc_abi": 0.38.0 + "@noir-lang/types": 0.38.0 + checksum: 99cdc1f1e352d45a8968261dc7f1d68d58b5bca8177e25c610667eb60954436356c56852e6a23fbf69ddb8db9b92494736438c0852f4702d33e8d0e981e60552 languageName: node linkType: hard @@ -3515,7 +3520,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noirc_abi@portal:../noir/packages/noirc_abi::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/types": 0.37.0 + "@noir-lang/types": 0.38.0 languageName: node linkType: soft