From d5beb734c86817a8627ebdfae51f2d109fc11ad7 Mon Sep 17 00:00:00 2001 From: Roman Chkhaidze Date: Mon, 22 Dec 2025 10:11:21 -0800 Subject: [PATCH 1/2] remove `+1` from block range --- bittensor/core/async_subtensor.py | 2 +- bittensor/core/extrinsics/asyncex/mev_shield.py | 6 +++--- bittensor/core/extrinsics/mev_shield.py | 6 +++--- bittensor/core/subtensor.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index b7926ea807..6dab64e150 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -7002,7 +7002,7 @@ async def mev_submit_encrypted( have successfully decrypted and executed the inner call. If True, the function will poll subsequent blocks for the event matching this submission's commitment. blocks_for_revealed_execution: Maximum number of blocks to poll for the executed event after - inclusion. The function checks blocks from start_block+1 to start_block + blocks_for_revealed_execution. + inclusion. The function checks blocks from start_block to start_block + blocks_for_revealed_execution. Returns immediately if the event is found before the block limit is reached. Returns: diff --git a/bittensor/core/extrinsics/asyncex/mev_shield.py b/bittensor/core/extrinsics/asyncex/mev_shield.py index a31fab1dae..8aa8dd7043 100644 --- a/bittensor/core/extrinsics/asyncex/mev_shield.py +++ b/bittensor/core/extrinsics/asyncex/mev_shield.py @@ -40,14 +40,14 @@ async def wait_for_extrinsic_by_hash( extrinsic_hash: The hash of the inner extrinsic to find. shield_id: The wrapper ID from EncryptedSubmitted event (for detecting decryption failures). submit_block_hash: Block hash where submit_encrypted was included. - timeout_blocks: Max blocks to wait (default 3). + timeout_blocks: Max blocks to wait. Returns: Optional ExtrinsicReceipt. """ starting_block = await subtensor.substrate.get_block_number(submit_block_hash) - current_block = starting_block + 1 + current_block = starting_block while current_block - starting_block <= timeout_blocks: logging.debug( @@ -127,7 +127,7 @@ async def submit_encrypted_extrinsic( successfully decrypted and executed the inner call. If True, the function will poll subsequent blocks for the event matching this submission's commitment. blocks_for_revealed_execution: Maximum number of blocks to poll for the executed event after inclusion. - The function checks blocks from start_block + 1 to start_block + blocks_for_revealed_execution. Returns + The function checks blocks from start_block to start_block + blocks_for_revealed_execution. Returns immediately if the event is found before the block limit is reached. Returns: diff --git a/bittensor/core/extrinsics/mev_shield.py b/bittensor/core/extrinsics/mev_shield.py index 8f0ab3c854..a21a397270 100644 --- a/bittensor/core/extrinsics/mev_shield.py +++ b/bittensor/core/extrinsics/mev_shield.py @@ -39,14 +39,14 @@ def wait_for_extrinsic_by_hash( extrinsic_hash: The hash of the inner extrinsic to find. shield_id: The wrapper ID from EncryptedSubmitted event (for detecting decryption failures). submit_block_hash: Block hash where submit_encrypted was included. - timeout_blocks: Max blocks to wait (default 3). + timeout_blocks: Max blocks to wait. Returns: Optional ExtrinsicReceipt. """ starting_block = subtensor.substrate.get_block_number(submit_block_hash) - current_block = starting_block + 1 + current_block = starting_block while current_block - starting_block <= timeout_blocks: logging.debug( @@ -126,7 +126,7 @@ def submit_encrypted_extrinsic( successfully decrypted and executed the inner call. If True, the function will poll subsequent blocks for the event matching this submission's commitment. blocks_for_revealed_execution: Maximum number of blocks to poll for the executed event after inclusion. - The function checks blocks from start_block + 1 to start_block + blocks_for_revealed_execution. Returns + The function checks blocks from start_block to start_block + blocks_for_revealed_execution. Returns immediately if the event is found before the block limit is reached. Returns: diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 217e93d9ff..6862f3a1c4 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -5847,7 +5847,7 @@ def mev_submit_encrypted( have successfully decrypted and executed the inner call. If True, the function will poll subsequent blocks for the event matching this submission's commitment. blocks_for_revealed_execution: Maximum number of blocks to poll for the executed event after inclusion. The - function checks blocks from start_block+1 to start_block + blocks_for_revealed_execution. Returns + function checks blocks from start_block to start_block + blocks_for_revealed_execution. Returns immediately if the event is found before the block limit is reached. Returns: From 4e9185e06c46fcd57b6c63472e84fc33ef68a42e Mon Sep 17 00:00:00 2001 From: Roman Chkhaidze Date: Mon, 22 Dec 2025 10:11:28 -0800 Subject: [PATCH 2/2] fix unit tests --- tests/unit_tests/extrinsics/asyncex/test_mev_shield.py | 10 +++++----- tests/unit_tests/extrinsics/test_mev_shield.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py b/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py index a9475af019..4143252636 100644 --- a/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py +++ b/tests/unit_tests/extrinsics/asyncex/test_mev_shield.py @@ -15,7 +15,7 @@ async def test_wait_for_extrinsic_by_hash_success(subtensor, mocker): shield_id = "shield_id_123" submit_block_hash = "0xblockhash" starting_block = 100 - current_block = 101 + current_block = 100 mocked_get_block_number = mocker.patch.object( subtensor.substrate, @@ -76,7 +76,7 @@ async def test_wait_for_extrinsic_by_hash_decryption_failed(subtensor, mocker): shield_id = "shield_id_123" submit_block_hash = "0xblockhash" starting_block = 100 - current_block = 101 + current_block = 100 mocked_get_block_number = mocker.patch.object( subtensor.substrate, @@ -174,9 +174,9 @@ async def test_wait_for_extrinsic_by_hash_timeout(subtensor, mocker): # Asserts mocked_get_block_number.assert_awaited_once_with(submit_block_hash) - assert mocked_wait_for_block.await_count == 3 - assert mocked_get_block_hash.await_count == 3 - assert mocked_get_extrinsics.await_count == 3 + assert mocked_wait_for_block.await_count == 4 + assert mocked_get_block_hash.await_count == 4 + assert mocked_get_extrinsics.await_count == 4 assert result is None diff --git a/tests/unit_tests/extrinsics/test_mev_shield.py b/tests/unit_tests/extrinsics/test_mev_shield.py index 514f58e11a..44b7cec7a9 100644 --- a/tests/unit_tests/extrinsics/test_mev_shield.py +++ b/tests/unit_tests/extrinsics/test_mev_shield.py @@ -13,7 +13,7 @@ def test_wait_for_extrinsic_by_hash_success(subtensor, mocker): shield_id = "shield_id_123" submit_block_hash = "0xblockhash" starting_block = 100 - current_block = 101 + current_block = 100 mocked_get_block_number = mocker.patch.object( subtensor.substrate, "get_block_number", return_value=starting_block @@ -67,7 +67,7 @@ def test_wait_for_extrinsic_by_hash_decryption_failed(subtensor, mocker): shield_id = "shield_id_123" submit_block_hash = "0xblockhash" starting_block = 100 - current_block = 101 + current_block = 100 mocked_get_block_number = mocker.patch.object( subtensor.substrate, "get_block_number", return_value=starting_block @@ -152,9 +152,9 @@ def test_wait_for_extrinsic_by_hash_timeout(subtensor, mocker): # Asserts mocked_get_block_number.assert_called_once_with(submit_block_hash) - assert mocked_wait_for_block.call_count == 3 - assert mocked_get_block_hash.call_count == 3 - assert mocked_get_extrinsics.call_count == 3 + assert mocked_wait_for_block.call_count == 4 + assert mocked_get_block_hash.call_count == 4 + assert mocked_get_extrinsics.call_count == 4 assert result is None