ChildToParentMessageNitro¶
- arbitrum_py.message.child_to_parent_message_nitro.get_child_block_range_cache_key(child_chain_id, l1_block_number)[source]¶
Create a unique cache key for the child block range lookup.
- Parameters:
child_chain_id (
int) – The chain ID of the child chainl1_block_number (
int) – The L1 block number to create a cache key for
- Return type:
str- Returns:
A unique string key combining chain ID and block number
- arbitrum_py.message.child_to_parent_message_nitro.set_child_block_range_cache(key, value)[source]¶
Cache the child block range under the given key.
- Parameters:
key (
str) – The cache key to store the value undervalue (
List[Optional[int]]) – The block range values to cache
- Return type:
None
- arbitrum_py.message.child_to_parent_message_nitro.get_block_ranges_for_l1_block_with_cache(parent_provider, child_provider, for_l1_block)[source]¶
Get block ranges for an L1 block using a shared cache to avoid repeated calls.
- Parameters:
parent_provider (
Web3) – Web3 provider instance for the parent chainchild_provider (
Web3) – Web3 provider instance for the child chainfor_l1_block (
int) – The L1 block number to get ranges for
- Return type:
List[Optional[int]]- Returns:
List of block ranges, where each element can be None
- class arbitrum_py.message.child_to_parent_message_nitro.ChildToParentMessageNitro(event)[source]¶
Bases:
objectBase functionality for ‘nitro’ child->parent messages.
This class provides the core functionality for handling messages sent from a child chain to its parent chain in the Arbitrum Nitro protocol.
- __init__(event)[source]¶
Initialize a new ChildToParentMessageNitro instance.
- Parameters:
event (
dict) – The ChildToParentTx event dictionary from the child chain
- classmethod from_event(parent_signer_or_provider, event, parent_provider=None)[source]¶
Create a message reader or writer based on the provided signer/provider.
- Parameters:
parent_signer_or_provider (
Web3) – Signer or provider for the parent chainevent (
dict) – The event data containing message detailsparent_provider (
Optional[Web3]) – Optional override provider for the parent chain
- Return type:
Union[ChildToParentMessageReaderNitro,ChildToParentMessageWriterNitro]- Returns:
Either a reader or writer instance based on input type
- static get_child_to_parent_events(child_provider, filter_dict, position=None, destination=None, hash=None)[source]¶
Fetch Child->Parent events from the child chain.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chainfilter_dict (
dict) – Dictionary containing filter parameters (fromBlock, toBlock)position (
Optional[int]) – Optional position to filter events bydestination (
Optional[str]) – Optional destination address to filter events byhash (
Optional[str]) – Optional hash to filter events by
- Return type:
List[dict]- Returns:
List of matching event dictionaries
- class arbitrum_py.message.child_to_parent_message_nitro.ChildToParentMessageReaderNitro(parent_provider, event)[source]¶
Bases:
ChildToParentMessageNitroRead-only logic for child->parent messages in Nitro. Replaces L2ToL1MessageReaderNitro.
- __init__(parent_provider, event)[source]¶
Initialize a new ChildToParentMessageNitro instance.
- Parameters:
event (
CaseDict) – The ChildToParentTx event dictionary from the child chain
- get_outbox_proof(child_provider)[source]¶
Equivalent to getOutboxProof in the TS code. Constructs a proof to execute the message.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chain- Return type:
List[bytes]- Returns:
The outbox proof
- has_executed(child_provider)[source]¶
Checks if the message is already executed by calling Outbox.isSpent(position).
- Parameters:
child_provider (
Web3) – Web3 provider for the child chain- Return type:
bool- Returns:
Whether the message has been executed
- status(child_provider)[source]¶
Returns the status of this message (UNCONFIRMED, CONFIRMED, or EXECUTED).
- Parameters:
child_provider (
Web3) – Web3 provider for the child chain- Return type:
- Returns:
The status of the message
- parse_node_created_assertion(fetched_event)[source]¶
For a classic RollupUserLogic NodeCreated event. Replaces parseNodeCreatedAssertion from TS code.
- Parameters:
fetched_event (
FetchedEvent) – The event data- Return type:
Dict[str,Dict[str,bytes]]- Returns:
The parsed assertion data
- parse_assertion_created_event(fetched_event)[source]¶
For a BoldRollupUserLogic AssertionCreated event (BoLD). Replaces parseAssertionCreatedEvent from TS code.
- Parameters:
fetched_event – The event data
- Returns:
The parsed assertion data
- is_assertion_created_log(fetched_event)[source]¶
Distinguishes between NodeCreated (legacy) vs. AssertionCreated (BoLD). In TS, we look for ‘event.challengeManager != undefined’.
- Parameters:
fetched_event (
dict) – The event data- Return type:
bool- Returns:
Whether the event is an AssertionCreated log
- get_block_from_assertion_log(child_provider, fetched_event=None)[source]¶
Merges logic from getBlockFromNodeLog + getBlockFromAssertionLog in TS.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chainfetched_event (
Optional[FetchedEvent]) – The event data
- Return type:
AttributeDict- Returns:
The block data
- get_block_from_assertion_id(rollup_contract, assertion_id, child_provider)[source]¶
Merges getBlockFromNodeNum with the BoLD path using getAssertion. In TS, we do rollup.getNode(…) vs rollup.getAssertion(…).
- Parameters:
rollup_contract – The rollup contract instance
assertion_id – The assertion ID
child_provider – Web3 provider for the child chain
- Returns:
The block data
- get_batch_number(child_provider)[source]¶
findBatchContainingBlock parallels TS logic, but might fail if the block doesn’t exist yet.
- Parameters:
child_provider – Web3 provider for the child chain
- Return type:
Optional[int]- Returns:
The batch number
- get_send_props(child_provider)[source]¶
Merges logic from getSendProps in TS: checks whether the node is confirmed or not. If so, we store sendRootSize, sendRootHash, sendRootConfirmed, etc.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chain- Return type:
Dict[str,Union[int,str,bool,None]]- Returns:
The send properties
- wait_until_ready_to_execute(child_provider, retry_delay=1000)[source]¶
Wait repeatedly until the outbox entry (assertion) is confirmed, so the message can be executed.
Warning
This operation may take a very long time (1 week+) as outbox entries are only created when the corresponding node is confirmed.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chainretry_delay (
int) – Milliseconds to wait between status checks
- Return type:
- Returns:
Final message status (either EXECUTED or CONFIRMED)
- get_first_executable_block(child_provider)[source]¶
getFirstExecutableBlock from the TS code: - If message can be or is already executed, return None - Otherwise, find the earliest block in which it can be executed
- Parameters:
child_provider – Web3 provider for the child chain
- Return type:
Optional[NewType()(BlockNumber,int)]- Returns:
The first executable block number
- class arbitrum_py.message.child_to_parent_message_nitro.ChildToParentMessageWriterNitro(parent_signer, event, parent_provider=None)[source]¶
Bases:
ChildToParentMessageReaderNitroRead+Write access for nitro Child->Parent messages. Replaces L2ToL1MessageWriterNitro.
- __init__(parent_signer, event, parent_provider=None)[source]¶
Initialize a new ChildToParentMessageNitro instance.
- Parameters:
event (
CaseDict) – The ChildToParentTx event dictionary from the child chain
- execute(child_provider, overrides=None)[source]¶
Executes the Child->Parent message on the parent chain once the outbox entry is confirmed. Throws if message is not yet CONFIRMED.
- Parameters:
child_provider (
Web3) – Web3 provider for the child chainoverrides (
None) – Optional transaction overrides
- Return type:
AttributeDict- Returns:
The transaction receipt