helix-bridge / contracts

MIT License
7 stars 3 forks source link

how to deal with reorg message on source chain? #46

Open xiaoch05 opened 9 months ago

xiaoch05 commented 9 months ago

Helix uses the messageId of the underlying message as the unique identifier of the transaction, so when a reorg occurs on the source chain, it is possible that the same transaction will generate a different messageId to be sent to the destination chain.

For example, messageId is generated by hash(nonce, payload), the nonce is stored in the contract and is incremented.

At this point, UserA's transaction generates different messageId on the forked chain and the canonical chain, which will be considered as different messages on the target chain, generating a double spend.