2
2
3
3
from .types import MessageStatus , OutputRootProof , BedrockMessageProof
4
4
from .utils import get_provider , get_account , to_low_level_message , make_state_trie_proof , hash_message_hash , read_addresses , load_abi
5
- from .contracts import L2ToL1MessagePasser , L2OutputOracle , OptimismPortal , CrossChainMessengerContract , StandardBridge
5
+ from .contracts import L2ToL1MessagePasser , DisputeGameFactory , FaultDisputeGame , OptimismPortal , CrossChainMessengerContract , StandardBridge
6
6
7
7
class CrossChainMessenger ():
8
8
@@ -111,7 +111,7 @@ def prove_message(self, l2_txn_hash):
111
111
message_proof = self .get_bedrock_message_proof (l2_txn , withrawl_message_hash )
112
112
113
113
optimism_portal = OptimismPortal (self .chain_id_l1 , self .chain_id_l2 , self .account_l1 , provider = self .provider_l1 )
114
- return optimism_portal .prove_withdrawl_transaction (withdrawl_message .values (), message_proof .get_l2_output_index (), message_proof .get_output_root_proof (), message_proof .get_withdrawl_proof ())
114
+ return optimism_portal .prove_withdrawl_transaction (withdrawl_message .values (), message_proof .get_dispute_game_index (), message_proof .get_output_root_proof (), message_proof .get_withdrawl_proof ())
115
115
116
116
def finalize_message (self , l2_txn_hash ):
117
117
@@ -128,10 +128,15 @@ def get_bedrock_message_proof(self, txn, withdrawl_hash):
128
128
129
129
l2_block_number = txn .blockNumber
130
130
131
- l2_output_oracle = L2OutputOracle (self .chain_id_l1 , self .chain_id_l2 , self .account_l1 )
131
+ dispute_game_factory = DisputeGameFactory (self .chain_id_l1 , self .chain_id_l2 , provider = self .provider_l1 )
132
+ game_count = dispute_game_factory .game_count ()
132
133
133
- latest_l2_output_index = l2_output_oracle .latest_output_index ()
134
- output_root , timestamp , l2_block_number = l2_output_oracle .get_l2_output (latest_l2_output_index )
134
+ game_index = game_count - 1
135
+
136
+ latest_game_type , latest_game_timestamp , latest_game_address = dispute_game_factory .game_at_index (game_index )
137
+
138
+ fault_dispute_game = FaultDisputeGame (latest_game_address , self .provider_l1 )
139
+ l2_block_number = fault_dispute_game .l2_block_number ()
135
140
136
141
message_slot = hash_message_hash (withdrawl_hash )
137
142
@@ -145,7 +150,7 @@ def get_bedrock_message_proof(self, txn, withdrawl_hash):
145
150
146
151
bedrock_message_proof = BedrockMessageProof (output_root_proof = output_root_proof ,
147
152
withdrawl_proof = [el .hex () for el in state_trie_proof .storage_proof ],
148
- l2_output_index = latest_l2_output_index )
153
+ dispute_game_index = game_index )
149
154
150
155
return bedrock_message_proof
151
156
@@ -174,8 +179,16 @@ def get_message_status(self, txn_hash):
174
179
return MessageStatus .UNCONFIRMED_L2_TO_L1_MESSAGE
175
180
else :
176
181
if txn_receipt .status == 1 :
177
- l2_output_oracle = L2OutputOracle (self .chain_id_l1 , self .chain_id_l2 , self .account_l1 , provider = self .provider_l1 )
178
- latest_block_number = l2_output_oracle .latest_block_number ()
182
+
183
+ dispute_game_factory = DisputeGameFactory (self .chain_id_l1 , self .chain_id_l2 , provider = self .provider_l1 )
184
+ game_count = dispute_game_factory .game_count ()
185
+
186
+ game_index = game_count - 1
187
+
188
+ latest_game_type , latest_game_timestamp , latest_game_address = dispute_game_factory .game_at_index (game_index )
189
+
190
+ fault_dispute_game = FaultDisputeGame (latest_game_address , self .provider_l1 )
191
+ latest_block_number = fault_dispute_game .l2_block_number ()
179
192
180
193
try :
181
194
_ , message_hash = to_low_level_message (txn , txn_receipt )
@@ -186,12 +199,12 @@ def get_message_status(self, txn_hash):
186
199
return MessageStatus .STATE_ROOT_NOT_PUBLISHED
187
200
else :
188
201
optimism_portal = OptimismPortal (self .chain_id_l1 , self .chain_id_l2 , self .account_l1 , provider = self .provider_l1 )
189
- proven = optimism_portal .proven_withdrawls (message_hash )
202
+ proven = optimism_portal .proven_withdrawls (message_hash , txn [ "from" ] )
190
203
if proven [- 1 ] == 0 :
191
204
return MessageStatus .READY_TO_PROVE
192
205
else :
193
206
current_timestamp = self .provider_l2 .eth .get_block (self .provider_l2 .eth .block_number ).timestamp
194
- if current_timestamp > proven [1 ] + self . challenge_period :
207
+ if current_timestamp > proven [1 ] + optimism_portal . proof_maturity_delay_seconds () :
195
208
return MessageStatus .READY_FOR_RELAY
196
209
else :
197
210
return MessageStatus .IN_CHALLENGE_PERIOD
0 commit comments