bittensor.core.extrinsics.mev_shield#
Module provides sync MEV Shield extrinsics.
Functions#
|
Submits an encrypted extrinsic to the MEV Shield pallet. |
|
Wait for the result of a MeV Shield encrypted extrinsic. |
Module Contents#
- bittensor.core.extrinsics.mev_shield.submit_encrypted_extrinsic(subtensor, wallet, call, sign_with='coldkey', *, period=None, raise_error=False, wait_for_inclusion=True, wait_for_finalization=False, wait_for_revealed_execution=True, blocks_for_revealed_execution=3)#
Submits an encrypted extrinsic to the MEV Shield pallet.
This function encrypts a call using ML-KEM-768 + XChaCha20Poly1305 and submits it to the MevShield pallet. The extrinsic remains encrypted in the transaction pool until it is included in a block and decrypted by validators.
- Parameters:
subtensor (bittensor.core.subtensor.Subtensor) – The Subtensor client instance used for blockchain interaction.
wallet (bittensor_wallet.Wallet) – The wallet used to sign the extrinsic (must be unlocked, coldkey will be used for signing).
call (scalecodec.types.GenericCall) – The GenericCall object to encrypt and submit.
sign_with (str) – The keypair to use for signing the inner call/extrinsic. Can be either “coldkey” or “hotkey”.
period (Optional[int]) – The number of blocks during which the transaction will remain valid after it’s submitted. If the transaction is not included in a block within that number of blocks, it will expire and be rejected. You can think of it as an expiration date for the transaction.
raise_error (bool) – Raises a relevant exception rather than returning False if unsuccessful.
wait_for_inclusion (bool) – Whether to wait for the inclusion of the transaction.
wait_for_finalization (bool) – Whether to wait for the finalization of the transaction.
wait_for_revealed_execution (bool) – Whether to wait for the executed event, indicating that validators 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 (int) – 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 immediately if the event is found before the block limit is reached.
- Returns:
The result object of the extrinsic execution.
- Return type:
- Raises:
ValueError – If NextKey is not available in storage or encryption fails.
SubstrateRequestException – If the extrinsic fails to be submitted or included.
Note
The encryption uses the public key from NextKey storage, which rotates every block. The payload structure is: payload_core = signer_bytes (32B) + key_hash (32B Blake2-256 hash of NextKey) + SCALE(call) plaintext = payload_core + b”x01” + signature (64B for sr25519) commitment = blake2_256(payload_core)
The key_hash binds the transaction to the key epoch at submission time and replaces nonce-based replay protection.
- bittensor.core.extrinsics.mev_shield.wait_for_extrinsic_by_hash(subtensor, extrinsic_hash, shield_id, submit_block_hash, timeout_blocks=3)#
Wait for the result of a MeV Shield encrypted extrinsic.
After submit_encrypted succeeds, the block author will decrypt and submit the inner extrinsic directly. This function polls subsequent blocks looking for either: - an extrinsic matching the provided hash (success) OR - a markDecryptionFailed extrinsic with matching shield ID (failure)
- Parameters:
subtensor (bittensor.core.subtensor.Subtensor) – SubtensorInterface instance.
extrinsic_hash (str) – The hash of the inner extrinsic to find.
shield_id (str) – The wrapper ID from EncryptedSubmitted event (for detecting decryption failures).
submit_block_hash (str) – Block hash where submit_encrypted was included.
timeout_blocks (int) – Max blocks to wait (default 3).
- Returns:
Optional ExtrinsicReceipt.
- Return type:
Optional[async_substrate_interface.ExtrinsicReceipt]