@layerzerolabs/protocol-starknet-v2 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +186 -0
- package/.turbo/turbo-lint.log +71 -0
- package/.turbo/turbo-test.log +937 -0
- package/README.md +41 -0
- package/Scarb.lock +211 -0
- package/Scarb.toml +2 -0
- package/dist/4XD3ZRZ4.cjs +301 -0
- package/dist/4XD3ZRZ4.cjs.map +1 -0
- package/dist/4Z5IPBC3.js +299 -0
- package/dist/4Z5IPBC3.js.map +1 -0
- package/dist/5NEZDLVQ.cjs +474 -0
- package/dist/5NEZDLVQ.cjs.map +1 -0
- package/dist/6JYCOKDE.js +472 -0
- package/dist/6JYCOKDE.js.map +1 -0
- package/dist/7C4PFMIZ.cjs +1288 -0
- package/dist/7C4PFMIZ.cjs.map +1 -0
- package/dist/7ZSGGZUE.js +1229 -0
- package/dist/7ZSGGZUE.js.map +1 -0
- package/dist/ARHOGUYH.cjs +2136 -0
- package/dist/ARHOGUYH.cjs.map +1 -0
- package/dist/CRCRIUFX.js +1264 -0
- package/dist/CRCRIUFX.js.map +1 -0
- package/dist/DB7CQSED.cjs +430 -0
- package/dist/DB7CQSED.cjs.map +1 -0
- package/dist/DFXLWHYP.cjs +1266 -0
- package/dist/DFXLWHYP.cjs.map +1 -0
- package/dist/EOLZCMCK.js +988 -0
- package/dist/EOLZCMCK.js.map +1 -0
- package/dist/FFDPTOWG.cjs +331 -0
- package/dist/FFDPTOWG.cjs.map +1 -0
- package/dist/FOJGEAIO.js +2134 -0
- package/dist/FOJGEAIO.js.map +1 -0
- package/dist/IWIUMVGB.js +629 -0
- package/dist/IWIUMVGB.js.map +1 -0
- package/dist/MUEN6AWV.cjs +697 -0
- package/dist/MUEN6AWV.cjs.map +1 -0
- package/dist/ORE6VBZ4.cjs +990 -0
- package/dist/ORE6VBZ4.cjs.map +1 -0
- package/dist/OUFKWPZ7.js +732 -0
- package/dist/OUFKWPZ7.js.map +1 -0
- package/dist/T2QTYQXJ.js +1229 -0
- package/dist/T2QTYQXJ.js.map +1 -0
- package/dist/UPJTM7BR.cjs +631 -0
- package/dist/UPJTM7BR.cjs.map +1 -0
- package/dist/VNVNX2P3.cjs +1231 -0
- package/dist/VNVNX2P3.cjs.map +1 -0
- package/dist/VUOMXK5T.js +6 -0
- package/dist/VUOMXK5T.js.map +1 -0
- package/dist/WISWRTDG.js +1286 -0
- package/dist/WISWRTDG.js.map +1 -0
- package/dist/WU5L7YIQ.cjs +1231 -0
- package/dist/WU5L7YIQ.cjs.map +1 -0
- package/dist/X3B5JDMZ.js +695 -0
- package/dist/X3B5JDMZ.js.map +1 -0
- package/dist/XYNBDBBV.cjs +297 -0
- package/dist/XYNBDBBV.cjs.map +1 -0
- package/dist/Y5JFPCYJ.cjs +734 -0
- package/dist/Y5JFPCYJ.cjs.map +1 -0
- package/dist/YEHL7IYO.js +295 -0
- package/dist/YEHL7IYO.js.map +1 -0
- package/dist/YJF4D23A.cjs +8 -0
- package/dist/YJF4D23A.cjs.map +1 -0
- package/dist/YTS44OEA.js +428 -0
- package/dist/YTS44OEA.js.map +1 -0
- package/dist/Z2NIUZMW.js +329 -0
- package/dist/Z2NIUZMW.js.map +1 -0
- package/dist/abis/blocked-message-lib.cjs +13 -0
- package/dist/abis/blocked-message-lib.cjs.map +1 -0
- package/dist/abis/blocked-message-lib.d.ts +338 -0
- package/dist/abis/blocked-message-lib.d.ts.map +1 -0
- package/dist/abis/blocked-message-lib.js +4 -0
- package/dist/abis/blocked-message-lib.js.map +1 -0
- package/dist/abis/dvn-fee-lib.cjs +13 -0
- package/dist/abis/dvn-fee-lib.cjs.map +1 -0
- package/dist/abis/dvn-fee-lib.d.ts +214 -0
- package/dist/abis/dvn-fee-lib.d.ts.map +1 -0
- package/dist/abis/dvn-fee-lib.js +4 -0
- package/dist/abis/dvn-fee-lib.js.map +1 -0
- package/dist/abis/dvn.cjs +13 -0
- package/dist/abis/dvn.cjs.map +1 -0
- package/dist/abis/dvn.d.ts +952 -0
- package/dist/abis/dvn.d.ts.map +1 -0
- package/dist/abis/dvn.js +4 -0
- package/dist/abis/dvn.js.map +1 -0
- package/dist/abis/endpoint-v2.cjs +13 -0
- package/dist/abis/endpoint-v2.cjs.map +1 -0
- package/dist/abis/endpoint-v2.d.ts +1580 -0
- package/dist/abis/endpoint-v2.d.ts.map +1 -0
- package/dist/abis/endpoint-v2.js +4 -0
- package/dist/abis/endpoint-v2.js.map +1 -0
- package/dist/abis/executor-fee-lib.cjs +13 -0
- package/dist/abis/executor-fee-lib.cjs.map +1 -0
- package/dist/abis/executor-fee-lib.d.ts +217 -0
- package/dist/abis/executor-fee-lib.d.ts.map +1 -0
- package/dist/abis/executor-fee-lib.js +4 -0
- package/dist/abis/executor-fee-lib.js.map +1 -0
- package/dist/abis/executor.cjs +13 -0
- package/dist/abis/executor.cjs.map +1 -0
- package/dist/abis/executor.d.ts +914 -0
- package/dist/abis/executor.d.ts.map +1 -0
- package/dist/abis/executor.js +4 -0
- package/dist/abis/executor.js.map +1 -0
- package/dist/abis/o-app.cjs +13 -0
- package/dist/abis/o-app.cjs.map +1 -0
- package/dist/abis/o-app.d.ts +311 -0
- package/dist/abis/o-app.d.ts.map +1 -0
- package/dist/abis/o-app.js +4 -0
- package/dist/abis/o-app.js.map +1 -0
- package/dist/abis/oft-adapter.cjs +13 -0
- package/dist/abis/oft-adapter.cjs.map +1 -0
- package/dist/abis/oft-adapter.d.ts +722 -0
- package/dist/abis/oft-adapter.d.ts.map +1 -0
- package/dist/abis/oft-adapter.js +4 -0
- package/dist/abis/oft-adapter.js.map +1 -0
- package/dist/abis/oft.cjs +13 -0
- package/dist/abis/oft.cjs.map +1 -0
- package/dist/abis/oft.d.ts +922 -0
- package/dist/abis/oft.d.ts.map +1 -0
- package/dist/abis/oft.js +4 -0
- package/dist/abis/oft.js.map +1 -0
- package/dist/abis/omni-counter.cjs +13 -0
- package/dist/abis/omni-counter.cjs.map +1 -0
- package/dist/abis/omni-counter.d.ts +459 -0
- package/dist/abis/omni-counter.d.ts.map +1 -0
- package/dist/abis/omni-counter.js +4 -0
- package/dist/abis/omni-counter.js.map +1 -0
- package/dist/abis/price-feed.cjs +13 -0
- package/dist/abis/price-feed.cjs.map +1 -0
- package/dist/abis/price-feed.d.ts +505 -0
- package/dist/abis/price-feed.d.ts.map +1 -0
- package/dist/abis/price-feed.js +4 -0
- package/dist/abis/price-feed.js.map +1 -0
- package/dist/abis/simple-message-lib.cjs +13 -0
- package/dist/abis/simple-message-lib.cjs.map +1 -0
- package/dist/abis/simple-message-lib.d.ts +535 -0
- package/dist/abis/simple-message-lib.d.ts.map +1 -0
- package/dist/abis/simple-message-lib.js +4 -0
- package/dist/abis/simple-message-lib.js.map +1 -0
- package/dist/abis/treasury.cjs +13 -0
- package/dist/abis/treasury.cjs.map +1 -0
- package/dist/abis/treasury.d.ts +240 -0
- package/dist/abis/treasury.d.ts.map +1 -0
- package/dist/abis/treasury.js +4 -0
- package/dist/abis/treasury.js.map +1 -0
- package/dist/abis/ultra-light-node.cjs +13 -0
- package/dist/abis/ultra-light-node.cjs.map +1 -0
- package/dist/abis/ultra-light-node.d.ts +900 -0
- package/dist/abis/ultra-light-node.d.ts.map +1 -0
- package/dist/abis/ultra-light-node.js +4 -0
- package/dist/abis/ultra-light-node.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/build-abi.cjs +28 -0
- package/dist/scripts/build-abi.cjs.map +1 -0
- package/dist/scripts/build-abi.d.ts +2 -0
- package/dist/scripts/build-abi.d.ts.map +1 -0
- package/dist/scripts/build-abi.js +26 -0
- package/dist/scripts/build-abi.js.map +1 -0
- package/layerzero/README.md +244 -0
- package/layerzero/Scarb.lock +203 -0
- package/layerzero/Scarb.toml +30 -0
- package/layerzero/snfoundry.toml +11 -0
- package/layerzero/src/common/constants.cairo +26 -0
- package/layerzero/src/common/conversions.cairo +16 -0
- package/layerzero/src/common/guid.cairo +20 -0
- package/layerzero/src/common/packet_v1_codec.cairo +307 -0
- package/layerzero/src/common/structs/messaging.cairo +40 -0
- package/layerzero/src/common/structs/packet.cairo +31 -0
- package/layerzero/src/endpoint/constants.cairo +14 -0
- package/layerzero/src/endpoint/endpoint.cairo +688 -0
- package/layerzero/src/endpoint/errors.cairo +108 -0
- package/layerzero/src/endpoint/events.cairo +124 -0
- package/layerzero/src/endpoint/interfaces/endpoint.cairo +286 -0
- package/layerzero/src/endpoint/interfaces/layerzero_composer.cairo +62 -0
- package/layerzero/src/endpoint/interfaces/layerzero_receiver.cairo +63 -0
- package/layerzero/src/endpoint/message_lib_manager/errors.cairo +95 -0
- package/layerzero/src/endpoint/message_lib_manager/events.cairo +90 -0
- package/layerzero/src/endpoint/message_lib_manager/interface.cairo +449 -0
- package/layerzero/src/endpoint/message_lib_manager/message_lib_manager.cairo +720 -0
- package/layerzero/src/endpoint/message_lib_manager/structs.cairo +33 -0
- package/layerzero/src/endpoint/messaging_channel/errors.cairo +37 -0
- package/layerzero/src/endpoint/messaging_channel/events.cairo +58 -0
- package/layerzero/src/endpoint/messaging_channel/interface.cairo +171 -0
- package/layerzero/src/endpoint/messaging_channel/messaging_channel.cairo +453 -0
- package/layerzero/src/endpoint/messaging_composer/errors.cairo +46 -0
- package/layerzero/src/endpoint/messaging_composer/events.cairo +67 -0
- package/layerzero/src/endpoint/messaging_composer/interface.cairo +132 -0
- package/layerzero/src/endpoint/messaging_composer/messaging_composer.cairo +223 -0
- package/layerzero/src/lib.cairo +189 -0
- package/layerzero/src/message_lib/blocked_message_lib.cairo +114 -0
- package/layerzero/src/message_lib/interface.cairo +63 -0
- package/layerzero/src/message_lib/sml/errors.cairo +23 -0
- package/layerzero/src/message_lib/sml/events.cairo +32 -0
- package/layerzero/src/message_lib/sml/simple_message_lib.cairo +312 -0
- package/layerzero/src/message_lib/structs.cairo +22 -0
- package/layerzero/src/message_lib/uln/errors.cairo +128 -0
- package/layerzero/src/message_lib/uln/events.cairo +97 -0
- package/layerzero/src/message_lib/uln/interface.cairo +83 -0
- package/layerzero/src/message_lib/uln/options.cairo +64 -0
- package/layerzero/src/message_lib/uln/structs/executor_config.cairo +35 -0
- package/layerzero/src/message_lib/uln/structs/payment_info.cairo +7 -0
- package/layerzero/src/message_lib/uln/structs/uln_config.cairo +155 -0
- package/layerzero/src/message_lib/uln/structs/uln_config_storage_node.cairo +91 -0
- package/layerzero/src/message_lib/uln/structs/verification.cairo +7 -0
- package/layerzero/src/message_lib/uln/ultra_light_node.cairo +965 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/errors.cairo +22 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/events.cairo +6 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/interface.cairo +34 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/oapp_options_type_3.cairo +120 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/structs.cairo +6 -0
- package/layerzero/src/oapps/counter/constants.cairo +3 -0
- package/layerzero/src/oapps/counter/counter.cairo +170 -0
- package/layerzero/src/oapps/counter/interface.cairo +27 -0
- package/layerzero/src/oapps/counter/structs.cairo +20 -0
- package/layerzero/src/oapps/message_inspector/interface.cairo +21 -0
- package/layerzero/src/oapps/oapp/errors.cairo +72 -0
- package/layerzero/src/oapps/oapp/events.cairo +9 -0
- package/layerzero/src/oapps/oapp/interface.cairo +67 -0
- package/layerzero/src/oapps/oapp/oapp.cairo +70 -0
- package/layerzero/src/oapps/oapp/oapp_core.cairo +448 -0
- package/layerzero/src/oapps/oft/errors.cairo +42 -0
- package/layerzero/src/oapps/oft/events.cairo +33 -0
- package/layerzero/src/oapps/oft/interface.cairo +87 -0
- package/layerzero/src/oapps/oft/oft.cairo +188 -0
- package/layerzero/src/oapps/oft/oft_adapter.cairo +175 -0
- package/layerzero/src/oapps/oft/oft_compose_msg_codec.cairo +128 -0
- package/layerzero/src/oapps/oft/oft_core.cairo +542 -0
- package/layerzero/src/oapps/oft/oft_msg_codec.cairo +131 -0
- package/layerzero/src/oapps/oft/structs.cairo +72 -0
- package/layerzero/src/treasury/errors.cairo +22 -0
- package/layerzero/src/treasury/events.cairo +5 -0
- package/layerzero/src/treasury/interfaces/layerzero_treasury.cairo +54 -0
- package/layerzero/src/treasury/interfaces/lz_token_fee_lib.cairo +45 -0
- package/layerzero/src/treasury/interfaces/treasury_admin.cairo +39 -0
- package/layerzero/src/treasury/treasury.cairo +140 -0
- package/layerzero/src/workers/access_control.cairo +11 -0
- package/layerzero/src/workers/base/base.cairo +238 -0
- package/layerzero/src/workers/base/errors.cairo +24 -0
- package/layerzero/src/workers/base/events.cairo +43 -0
- package/layerzero/src/workers/base/interface.cairo +93 -0
- package/layerzero/src/workers/base/structs.cairo +10 -0
- package/layerzero/src/workers/common.cairo +59 -0
- package/layerzero/src/workers/dvn/constants.cairo +11 -0
- package/layerzero/src/workers/dvn/dvn.cairo +338 -0
- package/layerzero/src/workers/dvn/errors.cairo +80 -0
- package/layerzero/src/workers/dvn/events.cairo +30 -0
- package/layerzero/src/workers/dvn/fee_lib/dvn_fee_lib.cairo +152 -0
- package/layerzero/src/workers/dvn/fee_lib/interface.cairo +45 -0
- package/layerzero/src/workers/dvn/interface.cairo +131 -0
- package/layerzero/src/workers/dvn/options.cairo +125 -0
- package/layerzero/src/workers/dvn/structs.cairo +51 -0
- package/layerzero/src/workers/executor/errors.cairo +159 -0
- package/layerzero/src/workers/executor/events.cairo +32 -0
- package/layerzero/src/workers/executor/executor.cairo +392 -0
- package/layerzero/src/workers/executor/fee_lib/executor_fee_lib.cairo +160 -0
- package/layerzero/src/workers/executor/fee_lib/interface.cairo +87 -0
- package/layerzero/src/workers/executor/interface.cairo +131 -0
- package/layerzero/src/workers/executor/options.cairo +244 -0
- package/layerzero/src/workers/executor/structs.cairo +119 -0
- package/layerzero/src/workers/interface.cairo +32 -0
- package/layerzero/src/workers/price_feed/constants.cairo +7 -0
- package/layerzero/src/workers/price_feed/errors.cairo +28 -0
- package/layerzero/src/workers/price_feed/events.cairo +13 -0
- package/layerzero/src/workers/price_feed/interface.cairo +264 -0
- package/layerzero/src/workers/price_feed/price_feed.cairo +392 -0
- package/layerzero/src/workers/price_feed/structs.cairo +74 -0
- package/layerzero/tests/common/test_constants.cairo +21 -0
- package/layerzero/tests/common/test_guid.cairo +232 -0
- package/layerzero/tests/common/test_packet_v1_codec.cairo +372 -0
- package/layerzero/tests/common/utils.cairo +23 -0
- package/layerzero/tests/e2e/oft_utils.cairo +121 -0
- package/layerzero/tests/e2e/test_counter_with_sml.cairo +194 -0
- package/layerzero/tests/e2e/test_counter_with_uln.cairo +352 -0
- package/layerzero/tests/e2e/test_dvn.cairo +406 -0
- package/layerzero/tests/e2e/test_lz_token.cairo +354 -0
- package/layerzero/tests/e2e/test_oft_compose_with_uln.cairo +364 -0
- package/layerzero/tests/e2e/test_oft_with_sml.cairo +240 -0
- package/layerzero/tests/e2e/test_oft_with_uln.cairo +299 -0
- package/layerzero/tests/e2e/utils.cairo +490 -0
- package/layerzero/tests/endpoint/message_lib_manager/test_message_lib_manager.cairo +2051 -0
- package/layerzero/tests/endpoint/message_lib_manager/utils.cairo +45 -0
- package/layerzero/tests/endpoint/messaging_channel/test_messaging_channel.cairo +621 -0
- package/layerzero/tests/endpoint/messaging_channel/utils.cairo +96 -0
- package/layerzero/tests/endpoint/messaging_composer/test_messaging_composer.cairo +456 -0
- package/layerzero/tests/endpoint/messaging_composer/utils.cairo +75 -0
- package/layerzero/tests/endpoint/test_endpoint_commit.cairo +763 -0
- package/layerzero/tests/endpoint/test_endpoint_lzreceive.cairo +1253 -0
- package/layerzero/tests/endpoint/test_endpoint_quote.cairo +71 -0
- package/layerzero/tests/endpoint/test_endpoint_send.cairo +1327 -0
- package/layerzero/tests/endpoint/utils.cairo +129 -0
- package/layerzero/tests/fuzzable/blockchain_config.cairo +89 -0
- package/layerzero/tests/fuzzable/bytes32.cairo +16 -0
- package/layerzero/tests/fuzzable/contract_address.cairo +67 -0
- package/layerzero/tests/fuzzable/dst_config.cairo +37 -0
- package/layerzero/tests/fuzzable/eid.cairo +23 -0
- package/layerzero/tests/fuzzable/eth_address.cairo +17 -0
- package/layerzero/tests/fuzzable/expiry.cairo +27 -0
- package/layerzero/tests/fuzzable/felt_array.cairo +38 -0
- package/layerzero/tests/fuzzable/inbound_params.cairo +21 -0
- package/layerzero/tests/fuzzable/keys.cairo +16 -0
- package/layerzero/tests/fuzzable/model_type.cairo +27 -0
- package/layerzero/tests/fuzzable/origin.cairo +21 -0
- package/layerzero/tests/fuzzable/price.cairo +32 -0
- package/layerzero/tests/fuzzable/role_admin.cairo +29 -0
- package/layerzero/tests/fuzzable/small_byte_array.cairo +61 -0
- package/layerzero/tests/lib.cairo +177 -0
- package/layerzero/tests/message_lib/sml/test_simple_message_lib.cairo +224 -0
- package/layerzero/tests/message_lib/uln/test_uln_admin.cairo +2150 -0
- package/layerzero/tests/message_lib/uln/test_uln_config.cairo +527 -0
- package/layerzero/tests/message_lib/uln/test_uln_config_storage_node.cairo +69 -0
- package/layerzero/tests/message_lib/uln/test_uln_executor_config.cairo +173 -0
- package/layerzero/tests/message_lib/uln/test_uln_options.cairo +329 -0
- package/layerzero/tests/message_lib/uln/test_uln_quote.cairo +1038 -0
- package/layerzero/tests/message_lib/uln/test_uln_receive.cairo +715 -0
- package/layerzero/tests/message_lib/uln/test_uln_send.cairo +1155 -0
- package/layerzero/tests/message_lib/uln/utils.cairo +59 -0
- package/layerzero/tests/mocks/composer_target.cairo +76 -0
- package/layerzero/tests/mocks/endpoint.cairo +199 -0
- package/layerzero/tests/mocks/erc20/erc20.cairo +50 -0
- package/layerzero/tests/mocks/erc20/interface.cairo +8 -0
- package/layerzero/tests/mocks/message_inspector/message_inspector.cairo +17 -0
- package/layerzero/tests/mocks/message_lib_manager.cairo +98 -0
- package/layerzero/tests/mocks/messaging_channel/interface.cairo +23 -0
- package/layerzero/tests/mocks/messaging_channel/messaging_channel.cairo +138 -0
- package/layerzero/tests/mocks/messaging_composer.cairo +171 -0
- package/layerzero/tests/mocks/oapp_core/interface.cairo +53 -0
- package/layerzero/tests/mocks/oapp_core/oapp_core.cairo +142 -0
- package/layerzero/tests/mocks/oapp_options_type3.cairo +42 -0
- package/layerzero/tests/mocks/oft_core/interface.cairo +28 -0
- package/layerzero/tests/mocks/oft_core/oft_core.cairo +242 -0
- package/layerzero/tests/mocks/receiver.cairo +54 -0
- package/layerzero/tests/mocks/treasury/lz_token_fee_lib.cairo +57 -0
- package/layerzero/tests/mocks/treasury/treasury.cairo +74 -0
- package/layerzero/tests/mocks/uln_config/interface.cairo +12 -0
- package/layerzero/tests/mocks/uln_config/uln_config.cairo +35 -0
- package/layerzero/tests/mocks/workers/base.cairo +80 -0
- package/layerzero/tests/mocks/workers/dvn.cairo +115 -0
- package/layerzero/tests/mocks/workers/executor/decode/decode.cairo +97 -0
- package/layerzero/tests/mocks/workers/executor/decode/interface.cairo +59 -0
- package/layerzero/tests/mocks/workers/executor/executor.cairo +176 -0
- package/layerzero/tests/oapps/common/test_oapp_options_type_3.cairo +279 -0
- package/layerzero/tests/oapps/oft/test_oft_adapter.cairo +441 -0
- package/layerzero/tests/oapps/oft/test_oft_compose_msg_codec.cairo +139 -0
- package/layerzero/tests/oapps/oft/test_oft_core.cairo +751 -0
- package/layerzero/tests/oapps/oft/test_oft_msg_codec.cairo +268 -0
- package/layerzero/tests/oapps/test_counter.cairo +470 -0
- package/layerzero/tests/oapps/test_oapp_core.cairo +750 -0
- package/layerzero/tests/treasury/test_lz_token_fee_lib.cairo +63 -0
- package/layerzero/tests/treasury/test_treasury.cairo +458 -0
- package/layerzero/tests/treasury/utils.cairo +8 -0
- package/layerzero/tests/utils.cairo +48 -0
- package/layerzero/tests/workers/base/test_worker_base.cairo +1097 -0
- package/layerzero/tests/workers/base/utils.cairo +76 -0
- package/layerzero/tests/workers/dvn/fee_lib/test_dvn_fee_lib.cairo +361 -0
- package/layerzero/tests/workers/dvn/test_dvn.cairo +1101 -0
- package/layerzero/tests/workers/dvn/test_dvn_options.cairo +312 -0
- package/layerzero/tests/workers/dvn/utils.cairo +236 -0
- package/layerzero/tests/workers/executor/fee_lib/test_executor_fee_lib.cairo +223 -0
- package/layerzero/tests/workers/executor/test_decode.cairo +612 -0
- package/layerzero/tests/workers/executor/test_executor.cairo +1472 -0
- package/layerzero/tests/workers/executor/utils.cairo +296 -0
- package/layerzero/tests/workers/price_feed/test_price_feed.cairo +879 -0
- package/layerzero/tests/workers/price_feed/utils.cairo +37 -0
- package/libs/enumerable_set/Scarb.lock +24 -0
- package/libs/enumerable_set/Scarb.toml +17 -0
- package/libs/enumerable_set/src/enumerable_set.cairo +118 -0
- package/libs/enumerable_set/src/lib.cairo +4 -0
- package/libs/enumerable_set/tests/lib.cairo +5 -0
- package/libs/enumerable_set/tests/mocks/mock_enumerable_set.cairo +61 -0
- package/libs/enumerable_set/tests/test_enumerable_set.cairo +379 -0
- package/libs/lz_utils/Scarb.lock +24 -0
- package/libs/lz_utils/Scarb.toml +17 -0
- package/libs/lz_utils/src/bytes.cairo +33 -0
- package/libs/lz_utils/src/error.cairo +12 -0
- package/libs/lz_utils/src/keccak.cairo +28 -0
- package/libs/lz_utils/src/lib.cairo +3 -0
- package/libs/multisig/Scarb.lock +172 -0
- package/libs/multisig/Scarb.toml +23 -0
- package/libs/multisig/src/errors.cairo +84 -0
- package/libs/multisig/src/events.cairo +13 -0
- package/libs/multisig/src/interface.cairo +73 -0
- package/libs/multisig/src/lib.cairo +7 -0
- package/libs/multisig/src/multisig.cairo +241 -0
- package/libs/multisig/tests/lib.cairo +4 -0
- package/libs/multisig/tests/mocks/mock_multisig.cairo +57 -0
- package/libs/multisig/tests/test_multisig.cairo +452 -0
- package/package.json +41 -0
- package/src/scripts/build-abi.ts +51 -0
- package/target/CACHEDIR.TAG +3 -0
- package/target/dev/.fingerprint/alexandria_bytes-5ea6u5t70d7qi/alexandria_bytes +1 -0
- package/target/dev/.fingerprint/alexandria_data_structures-0aue3g6q80gs0/alexandria_data_structures +1 -0
- package/target/dev/.fingerprint/alexandria_math-h2fi7jdq4isuu/alexandria_math +1 -0
- package/target/dev/.fingerprint/core-lq3u730l5p1ag/core +1 -0
- package/target/dev/.fingerprint/core-vf7fc6rvic5vi/core +1 -0
- package/target/dev/.fingerprint/enumerable_set-eaerkg8njl85o/enumerable_set +1 -0
- package/target/dev/.fingerprint/enumerable_set-r54oje7t06ku8/enumerable_set +1 -0
- package/target/dev/.fingerprint/layerzero-oqgdqsaddpi2k/layerzero +1 -0
- package/target/dev/.fingerprint/lz_utils-kfkkeueiqg0pa/lz_utils +1 -0
- package/target/dev/.fingerprint/lz_utils-u4v1os6e7gkng/lz_utils +1 -0
- package/target/dev/.fingerprint/multisig-0fjetugejecge/multisig +1 -0
- package/target/dev/.fingerprint/multisig-6j5kqs436hm54/multisig +1 -0
- package/target/dev/.fingerprint/openzeppelin-ei1id1hu088lo/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin-j9d5nd1qhfnu6/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-3oa41aikpaek0/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-p5h849v8so76q/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-4qhv5fks84g9u/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-hgbm8ln9ah7rm/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-n70q9al0cps8i/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-nnd4f8703t3ak/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-3gnk21ubp5lis/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-rj1bfont4fij4/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-3fja9hd1gvbcq/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-jc3nf5525eet6/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4en77ogr2r2l2/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4t190frqs4db8/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-aqb0f6p9c0bp6/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-nseg8korhin8e/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-g7p73ji1ih1qg/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-qp5328v80452u/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-jjf7tl9rphc6k/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-r6s43vlpj6rqk/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-0dpbnre7engca/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-2sqgvbuv9s800/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-mj395ivff1ffo/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-oh1hse8sjumgm/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-1qnnjnq0pf9u0/starkware_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-mh8e3te65lju4/starkware_utils +1 -0
- package/target/dev/enumerable_set.sierra.json +1 -0
- package/target/dev/incremental/alexandria_bytes-5ea6u5t70d7qi.bin +0 -0
- package/target/dev/incremental/alexandria_data_structures-0aue3g6q80gs0.bin +0 -0
- package/target/dev/incremental/alexandria_math-h2fi7jdq4isuu.bin +0 -0
- package/target/dev/incremental/core-lq3u730l5p1ag.bin +0 -0
- package/target/dev/incremental/core-vf7fc6rvic5vi.bin +0 -0
- package/target/dev/incremental/enumerable_set-eaerkg8njl85o.bin +0 -0
- package/target/dev/incremental/enumerable_set-r54oje7t06ku8.bin +0 -0
- package/target/dev/incremental/layerzero-oqgdqsaddpi2k.bin +0 -0
- package/target/dev/incremental/lz_utils-kfkkeueiqg0pa.bin +0 -0
- package/target/dev/incremental/lz_utils-u4v1os6e7gkng.bin +0 -0
- package/target/dev/incremental/multisig-0fjetugejecge.bin +0 -0
- package/target/dev/incremental/multisig-6j5kqs436hm54.bin +0 -0
- package/target/dev/incremental/openzeppelin-ei1id1hu088lo.bin +0 -0
- package/target/dev/incremental/openzeppelin-j9d5nd1qhfnu6.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-3oa41aikpaek0.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-p5h849v8so76q.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-4qhv5fks84g9u.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-hgbm8ln9ah7rm.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-n70q9al0cps8i.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-nnd4f8703t3ak.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-3gnk21ubp5lis.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-rj1bfont4fij4.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-3fja9hd1gvbcq.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-jc3nf5525eet6.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4en77ogr2r2l2.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4t190frqs4db8.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-aqb0f6p9c0bp6.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-nseg8korhin8e.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-g7p73ji1ih1qg.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-qp5328v80452u.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-jjf7tl9rphc6k.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-r6s43vlpj6rqk.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-0dpbnre7engca.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-2sqgvbuv9s800.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-mj395ivff1ffo.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-oh1hse8sjumgm.bin +0 -0
- package/target/dev/incremental/starkware_utils-1qnnjnq0pf9u0.bin +0 -0
- package/target/dev/incremental/starkware_utils-mh8e3te65lju4.bin +0 -0
- package/target/dev/layerzero.starknet_artifacts.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.contract_class.json +1 -0
- package/target/dev/layerzero_Executor.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Executor.contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_OApp.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OApp.contract_class.json +1 -0
- package/target/dev/layerzero_OFT.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFT.contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.contract_class.json +1 -0
- package/target/dev/lz_utils.sierra.json +1 -0
- package/target/dev/multisig.sierra.json +1 -0
- package/tools/update_contracts.sh +19 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +7 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
//! ULN receive tests
|
|
2
|
+
|
|
3
|
+
use PacketV1Codec::{
|
|
4
|
+
PACKET_HEADER_LENGTH, err_invalid_eid, err_invalid_packet_header, err_invalid_packet_version,
|
|
5
|
+
};
|
|
6
|
+
use alexandria_bytes::byte_array_ext::ByteArrayTraitExt;
|
|
7
|
+
use layerzero::common::packet_v1_codec::PacketV1Codec;
|
|
8
|
+
use layerzero::common::structs::packet::Packet;
|
|
9
|
+
use layerzero::message_lib::interface::{
|
|
10
|
+
IMessageLibDispatcher, IMessageLibDispatcherTrait, IMessageLibSafeDispatcher,
|
|
11
|
+
IMessageLibSafeDispatcherTrait,
|
|
12
|
+
};
|
|
13
|
+
use layerzero::message_lib::uln::errors::err_uln_verifying;
|
|
14
|
+
use layerzero::message_lib::uln::events::PayloadVerified;
|
|
15
|
+
use layerzero::message_lib::uln::interface::{
|
|
16
|
+
IUltraLightNodeAdminDispatcher, IUltraLightNodeAdminDispatcherTrait,
|
|
17
|
+
IUltraLightNodeAdminSafeDispatcher,
|
|
18
|
+
};
|
|
19
|
+
use layerzero::message_lib::uln::structs::uln_config::{SetDefaultUlnConfigParam, UlnConfig};
|
|
20
|
+
use layerzero::message_lib::uln::ultra_light_node::UltraLightNode;
|
|
21
|
+
use lz_utils::bytes::Bytes32;
|
|
22
|
+
use snforge_std::{
|
|
23
|
+
ContractClassTrait, DeclareResultTrait, EventSpyAssertionsTrait, declare, spy_events,
|
|
24
|
+
start_cheat_caller_address, stop_cheat_caller_address,
|
|
25
|
+
};
|
|
26
|
+
use starknet::ContractAddress;
|
|
27
|
+
use starkware_utils_testing::test_utils::assert_panic_with_error;
|
|
28
|
+
|
|
29
|
+
// Import shared test utils
|
|
30
|
+
use crate::message_lib::uln::utils::set_oapp_uln_receive_config_via_message_lib;
|
|
31
|
+
|
|
32
|
+
// Test constants
|
|
33
|
+
pub const OWNER: ContractAddress = 'owner'.try_into().unwrap();
|
|
34
|
+
pub const RECEIVER: ContractAddress = 'receiver'.try_into().unwrap();
|
|
35
|
+
pub const SENDER: ContractAddress = 'sender'.try_into().unwrap();
|
|
36
|
+
pub const DVN_1: ContractAddress = 'dvn_1'.try_into().unwrap();
|
|
37
|
+
pub const DVN_2: ContractAddress = 'dvn_2'.try_into().unwrap();
|
|
38
|
+
pub const DVN_3: ContractAddress = 'dvn_3'.try_into().unwrap();
|
|
39
|
+
pub const SRC_EID: u32 = 1;
|
|
40
|
+
pub const DST_EID: u32 = 2; // This will be the local EID for receive tests
|
|
41
|
+
pub const CONFIRMATIONS: u64 = 20;
|
|
42
|
+
pub const TREASURY_FEE: u256 = 300;
|
|
43
|
+
pub const TREASURY_NATIVE_FEE_CAP: u256 = 100;
|
|
44
|
+
pub const INVALID_EID: u32 = 999;
|
|
45
|
+
|
|
46
|
+
// Helper functions
|
|
47
|
+
fn deploy_ultra_light_node() -> (
|
|
48
|
+
IMessageLibDispatcher,
|
|
49
|
+
IMessageLibSafeDispatcher,
|
|
50
|
+
IUltraLightNodeAdminDispatcher,
|
|
51
|
+
IUltraLightNodeAdminSafeDispatcher,
|
|
52
|
+
ContractAddress,
|
|
53
|
+
ContractAddress,
|
|
54
|
+
) {
|
|
55
|
+
let contract = declare("UltraLightNode").unwrap().contract_class();
|
|
56
|
+
let treasury = deploy_mock_treasury(TREASURY_FEE);
|
|
57
|
+
let endpoint = deploy_mock_endpoint(DST_EID);
|
|
58
|
+
let mut constructor_calldata = array![OWNER.into(), treasury.into(), endpoint.into()];
|
|
59
|
+
TREASURY_NATIVE_FEE_CAP.serialize(ref constructor_calldata);
|
|
60
|
+
let (contract_address, _) = contract.deploy(@constructor_calldata).unwrap();
|
|
61
|
+
let message_lib = IMessageLibDispatcher { contract_address };
|
|
62
|
+
let message_lib_safe = IMessageLibSafeDispatcher { contract_address };
|
|
63
|
+
let admin = IUltraLightNodeAdminDispatcher { contract_address };
|
|
64
|
+
let admin_safe = IUltraLightNodeAdminSafeDispatcher { contract_address };
|
|
65
|
+
|
|
66
|
+
(message_lib, message_lib_safe, admin, admin_safe, contract_address, endpoint)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fn deploy_mock_treasury(treasury_fee: u256) -> ContractAddress {
|
|
70
|
+
let contract = declare("MockTreasury").unwrap().contract_class();
|
|
71
|
+
let constructor_calldata = array![treasury_fee.low.into(), treasury_fee.high.into()];
|
|
72
|
+
let (address, _) = contract.deploy(@constructor_calldata).unwrap();
|
|
73
|
+
address
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fn deploy_mock_endpoint(eid: u32) -> ContractAddress {
|
|
77
|
+
let contract = declare("MockEndpoint").unwrap().contract_class();
|
|
78
|
+
let constructor_calldata = array![eid.into()];
|
|
79
|
+
let (address, _) = contract.deploy(@constructor_calldata).unwrap();
|
|
80
|
+
address
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fn create_required_dvns() -> Array<ContractAddress> {
|
|
84
|
+
array![DVN_1, DVN_2]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fn create_optional_dvns() -> Array<ContractAddress> {
|
|
88
|
+
array![DVN_3]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn create_test_uln_config() -> UlnConfig {
|
|
92
|
+
UlnConfig {
|
|
93
|
+
confirmations: CONFIRMATIONS,
|
|
94
|
+
has_confirmations: true,
|
|
95
|
+
required_dvns: create_required_dvns(),
|
|
96
|
+
has_required_dvns: true,
|
|
97
|
+
optional_dvns: create_optional_dvns(),
|
|
98
|
+
optional_dvn_threshold: 1,
|
|
99
|
+
has_optional_dvns: true,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn create_only_required_dvns_config() -> UlnConfig {
|
|
104
|
+
UlnConfig {
|
|
105
|
+
confirmations: CONFIRMATIONS,
|
|
106
|
+
has_confirmations: true,
|
|
107
|
+
required_dvns: create_required_dvns(),
|
|
108
|
+
has_required_dvns: true,
|
|
109
|
+
optional_dvns: array![],
|
|
110
|
+
optional_dvn_threshold: 0,
|
|
111
|
+
has_optional_dvns: true,
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
fn create_only_optional_dvns_config() -> UlnConfig {
|
|
116
|
+
UlnConfig {
|
|
117
|
+
confirmations: CONFIRMATIONS,
|
|
118
|
+
has_confirmations: true,
|
|
119
|
+
required_dvns: array![],
|
|
120
|
+
has_required_dvns: true,
|
|
121
|
+
optional_dvns: create_optional_dvns(),
|
|
122
|
+
optional_dvn_threshold: 1,
|
|
123
|
+
has_optional_dvns: true,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Helper function to create a valid packet
|
|
128
|
+
fn create_test_packet() -> Packet {
|
|
129
|
+
let receiver_felt: felt252 = RECEIVER.try_into().unwrap();
|
|
130
|
+
Packet {
|
|
131
|
+
nonce: 123,
|
|
132
|
+
src_eid: SRC_EID,
|
|
133
|
+
sender: SENDER,
|
|
134
|
+
dst_eid: DST_EID,
|
|
135
|
+
receiver: Bytes32 { value: receiver_felt.into() },
|
|
136
|
+
guid: Bytes32 { value: 0x987654321 },
|
|
137
|
+
message: "test message",
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Helper function to create a packet with invalid version (we'll modify the header after encoding)
|
|
142
|
+
fn create_invalid_version_packet() -> Packet {
|
|
143
|
+
let receiver_felt: felt252 = RECEIVER.try_into().unwrap();
|
|
144
|
+
Packet {
|
|
145
|
+
nonce: 123,
|
|
146
|
+
src_eid: SRC_EID,
|
|
147
|
+
sender: SENDER,
|
|
148
|
+
dst_eid: DST_EID,
|
|
149
|
+
receiver: Bytes32 { value: receiver_felt.into() },
|
|
150
|
+
guid: Bytes32 { value: 0x987654321 },
|
|
151
|
+
message: "test message",
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Helper function to create a packet with invalid EID
|
|
156
|
+
fn create_invalid_eid_packet() -> Packet {
|
|
157
|
+
let receiver_felt: felt252 = RECEIVER.try_into().unwrap();
|
|
158
|
+
Packet {
|
|
159
|
+
nonce: 123,
|
|
160
|
+
src_eid: SRC_EID,
|
|
161
|
+
sender: SENDER,
|
|
162
|
+
dst_eid: INVALID_EID, // wrong EID
|
|
163
|
+
receiver: Bytes32 { value: receiver_felt.into() },
|
|
164
|
+
guid: Bytes32 { value: 0x987654321 },
|
|
165
|
+
message: "test message",
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Helper function to create a valid packet header using PacketV1Codec
|
|
170
|
+
fn create_packet_header() -> ByteArray {
|
|
171
|
+
let packet = create_test_packet();
|
|
172
|
+
PacketV1Codec::encode_header(@packet)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fn create_invalid_version_header() -> ByteArray {
|
|
176
|
+
let packet = create_invalid_version_packet();
|
|
177
|
+
let mut header = PacketV1Codec::encode_header(@packet);
|
|
178
|
+
|
|
179
|
+
// Manually corrupt the version byte (first byte) to make it invalid
|
|
180
|
+
let mut corrupted_header: ByteArray = Default::default();
|
|
181
|
+
corrupted_header.append_u8(2); // invalid version (should be 1)
|
|
182
|
+
|
|
183
|
+
// Copy the rest of the header (skip the first byte)
|
|
184
|
+
let (_, rest_of_header) = header.read_bytes(1, 80); // 81 - 1 = 80 bytes
|
|
185
|
+
corrupted_header.append(@rest_of_header);
|
|
186
|
+
|
|
187
|
+
corrupted_header
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
fn create_invalid_eid_header() -> ByteArray {
|
|
191
|
+
let packet = create_invalid_eid_packet();
|
|
192
|
+
PacketV1Codec::encode_header(@packet)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn create_short_header() -> ByteArray {
|
|
196
|
+
let mut header: ByteArray = Default::default();
|
|
197
|
+
header.append_u8(1); // version - only 1 byte instead of required 81
|
|
198
|
+
header
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
fn setup_default_receive_config(
|
|
202
|
+
admin: IUltraLightNodeAdminDispatcher, contract_address: ContractAddress, src_eid: u32,
|
|
203
|
+
) {
|
|
204
|
+
start_cheat_caller_address(contract_address, OWNER);
|
|
205
|
+
let default_config = create_test_uln_config();
|
|
206
|
+
let config_params = array![SetDefaultUlnConfigParam { eid: src_eid, config: default_config }];
|
|
207
|
+
admin.set_default_uln_receive_config(config_params);
|
|
208
|
+
stop_cheat_caller_address(contract_address);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Test cases for verify function
|
|
212
|
+
#[test]
|
|
213
|
+
fn test_verify_stores_verification_correctly() {
|
|
214
|
+
let (message_lib, _, _, _, contract_address, _) = deploy_ultra_light_node();
|
|
215
|
+
let packet_header = create_packet_header();
|
|
216
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
217
|
+
let confirmations = 25_u64;
|
|
218
|
+
|
|
219
|
+
// Set up event spy
|
|
220
|
+
let mut spy = spy_events();
|
|
221
|
+
|
|
222
|
+
// Call verify as DVN_1
|
|
223
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
224
|
+
message_lib.verify(packet_header.clone(), payload_hash, confirmations);
|
|
225
|
+
stop_cheat_caller_address(contract_address);
|
|
226
|
+
|
|
227
|
+
// Verify event was emitted
|
|
228
|
+
spy
|
|
229
|
+
.assert_emitted(
|
|
230
|
+
@array![
|
|
231
|
+
(
|
|
232
|
+
contract_address,
|
|
233
|
+
UltraLightNode::Event::PayloadVerified(
|
|
234
|
+
PayloadVerified {
|
|
235
|
+
dvn: DVN_1,
|
|
236
|
+
header: packet_header,
|
|
237
|
+
confirmations: confirmations.into(),
|
|
238
|
+
proof_hash: payload_hash,
|
|
239
|
+
},
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
],
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#[test]
|
|
247
|
+
fn test_verify_multiple_dvns_same_payload() {
|
|
248
|
+
let (message_lib, _, _, _, contract_address, _) = deploy_ultra_light_node();
|
|
249
|
+
let packet_header = create_packet_header();
|
|
250
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
251
|
+
let confirmations1 = 25_u64;
|
|
252
|
+
let confirmations2 = 30_u64;
|
|
253
|
+
|
|
254
|
+
// Set up event spy
|
|
255
|
+
let mut spy = spy_events();
|
|
256
|
+
|
|
257
|
+
// Call verify as DVN_1
|
|
258
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
259
|
+
message_lib.verify(packet_header.clone(), payload_hash, confirmations1);
|
|
260
|
+
stop_cheat_caller_address(contract_address);
|
|
261
|
+
|
|
262
|
+
// Call verify as DVN_2 with different confirmations
|
|
263
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
264
|
+
message_lib.verify(packet_header.clone(), payload_hash, confirmations2);
|
|
265
|
+
stop_cheat_caller_address(contract_address);
|
|
266
|
+
|
|
267
|
+
// Verify both events were emitted
|
|
268
|
+
spy
|
|
269
|
+
.assert_emitted(
|
|
270
|
+
@array![
|
|
271
|
+
(
|
|
272
|
+
contract_address,
|
|
273
|
+
UltraLightNode::Event::PayloadVerified(
|
|
274
|
+
PayloadVerified {
|
|
275
|
+
dvn: DVN_1,
|
|
276
|
+
header: packet_header.clone(),
|
|
277
|
+
confirmations: confirmations1.into(),
|
|
278
|
+
proof_hash: payload_hash,
|
|
279
|
+
},
|
|
280
|
+
),
|
|
281
|
+
),
|
|
282
|
+
(
|
|
283
|
+
contract_address,
|
|
284
|
+
UltraLightNode::Event::PayloadVerified(
|
|
285
|
+
PayloadVerified {
|
|
286
|
+
dvn: DVN_2,
|
|
287
|
+
header: packet_header,
|
|
288
|
+
confirmations: confirmations2.into(),
|
|
289
|
+
proof_hash: payload_hash,
|
|
290
|
+
},
|
|
291
|
+
),
|
|
292
|
+
),
|
|
293
|
+
],
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
#[test]
|
|
298
|
+
fn test_verify_same_dvn_can_overwrite_verification() {
|
|
299
|
+
let (message_lib, _, _, _, contract_address, _) = deploy_ultra_light_node();
|
|
300
|
+
let packet_header = create_packet_header();
|
|
301
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
302
|
+
let confirmations1 = 25_u64;
|
|
303
|
+
let confirmations2 = 35_u64;
|
|
304
|
+
|
|
305
|
+
// Set up event spy
|
|
306
|
+
let mut spy = spy_events();
|
|
307
|
+
|
|
308
|
+
// Call verify as DVN_1 first time
|
|
309
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
310
|
+
message_lib.verify(packet_header.clone(), payload_hash, confirmations1);
|
|
311
|
+
stop_cheat_caller_address(contract_address);
|
|
312
|
+
|
|
313
|
+
// Call verify as DVN_1 second time with different confirmations
|
|
314
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
315
|
+
message_lib.verify(packet_header.clone(), payload_hash, confirmations2);
|
|
316
|
+
stop_cheat_caller_address(contract_address);
|
|
317
|
+
|
|
318
|
+
// Verify both events were emitted (second one overwrites first)
|
|
319
|
+
spy
|
|
320
|
+
.assert_emitted(
|
|
321
|
+
@array![
|
|
322
|
+
(
|
|
323
|
+
contract_address,
|
|
324
|
+
UltraLightNode::Event::PayloadVerified(
|
|
325
|
+
PayloadVerified {
|
|
326
|
+
dvn: DVN_1,
|
|
327
|
+
header: packet_header.clone(),
|
|
328
|
+
confirmations: confirmations1.into(),
|
|
329
|
+
proof_hash: payload_hash,
|
|
330
|
+
},
|
|
331
|
+
),
|
|
332
|
+
),
|
|
333
|
+
(
|
|
334
|
+
contract_address,
|
|
335
|
+
UltraLightNode::Event::PayloadVerified(
|
|
336
|
+
PayloadVerified {
|
|
337
|
+
dvn: DVN_1,
|
|
338
|
+
header: packet_header,
|
|
339
|
+
confirmations: confirmations2.into(),
|
|
340
|
+
proof_hash: payload_hash,
|
|
341
|
+
},
|
|
342
|
+
),
|
|
343
|
+
),
|
|
344
|
+
],
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Test cases for commit function
|
|
349
|
+
#[test]
|
|
350
|
+
fn test_commit_success_with_required_dvns_only() {
|
|
351
|
+
let (message_lib, _, admin, _, contract_address, endpoint_address) = deploy_ultra_light_node();
|
|
352
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
353
|
+
|
|
354
|
+
// Set up receive config for the receiver with only required DVNs
|
|
355
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
356
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
357
|
+
contract_address, RECEIVER, SRC_EID, create_only_required_dvns_config(),
|
|
358
|
+
);
|
|
359
|
+
stop_cheat_caller_address(contract_address);
|
|
360
|
+
|
|
361
|
+
let packet_header = create_packet_header();
|
|
362
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
363
|
+
|
|
364
|
+
// Both required DVNs verify with sufficient confirmations
|
|
365
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
366
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
367
|
+
stop_cheat_caller_address(contract_address);
|
|
368
|
+
|
|
369
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
370
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
371
|
+
stop_cheat_caller_address(contract_address);
|
|
372
|
+
|
|
373
|
+
// Now commit should succeed
|
|
374
|
+
message_lib.commit(packet_header, payload_hash);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#[test]
|
|
378
|
+
fn test_commit_success_with_optional_dvns_only() {
|
|
379
|
+
let (message_lib, _, admin, _, contract_address, endpoint_address) = deploy_ultra_light_node();
|
|
380
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
381
|
+
|
|
382
|
+
// Set up receive config for the receiver with only optional DVNs
|
|
383
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
384
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
385
|
+
contract_address, RECEIVER, SRC_EID, create_only_optional_dvns_config(),
|
|
386
|
+
);
|
|
387
|
+
stop_cheat_caller_address(contract_address);
|
|
388
|
+
|
|
389
|
+
let packet_header = create_packet_header();
|
|
390
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
391
|
+
|
|
392
|
+
// Optional DVN verifies with sufficient confirmations (threshold = 1)
|
|
393
|
+
start_cheat_caller_address(contract_address, DVN_3);
|
|
394
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
395
|
+
stop_cheat_caller_address(contract_address);
|
|
396
|
+
|
|
397
|
+
// Now commit should succeed
|
|
398
|
+
message_lib.commit(packet_header, payload_hash);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
#[test]
|
|
402
|
+
fn test_commit_success_with_mixed_dvns() {
|
|
403
|
+
let (message_lib, _, admin, _, contract_address, endpoint_address) = deploy_ultra_light_node();
|
|
404
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
405
|
+
|
|
406
|
+
// Set up receive config for the receiver with both required and optional DVNs
|
|
407
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
408
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
409
|
+
contract_address, RECEIVER, SRC_EID, create_test_uln_config(),
|
|
410
|
+
);
|
|
411
|
+
stop_cheat_caller_address(contract_address);
|
|
412
|
+
|
|
413
|
+
let packet_header = create_packet_header();
|
|
414
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
415
|
+
|
|
416
|
+
// Both required DVNs verify
|
|
417
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
418
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
419
|
+
stop_cheat_caller_address(contract_address);
|
|
420
|
+
|
|
421
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
422
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
423
|
+
stop_cheat_caller_address(contract_address);
|
|
424
|
+
|
|
425
|
+
// Optional DVN also verifies (threshold = 1)
|
|
426
|
+
start_cheat_caller_address(contract_address, DVN_3);
|
|
427
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
428
|
+
stop_cheat_caller_address(contract_address);
|
|
429
|
+
|
|
430
|
+
// Now commit should succeed
|
|
431
|
+
message_lib.commit(packet_header, payload_hash);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
#[test]
|
|
435
|
+
#[feature("safe_dispatcher")]
|
|
436
|
+
fn test_commit_fails_when_required_dvn_missing() {
|
|
437
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
438
|
+
deploy_ultra_light_node();
|
|
439
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
440
|
+
|
|
441
|
+
// Set up receive config for the receiver with only required DVNs
|
|
442
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
443
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
444
|
+
contract_address, RECEIVER, SRC_EID, create_only_required_dvns_config(),
|
|
445
|
+
);
|
|
446
|
+
stop_cheat_caller_address(contract_address);
|
|
447
|
+
|
|
448
|
+
let packet_header = create_packet_header();
|
|
449
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
450
|
+
|
|
451
|
+
// Only one required DVN verifies (DVN_2 is missing)
|
|
452
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
453
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
454
|
+
stop_cheat_caller_address(contract_address);
|
|
455
|
+
|
|
456
|
+
// Commit should fail because DVN_2 hasn't verified
|
|
457
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
458
|
+
assert_panic_with_error(result, err_uln_verifying());
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
#[test]
|
|
462
|
+
#[feature("safe_dispatcher")]
|
|
463
|
+
fn test_commit_fails_when_optional_threshold_not_met() {
|
|
464
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
465
|
+
deploy_ultra_light_node();
|
|
466
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
467
|
+
|
|
468
|
+
// Set up receive config with higher optional threshold
|
|
469
|
+
let config_with_high_threshold = UlnConfig {
|
|
470
|
+
confirmations: CONFIRMATIONS,
|
|
471
|
+
has_confirmations: true,
|
|
472
|
+
required_dvns: array![],
|
|
473
|
+
has_required_dvns: true,
|
|
474
|
+
optional_dvns: array![DVN_1, DVN_2, DVN_3],
|
|
475
|
+
optional_dvn_threshold: 2, // Need 2 out of 3
|
|
476
|
+
has_optional_dvns: true,
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
480
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
481
|
+
contract_address, RECEIVER, SRC_EID, config_with_high_threshold,
|
|
482
|
+
);
|
|
483
|
+
stop_cheat_caller_address(contract_address);
|
|
484
|
+
|
|
485
|
+
let packet_header = create_packet_header();
|
|
486
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
487
|
+
|
|
488
|
+
// Only one optional DVN verifies (need 2)
|
|
489
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
490
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
491
|
+
stop_cheat_caller_address(contract_address);
|
|
492
|
+
|
|
493
|
+
// Commit should fail because optional threshold not met
|
|
494
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
495
|
+
assert_panic_with_error(result, err_uln_verifying());
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
#[test]
|
|
499
|
+
#[feature("safe_dispatcher")]
|
|
500
|
+
fn test_commit_fails_when_insufficient_confirmations() {
|
|
501
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
502
|
+
deploy_ultra_light_node();
|
|
503
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
504
|
+
|
|
505
|
+
// Set up receive config for the receiver
|
|
506
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
507
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
508
|
+
contract_address, RECEIVER, SRC_EID, create_only_required_dvns_config(),
|
|
509
|
+
);
|
|
510
|
+
stop_cheat_caller_address(contract_address);
|
|
511
|
+
|
|
512
|
+
let packet_header = create_packet_header();
|
|
513
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
514
|
+
|
|
515
|
+
// DVNs verify with insufficient confirmations
|
|
516
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
517
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS - 1); // Not enough
|
|
518
|
+
stop_cheat_caller_address(contract_address);
|
|
519
|
+
|
|
520
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
521
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS - 1); // Not enough
|
|
522
|
+
stop_cheat_caller_address(contract_address);
|
|
523
|
+
|
|
524
|
+
// Commit should fail because confirmations are insufficient
|
|
525
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
526
|
+
assert_panic_with_error(result, err_uln_verifying());
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
#[test]
|
|
530
|
+
#[feature("safe_dispatcher")]
|
|
531
|
+
fn test_commit_success_with_higher_confirmations() {
|
|
532
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
533
|
+
deploy_ultra_light_node();
|
|
534
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
535
|
+
|
|
536
|
+
// Set up receive config for the receiver
|
|
537
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
538
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
539
|
+
contract_address, RECEIVER, SRC_EID, create_only_required_dvns_config(),
|
|
540
|
+
);
|
|
541
|
+
stop_cheat_caller_address(contract_address);
|
|
542
|
+
|
|
543
|
+
let packet_header = create_packet_header();
|
|
544
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
545
|
+
|
|
546
|
+
// DVNs verify with more confirmations than required
|
|
547
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
548
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS + 10);
|
|
549
|
+
stop_cheat_caller_address(contract_address);
|
|
550
|
+
|
|
551
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
552
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS + 5);
|
|
553
|
+
stop_cheat_caller_address(contract_address);
|
|
554
|
+
|
|
555
|
+
// Commit should succeed because confirmations exceed requirement
|
|
556
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
557
|
+
assert(result.is_ok(), 'Commit should succeed');
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
#[test]
|
|
561
|
+
#[feature("safe_dispatcher")]
|
|
562
|
+
fn test_commit_fails_with_invalid_packet_header_version() {
|
|
563
|
+
let (_, message_lib_safe, _, _, _, _) = deploy_ultra_light_node();
|
|
564
|
+
let invalid_header = create_invalid_version_header();
|
|
565
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
566
|
+
|
|
567
|
+
// Commit should fail due to invalid version
|
|
568
|
+
let result = message_lib_safe.commit(invalid_header, payload_hash);
|
|
569
|
+
assert_panic_with_error(result, err_invalid_packet_version(2));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
#[test]
|
|
573
|
+
#[feature("safe_dispatcher")]
|
|
574
|
+
fn test_commit_fails_with_invalid_packet_header_length() {
|
|
575
|
+
let (_, message_lib_safe, _, _, _, _) = deploy_ultra_light_node();
|
|
576
|
+
let short_header = create_short_header();
|
|
577
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
578
|
+
|
|
579
|
+
// Commit should fail due to invalid header length
|
|
580
|
+
let result = message_lib_safe.commit(short_header.clone(), payload_hash);
|
|
581
|
+
assert_panic_with_error(
|
|
582
|
+
result, err_invalid_packet_header(PACKET_HEADER_LENGTH, short_header.len()),
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
#[test]
|
|
587
|
+
#[feature("safe_dispatcher")]
|
|
588
|
+
fn test_commit_fails_with_invalid_eid() {
|
|
589
|
+
let (_, message_lib_safe, _, _, _, _) = deploy_ultra_light_node();
|
|
590
|
+
let invalid_eid_header = create_invalid_eid_header();
|
|
591
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
592
|
+
|
|
593
|
+
// Commit should fail due to wrong destination EID
|
|
594
|
+
let result = message_lib_safe.commit(invalid_eid_header, payload_hash);
|
|
595
|
+
assert_panic_with_error(result, err_invalid_eid(DST_EID, INVALID_EID));
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
#[test]
|
|
599
|
+
#[feature("safe_dispatcher")]
|
|
600
|
+
fn test_commit_clears_verification_storage() {
|
|
601
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
602
|
+
deploy_ultra_light_node();
|
|
603
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
604
|
+
|
|
605
|
+
// Set up receive config for the receiver
|
|
606
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
607
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
608
|
+
contract_address, RECEIVER, SRC_EID, create_test_uln_config(),
|
|
609
|
+
);
|
|
610
|
+
stop_cheat_caller_address(contract_address);
|
|
611
|
+
|
|
612
|
+
let packet_header = create_packet_header();
|
|
613
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
614
|
+
|
|
615
|
+
// All DVNs verify
|
|
616
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
617
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
618
|
+
stop_cheat_caller_address(contract_address);
|
|
619
|
+
|
|
620
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
621
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
622
|
+
stop_cheat_caller_address(contract_address);
|
|
623
|
+
|
|
624
|
+
start_cheat_caller_address(contract_address, DVN_3);
|
|
625
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
626
|
+
stop_cheat_caller_address(contract_address);
|
|
627
|
+
|
|
628
|
+
// Commit should succeed and clear storage
|
|
629
|
+
let result = message_lib_safe.commit(packet_header.clone(), payload_hash);
|
|
630
|
+
assert(result.is_ok(), 'Commit should succeed');
|
|
631
|
+
|
|
632
|
+
// Trying to commit again should fail because storage was cleared
|
|
633
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
634
|
+
assert_panic_with_error(result, err_uln_verifying());
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
#[test]
|
|
638
|
+
#[feature("safe_dispatcher")]
|
|
639
|
+
fn test_commit_success_with_mixed_confirmations() {
|
|
640
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
641
|
+
deploy_ultra_light_node();
|
|
642
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
643
|
+
|
|
644
|
+
// Set up receive config for the receiver
|
|
645
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
646
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
647
|
+
contract_address, RECEIVER, SRC_EID, create_test_uln_config(),
|
|
648
|
+
);
|
|
649
|
+
stop_cheat_caller_address(contract_address);
|
|
650
|
+
|
|
651
|
+
let packet_header = create_packet_header();
|
|
652
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
653
|
+
|
|
654
|
+
// DVNs verify with different confirmations (all >= required)
|
|
655
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
656
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS); // exactly required
|
|
657
|
+
stop_cheat_caller_address(contract_address);
|
|
658
|
+
|
|
659
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
660
|
+
message_lib
|
|
661
|
+
.verify(packet_header.clone(), payload_hash, CONFIRMATIONS + 5); // more than required
|
|
662
|
+
stop_cheat_caller_address(contract_address);
|
|
663
|
+
|
|
664
|
+
start_cheat_caller_address(contract_address, DVN_3);
|
|
665
|
+
message_lib
|
|
666
|
+
.verify(packet_header.clone(), payload_hash, CONFIRMATIONS + 10); // much more than required
|
|
667
|
+
stop_cheat_caller_address(contract_address);
|
|
668
|
+
|
|
669
|
+
// Commit should succeed
|
|
670
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
671
|
+
assert(result.is_ok(), 'Commit should succeed');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
#[test]
|
|
675
|
+
#[feature("safe_dispatcher")]
|
|
676
|
+
fn test_commit_success_with_partial_optional_verification() {
|
|
677
|
+
let (message_lib, message_lib_safe, admin, _, contract_address, endpoint_address) =
|
|
678
|
+
deploy_ultra_light_node();
|
|
679
|
+
setup_default_receive_config(admin, contract_address, SRC_EID);
|
|
680
|
+
|
|
681
|
+
// Set up config with multiple optional DVNs but low threshold
|
|
682
|
+
let config_with_multiple_optional = UlnConfig {
|
|
683
|
+
confirmations: CONFIRMATIONS,
|
|
684
|
+
has_confirmations: true,
|
|
685
|
+
required_dvns: array![DVN_1],
|
|
686
|
+
has_required_dvns: true,
|
|
687
|
+
optional_dvns: array![DVN_2, DVN_3],
|
|
688
|
+
optional_dvn_threshold: 1, // Only need 1 out of 2
|
|
689
|
+
has_optional_dvns: true,
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
start_cheat_caller_address(contract_address, endpoint_address);
|
|
693
|
+
set_oapp_uln_receive_config_via_message_lib(
|
|
694
|
+
contract_address, RECEIVER, SRC_EID, config_with_multiple_optional,
|
|
695
|
+
);
|
|
696
|
+
stop_cheat_caller_address(contract_address);
|
|
697
|
+
|
|
698
|
+
let packet_header = create_packet_header();
|
|
699
|
+
let payload_hash = Bytes32 { value: 0x123456789abcdef };
|
|
700
|
+
|
|
701
|
+
// Required DVN verifies
|
|
702
|
+
start_cheat_caller_address(contract_address, DVN_1);
|
|
703
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
704
|
+
stop_cheat_caller_address(contract_address);
|
|
705
|
+
|
|
706
|
+
// Only one optional DVN verifies (threshold = 1)
|
|
707
|
+
start_cheat_caller_address(contract_address, DVN_2);
|
|
708
|
+
message_lib.verify(packet_header.clone(), payload_hash, CONFIRMATIONS);
|
|
709
|
+
stop_cheat_caller_address(contract_address);
|
|
710
|
+
// DVN_3 doesn't verify
|
|
711
|
+
|
|
712
|
+
// Commit should succeed because threshold is met
|
|
713
|
+
let result = message_lib_safe.commit(packet_header, payload_hash);
|
|
714
|
+
assert(result.is_ok(), 'Commit should succeed');
|
|
715
|
+
}
|