@@ -46,6 +46,7 @@ type EventFilterer interface {
4646
4747type AcrossData struct {
4848 DepositId * big.Int
49+ Nonce * big.Int
4950 LiquidityPool common.Address
5051 Caller common.Address
5152 Coordinator peer.ID
@@ -134,6 +135,7 @@ func (h *AcrossMessageHandler) Listen(ctx context.Context) {
134135
135136 msg := NewAcrossMessage (acrossMsg .Source , acrossMsg .Destination , AcrossData {
136137 DepositId : acrossMsg .DepositId ,
138+ Nonce : acrossMsg .Nonce ,
137139 Coordinator : wMsg .From ,
138140 LiquidityPool : common .HexToAddress (acrossMsg .LiqudityPool ),
139141 Caller : common .HexToAddress (acrossMsg .Caller ),
@@ -159,6 +161,8 @@ func (h *AcrossMessageHandler) Listen(ctx context.Context) {
159161func (h * AcrossMessageHandler ) HandleMessage (m * message.Message ) (* proposal.Proposal , error ) {
160162 data := m .Data .(AcrossData )
161163
164+ log .Info ().Str ("depositId" , data .DepositId .String ()).Msgf ("Handling across message %+v" , data )
165+
162166 sourceChainID := h .chainID
163167 if data .Coordinator == peer .ID ("" ) {
164168 data .Coordinator = h .host .ID ()
@@ -214,6 +218,7 @@ func (h *AcrossMessageHandler) HandleMessage(m *message.Message) (*proposal.Prop
214218func (h * AcrossMessageHandler ) notify (m * message.Message , data AcrossData ) error {
215219 msgBytes , err := tssMessage .MarshalAcrossMessage (
216220 data .DepositId ,
221+ data .Nonce ,
217222 data .LiquidityPool .Hex (),
218223 data .Caller .Hex (),
219224 m .Source ,
@@ -287,7 +292,9 @@ func (h *AcrossMessageHandler) waitForConfirmations(
287292 }
288293
289294 // nolint:gosec
290- time .Sleep (time .Duration (uint64 (h .blocktime ) * (requiredConfirmations - confirmations .Uint64 ())))
295+ duration := time .Duration (uint64 (h .blocktime ) * (requiredConfirmations - confirmations .Uint64 ()))
296+ log .Debug ().Msgf ("Waiting for tx %s for %s" , txHash , duration )
297+ time .Sleep (duration )
291298 }
292299 }
293300}
@@ -378,7 +385,7 @@ func (h *AcrossMessageHandler) unlockHash(
378385 "amount" : deposit .OutputAmount ,
379386 "target" : common .BytesToAddress (deposit .Recipient [12 :]).Hex (),
380387 "targetCallData" : hexutil .Encode (calldata ),
381- "nonce" : h . nonce ( deposit , sourceChainId ) ,
388+ "nonce" : data . Nonce ,
382389 "deadline" : new (big.Int ).SetUint64 (uint64 (deposit .FillDeadline )),
383390 }
384391
@@ -423,29 +430,3 @@ func (h *AcrossMessageHandler) unlockHash(
423430 rawData := []byte (fmt .Sprintf ("\x19 \x01 %s%s" , string (domainSeparator ), string (messageHash )))
424431 return crypto .Keccak256 (rawData ), nil
425432}
426-
427- // nonce creates a unique ID from the across deposit id, origin chain id and protocol id.
428- // Resulting id has this format: [originChainID (8 bits)][protocolID (8 bits)][nonce (240 bits)].
429- func (h * AcrossMessageHandler ) nonce (deposit * events.AcrossDeposit , sourceChainId uint64 ) * big.Int {
430- // Create a new big.Int
431- nonce := new (big.Int )
432-
433- // Set originChainID (8 bits)
434- originChainID := new (big.Int ).SetUint64 (sourceChainId )
435- originChainID .And (originChainID , new (big.Int ).SetUint64 (0xFF )) // Ensure only 8 bits are used
436- nonce .Lsh (originChainID , 248 ) // Shift left by 248 bits
437-
438- // Add protocolID in the middle (8 bits, shifted left by 240 bits)
439- protocolInt := big .NewInt (PROTOCOL_ID )
440- protocolInt .And (protocolInt , new (big.Int ).SetUint64 (0xFF )) // Ensure only 8 bits are used
441- protocolInt .Lsh (protocolInt , 240 )
442- nonce .Or (nonce , protocolInt )
443-
444- // Add depositId at the end (240 bits)
445- depositIdMask := new (big.Int ).Lsh (big .NewInt (1 ), 240 )
446- depositIdMask .Sub (depositIdMask , big .NewInt (1 )) // Create a mask of 240 1's
447- depositId := new (big.Int ).And (deposit .DepositId , depositIdMask ) // Ensure only 240 bits are used
448- nonce .Or (nonce , depositId )
449-
450- return nonce
451- }
0 commit comments